You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(messages): stop empty channel list after notification back navigation (#1994)
Tapping a message notification deep-links into the correct conversation,
but tapping back left the channel list empty until you backed out again and
re-entered Channels.
Root cause: the Messages sidebar `List` bound its selection directly to
`router.messagesState`, which a deep link sets to a payload-carrying value
(e.g. `.channels(channelId: 2, messageId: 5)`). The sidebar only offers
payload-free `.channels()` / `.directMessages()` rows, so that value matched
no row and corrupted the collapsed NavigationSplitView back stack.
Decouple the two concerns the single property was serving:
- `messagesState` is now a transient deep-link command (carries the payload),
consumed exactly once by the Messages view and then cleared.
- new `messagesSection` is the durable, payload-free sidebar/section selection;
it always matches a row, keeping the back stack intact, and survives tab
switches. Router derives it from each deep link via `sidebarSection`.
Consuming the payload clears `messagesState`, which re-fires onChange with nil;
a guard makes that a no-op, so there is no re-entrancy and a later tab
re-appear can't re-resolve the deep link and snap the user back into the
notified conversation.
Also fixes a sibling-selection bug: a DM notification arriving while a channel
was open showed the channel thread (the detail pane prioritizes
channelSelection); each branch now clears its sibling. Channel deep links that
arrive before SwiftData loads the channels keep their payload to retry on the
next appear instead of silently dropping.
Adds Router-level coverage for messagesSection derivation, reset, and
restoration, plus sidebarSection unit tests.
0 commit comments