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 3934b738aa239679836633cee4ecc222b5836fcd
parent 9207f469c411ef1a84c696a905470b5cab0942d6
Author: Johan Lindskogen <johan.lindskogen@gmail.com>
Date:   Wed,  4 Apr 2018 23:46:01 +0200

Close connection button

Diffstat:
Msrc/lib/weechat/connection.ts | 5+++--
Msrc/usecase/App.tsx | 14+++++++++++---
Msrc/usecase/Root.tsx | 5+++++
Asrc/usecase/icons/eject.png | 0
Asrc/usecase/icons/eject@2x.png | 0
5 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/src/lib/weechat/connection.ts b/src/lib/weechat/connection.ts @@ -34,7 +34,7 @@ export default class WeechatConnection { this.websocket.onopen = () => this.onopen(onSuccess); this.websocket.onmessage = event => this.onmessage(event); this.websocket.onerror = onError; - this.websocket.onclose = () => this.onclose(); + this.websocket.onclose = () => this.close(); } onopen(callback) { @@ -53,7 +53,8 @@ export default class WeechatConnection { callback(this); } - onclose() { + close() { + this.websocket.close(); this.dispatch({ type: "DISCONNECT" }); diff --git a/src/usecase/App.tsx b/src/usecase/App.tsx @@ -3,6 +3,7 @@ import { SafeAreaView, View, Text, + Image, TouchableOpacity, StyleSheet, Keyboard @@ -23,6 +24,7 @@ interface Props { buffers: { [key: string]: WeechatBuffer }; currentBufferId: string | null; currentBuffer: WeechatBuffer | null; + disconnect: () => void; fetchLinesForBuffer: (bufferId: string) => void; sendMessageToBuffer: (fullBufferName: string, message: string) => void; clearHotlistForBuffer: (fullBufferName: string) => void; @@ -116,7 +118,14 @@ class App extends React.Component<Props, State> { {currentBuffer && currentBuffer.short_name} </Text> </TouchableOpacity> - <View style={styles.channels} /> + <View style={styles.channels}> + <TouchableOpacity + style={styles.channelsButton} + onPress={this.props.disconnect} + > + <Image source={require("./icons/eject.png")} /> + </TouchableOpacity> + </View> </View> <BufferContainer showTopic={showTopic} @@ -147,12 +156,11 @@ const styles = StyleSheet.create({ topbar: { flexDirection: "row", backgroundColor: "#333", - justifyContent: "center", + justifyContent: "space-between", alignItems: "center", paddingBottom: 10 }, channels: { - flex: 1, paddingHorizontal: 5 }, channelsButton: { diff --git a/src/usecase/Root.tsx b/src/usecase/Root.tsx @@ -40,6 +40,10 @@ export default class WeechatNative extends React.Component<{}, State> { console.log(error); }; + disconnect = () => { + this.connection.close(); + }; + onConnect = (hostname: string, password: string, ssl: boolean) => { this.setState({ connecting: true }); this.connection.connect( @@ -77,6 +81,7 @@ export default class WeechatNative extends React.Component<{}, State> { <ConnectionGate connecting={connecting} onConnect={this.onConnect}> <StatusBar barStyle="light-content" /> <App + disconnect={this.disconnect} clearHotlistForBuffer={this.clearHotlistForBuffer} sendMessageToBuffer={this.sendMessageToBuffer} fetchLinesForBuffer={this.fetchLines} diff --git a/src/usecase/icons/eject.png b/src/usecase/icons/eject.png Binary files differ. diff --git a/src/usecase/icons/eject@2x.png b/src/usecase/icons/eject@2x.png Binary files differ.