commit a522a41e410bb9790df93640fd8bf205a5eabba0
parent 547667a59b1251c3e7c544654ec265d7ffccf6de
Author: Johan Lindskogen <johan.lindskogen@gmail.com>
Date: Wed, 4 Apr 2018 22:49:38 +0200
On websocket close -> go to login screen
Diffstat:
2 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/src/lib/weechat/connection.ts b/src/lib/weechat/connection.ts
@@ -34,6 +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();
}
onopen(callback) {
@@ -52,6 +53,12 @@ export default class WeechatConnection {
callback(this);
}
+ onclose() {
+ this.dispatch({
+ type: "DISCONNECT"
+ });
+ }
+
onmessage(event) {
const parsed = protocol.parse(event.data) as WeechatResponse<any>;
diff --git a/src/store/index.ts b/src/store/index.ts
@@ -28,6 +28,11 @@ const initialState: AppState = {
const app = (state: AppState = initialState, action) => {
switch (action.type) {
+ case "DISCONNECT":
+ return {
+ ...state,
+ connected: false
+ };
case "FETCH_VERSION":
return {
...state,