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.
This commit is contained in:
Tulir Asokan 2022-03-08 12:51:24 +02:00
parent 9b6ca8d6f1
commit dcfa9e1b34

View file

@ -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)