Browse Source

Update hacky workaround for transient disconnect states

The previous version didn't handle the case where the reconnect is what
triggers the `wa-phone-offline` state in the first place.
Tulir Asokan 3 năm trước cách đây
mục cha
commit
dcfa9e1b34
1 tập tin đã thay đổi với 1 bổ sung1 xóa
  1. 1 1
      user.go

+ 1 - 1
user.go

@@ -628,7 +628,7 @@ func (user *User) HandleEvent(event interface{}) {
 	case *events.Disconnected:
 		// Don't send the normal transient disconnect state if we're already in a different transient disconnect state.
 		// TODO remove this if/when the phone offline state is moved to a sub-state of CONNECTED
-		if user.GetPrevBridgeState().Error != WAPhoneOffline {
+		if user.GetPrevBridgeState().Error != WAPhoneOffline && user.PhoneRecentlySeen(false) {
 			go user.sendBridgeState(BridgeState{StateEvent: StateTransientDisconnect, Message: "Disconnected from WhatsApp. Trying to reconnect."})
 		}
 		user.bridge.Metrics.TrackConnectionState(user.JID, false)