Improve open action handling for notifications
Push notifications were not opened reliably. To improve robustness, the following changes were introduced: 1. The notification opening logic was updated to become more similar to URL handling, in a way that uses better defined interfaces and functions that provide better result guarantees, by separating complex handling logic, and the side-effects/mutations that are made after computing the open action — instead of relying on a complex logic function that produces side-effects as a result, which obfuscates the actual behavior of the function. 2. The LoadableThreadView was expanded and renamed to LoadableNostrEventView, to reflect that it can also handle non-thread nostr events, such as DMs, which is a necessity for handling push notifications. 3. A new type of Notify object, the `QueueableNotify` was introduced, to address issues where the listener/handler is not instantiated at the time the app notifies that there is a push notification to be opened. This was implemented using async streams, which simplifies the usage of this down to a simple "for-in" loop. Closes: https://github.com/damus-io/damus/issues/2825 Changelog-Fixed: Fixed issue where some push notifications would not open in the app and leave users confused Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
This commit is contained in:
@@ -32,7 +32,7 @@ enum Route: Hashable {
|
||||
case DeveloperSettings(settings: UserSettingsStore)
|
||||
case FirstAidSettings(settings: UserSettingsStore)
|
||||
case Thread(thread: ThreadModel)
|
||||
case ThreadFromReference(note_reference: LoadableThreadModel.NoteReference)
|
||||
case LoadableNostrEvent(note_reference: LoadableNostrEventViewModel.NoteReference)
|
||||
case Reposts(reposts: EventsModel)
|
||||
case QuoteReposts(quotes: EventsModel)
|
||||
case Reactions(reactions: EventsModel)
|
||||
@@ -97,8 +97,8 @@ enum Route: Hashable {
|
||||
case .Thread(let thread):
|
||||
ChatroomThreadView(damus: damusState, thread: thread)
|
||||
//ThreadView(state: damusState, thread: thread)
|
||||
case .ThreadFromReference(let note_reference):
|
||||
LoadableThreadView(state: damusState, note_reference: note_reference)
|
||||
case .LoadableNostrEvent(let note_reference):
|
||||
LoadableNostrEventView(state: damusState, note_reference: note_reference)
|
||||
case .Reposts(let reposts):
|
||||
RepostsView(damus_state: damusState, model: reposts)
|
||||
case .QuoteReposts(let quote_reposts):
|
||||
@@ -190,8 +190,8 @@ enum Route: Hashable {
|
||||
case .Thread(let threadModel):
|
||||
hasher.combine("thread")
|
||||
hasher.combine(threadModel.original_event.id)
|
||||
case .ThreadFromReference(note_reference: let note_reference):
|
||||
hasher.combine("thread_from_reference")
|
||||
case .LoadableNostrEvent(note_reference: let note_reference):
|
||||
hasher.combine("loadable_nostr_event")
|
||||
hasher.combine(note_reference)
|
||||
case .Reposts(let reposts):
|
||||
hasher.combine("reposts")
|
||||
|
||||
Reference in New Issue
Block a user