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 05a35bd190288fc546486f9c1956b75799ce4690
parent eb6c13549d7902d7d5f73980f10b464291ff5471
Author: Matthew Horan <matt@matthoran.com>
Date:   Sun, 20 Jan 2019 17:23:05 -0500

Make LoginForm responsible for persisting state

Previously, the WeechatConnection would persist connection settings on
connect. Instead, persist connections in LoginForm when connecting.

Diffstat:
Msrc/lib/weechat/connection.ts | 6------
Msrc/store/connection-info.ts | 2+-
Msrc/usecase/login/LoginForm.tsx | 13+++++++++++--
3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/src/lib/weechat/connection.ts b/src/lib/weechat/connection.ts @@ -49,12 +49,6 @@ export default class WeechatConnection { } onopen() { - this.dispatch({ - type: "SET_CONNECTION_INFO", - hostname: this.hostname, - password: this.password, - ssl: this.ssl - }); this.send( `init password=${this.password},compression=${ this.compressed ? "zlib" : "off" diff --git a/src/store/connection-info.ts b/src/store/connection-info.ts @@ -7,7 +7,7 @@ export type ConnectionInfo = { const initialState: ConnectionInfo = { hostname: null, password: null, - ssl: false + ssl: true }; export default (state: ConnectionInfo = initialState, action) => { diff --git a/src/usecase/login/LoginForm.tsx b/src/usecase/login/LoginForm.tsx @@ -19,6 +19,7 @@ interface Props { hostname: string; password: string; ssl: boolean; + dispatch: (any) => void; } interface State { hostname: string; @@ -38,7 +39,8 @@ class LoginForm extends React.Component<Props, State> { return { ...prevState, hostname: nextProps.hostname, - password: nextProps.password + password: nextProps.password, + ssl: nextProps.ssl }; } else { return null; @@ -46,6 +48,12 @@ class LoginForm extends React.Component<Props, State> { } onPress = () => { + this.props.dispatch({ + type: "SET_CONNECTION_INFO", + hostname: this.state.hostname, + password: this.state.password, + ssl: this.state.ssl + }); const { hostname, password, ssl } = this.state; this.props.onConnect(hostname, password, ssl); }; @@ -122,7 +130,8 @@ class LoginForm extends React.Component<Props, State> { export default connect((state: StoreState) => ({ hostname: state.connection.hostname, - password: state.connection.password + password: state.connection.password, + ssl: state.connection.ssl }))(LoginForm); const styles = StyleSheet.create({