From f90ccc0b8ae952501e99eb4d0dff9f327b688e6d Mon Sep 17 00:00:00 2001 From: Matthew Horan Date: Wed, 24 Apr 2024 17:55:31 -0400 Subject: [PATCH] Don't connect before store state is restored --- src/usecase/Root.tsx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/usecase/Root.tsx b/src/usecase/Root.tsx index 3aff400..954057e 100644 --- a/src/usecase/Root.tsx +++ b/src/usecase/Root.tsx @@ -116,11 +116,6 @@ export default class WeechatNative extends React.Component { ); } - componentDidMount(): void { - const { hostname, password, ssl } = store.getState().connection; - if (hostname && password) this.onConnect(hostname, password, ssl); - } - componentWillUnmount(): void { this.connection?.disconnect(); this.appStateListener.remove(); @@ -130,6 +125,11 @@ export default class WeechatNative extends React.Component { this.unsubscribeFetchBuffersDispatchListener(); } + onBeforeLift = (): void => { + const { hostname, password, ssl } = store.getState().connection; + if (hostname && password) this.onConnect(hostname, password, ssl); + }; + setNotificationToken = async (): Promise => { const token = await getPushNotificationStatusAsync(); if (token) this.sendMessageToBuffer('core.weechat', '/weechatrn ' + token); @@ -218,7 +218,11 @@ export default class WeechatNative extends React.Component { return ( - +