Skip to content

Commit

Permalink
Fix push notification & mentions
Browse files Browse the repository at this point in the history
The code had an issue where it would not register a chat if just joined
as re-register push notifications was called before the chat had been
added.
This commit fixes the behavior by making sure that the chat just joined
is included.
  • Loading branch information
cammellos committed Sep 17, 2020
1 parent 9e148ea commit a759d9d
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions protocol/messenger.go
Original file line number Diff line number Diff line change
Expand Up @@ -1377,20 +1377,24 @@ func (m *Messenger) saveChat(chat *Chat) error {
}

// We check if it's a new chat, or chat.Active has changed
if chat.Public() && (!ok && chat.Active) || (ok && chat.Active != previousChat.Active) {
// Re-register for push notifications, as we want to receive mentions
if err := m.reregisterForPushNotifications(); err != nil {
return err
}

}
// we check here, but we only re-register once the chat has been
// saved an added
shouldRegisterForPushNotifications := chat.Public() && (!ok && chat.Active) || (ok && chat.Active != previousChat.Active)

err := m.persistence.SaveChat(*chat)
if err != nil {
return err
}
m.allChats[chat.ID] = chat

if shouldRegisterForPushNotifications {
// Re-register for push notifications, as we want to receive mentions
if err := m.reregisterForPushNotifications(); err != nil {
return err
}

}

return nil
}

Expand Down

0 comments on commit a759d9d

Please sign in to comment.