From be68203056db5e49f8add5a14fe0227f4d55d65a Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Fri, 18 Feb 2022 13:18:29 +0200 Subject: [PATCH] Always wait for offline sync to finish before sending connected state --- user.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/user.go b/user.go index 819721a..443c7ed 100644 --- a/user.go +++ b/user.go @@ -545,7 +545,6 @@ func (user *User) HandleEvent(event interface{}) { user.bridge.Metrics.TrackConnectionState(user.JID, false) user.bridge.Metrics.TrackLoginState(user.JID, false) case *events.Connected: - go user.sendBridgeState(BridgeState{StateEvent: StateConnected}) user.bridge.Metrics.TrackConnectionState(user.JID, true) user.bridge.Metrics.TrackLoginState(user.JID, true) if len(user.Client.Store.PushName) > 0 { @@ -567,8 +566,10 @@ func (user *User) HandleEvent(event interface{}) { if !user.PhoneRecentlySeen(true) { user.log.Infofln("Offline sync completed, but phone last seen date is still %s - sending phone offline bridge status", user.PhoneLastSeen) go user.sendBridgeState(BridgeState{StateEvent: StateTransientDisconnect, Error: WAPhoneOffline}) - } else if user.GetPrevBridgeState().StateEvent == StateBackfilling { - user.log.Infoln("Offline sync completed") + } else { + if user.GetPrevBridgeState().StateEvent == StateBackfilling { + user.log.Infoln("Offline sync completed") + } go user.sendBridgeState(BridgeState{StateEvent: StateConnected}) } case *events.AppStateSyncComplete: