weechatRN

Weechat relay client for iOS using websockets https://github.com/mhoran/weechatRN
git clone http://git.hanabi.in/repos/weechatRN.git
Log | Files | Refs | README | LICENSE

commit 2431c215ddd5067f93416c26733768363a2ff318
parent 09d771d74d221bc32c4b98dc94008206dfd80f46
Author: Johan Lindskogen <johan.lindskogen@gmail.com>
Date:   Sun,  1 Apr 2018 18:07:42 +0200

Move Root component to Root

Diffstat:
Mindex.js | 57+++------------------------------------------------------
Asrc/usecase/Root.tsx | 59+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 62 insertions(+), 54 deletions(-)

diff --git a/index.js b/index.js @@ -1,55 +1,4 @@ -import React from "react"; -import { StatusBar, AppRegistry } from "react-native"; -import { Provider } from "react-redux"; +import { AppRegistry } from "react-native"; +import Root from "./src/usecase/Root"; -import WeechatConnection from "./src/lib/weechat/connection"; -import { HOSTNAME, PASSWORD } from "./config"; - -import store from "./src/store"; - -import App from "./src/usecase/App"; -import ConnectionGate from "./src/usecase/ConnectionGate"; - -const connection = new WeechatConnection(store.dispatch, HOSTNAME, PASSWORD); - -class WeechatNative extends React.Component { - componentWillMount() { - const compressed = false; - - connection.connect().then( - conn => { - conn.send( - `init password=${PASSWORD},compression=${compressed ? "zlib" : "off"}` - ); - conn.send("(version) info version"); - // conn.send("(hotlist) hdata hotlist:gui_hotlist(*)"); - conn.send( - "(buffers) hdata buffer:gui_buffers(*) local_variables,notify,number,full_name,short_name,title,hidden,type" - ); - // conn.send("(nicklist) nicklist"); - conn.send("sync"); - }, - error => { - console.log(error); - } - ); - } - fetchLines = (bufferId, numLines = 50) => { - connection && - connection.send( - `(lines) hdata buffer:0x${bufferId}/own_lines/last_line(-${numLines})/data` - ); - }; - render() { - return ( - <Provider store={store}> - <ConnectionGate> - <StatusBar barStyle="light-content" /> - <App fetchLinesForBuffer={this.fetchLines} /> - </ConnectionGate> - </Provider> - ); - } -} - -AppRegistry.registerComponent("WeechatNative", () => WeechatNative); +AppRegistry.registerComponent("WeechatNative", () => Root); diff --git a/src/usecase/Root.tsx b/src/usecase/Root.tsx @@ -0,0 +1,59 @@ +import * as React from "react"; +import { StatusBar } from "react-native"; +import { Provider } from "react-redux"; + +import WeechatConnection from "../lib/weechat/connection"; +import { HOSTNAME, PASSWORD } from "../../config"; + +import store from "../store"; + +import App from "./App"; +import ConnectionGate from "./ConnectionGate"; + +const connection = new WeechatConnection(store.dispatch, HOSTNAME, PASSWORD); + +export default class WeechatNative extends React.Component { + componentWillMount() { + const compressed = false; + + connection.connect().then( + conn => { + conn.send( + `init password=${PASSWORD},compression=${compressed ? "zlib" : "off"}` + ); + conn.send("(version) info version"); + // conn.send("(hotlist) hdata hotlist:gui_hotlist(*)"); + conn.send( + "(buffers) hdata buffer:gui_buffers(*) local_variables,notify,number,full_name,short_name,title,hidden,type" + ); + // conn.send("(nicklist) nicklist"); + conn.send("sync"); + }, + error => { + console.log(error); + } + ); + } + fetchLines = (bufferId: string, numLines: number = 50) => { + connection && + connection.send( + `(lines) hdata buffer:0x${bufferId}/own_lines/last_line(-${numLines})/data` + ); + }; + sendMessageToBuffer = (fullBufferName: string, message: string) => { + connection && connection.send(`(input) input ${fullBufferName} ${message}`); + }; + render() { + return ( + <Provider store={store}> + <ConnectionGate> + <StatusBar barStyle="light-content" /> + <App + sendMessageToBuffer={this.sendMessageToBuffer} + fetchLinesForBuffer={this.fetchLines} + /> + </ConnectionGate> + </Provider> + ); + } +}