Repository navigation
Cache recently opened mobile thread replies #9844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+2,118
−320
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
4c0c867
Cache recently opened mobile thread replies
wesbillman 71c5e2b
Land on saved thread replies after an offline query failure
wesbillman 49a071c
Announce confirmed thread access loss to screen readers
wesbillman 2297d93
Fence thread cache writes and refresh pruned previews
wesbillman 940fd8f
Drain the cache queue before checking preview retirement
wesbillman 9756f89
Merge remote-tracking branch 'origin/main' into mobile-saved-thread-p…
wesbillman 91e476d
Fix offline thread entry and stale saved edits
wesbillman 8bc759e
Merge remote-tracking branch 'origin/main' into mobile-saved-thread-p…
wesbillman 1168adb
Bound writer verification for saved thread pages
wesbillman 1ea2170
Keep saved thread previews stable and scope edit checks
wesbillman 2e0ebb2
Use saved thread evidence to detect stale replica reads
wesbillman e6138e6
Merge remote-tracking branch 'origin/main' into mobile-saved-thread-p…
wesbillman 79d7b44
Brace the saved-thread test polling condition
wesbillman fe5b19b
Retain saved thread pages when mutation verification fails
wesbillman 24e4f63
Keep saved thread links and retry controls usable
wesbillman 30bf267
Record exact pruned thread IDs for cache verification
wesbillman dca8250
Keep unrelated cache pages during a full-disk prune
wesbillman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
mobile/lib/features/channels/channel_detail_page/initial_thread_route.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| part of '../channel_detail_page.dart'; | ||
|
|
||
| extension on _MessageList { | ||
| void _useInitialThreadRoute(BuildContext context, WidgetRef ref) { | ||
| final opened = useRef(false); | ||
| final rootId = initialThreadRootId; | ||
| final channelHead = rootId == null | ||
| ? null | ||
| : allMessages.where((message) => message.id == rootId).firstOrNull; | ||
| final preview = rootId == null || channelHead != null || opened.value | ||
| ? null | ||
| : ref.watch( | ||
| savedThreadPreviewProvider((channelId: channelId, rootId: rootId)), | ||
| ); | ||
| final saved = preview?.isLoading == false ? preview?.value : null; | ||
| final live = saved == null | ||
| ? null | ||
| : ref.watch(channelMessagesProvider(channelId)).value; | ||
| final head = useMemoized(() { | ||
| if (channelHead != null || saved == null) return channelHead; | ||
| return formatTimeline( | ||
| mergeThreadEvents(saved, live ?? const []), | ||
| currentPubkey: currentPubkey, | ||
| ).where((message) => message.id == rootId).firstOrNull; | ||
| }, [channelHead, saved, live, currentPubkey, rootId]); | ||
| useEffect(() { | ||
| if (opened.value || head == null) return null; | ||
| var cancelled = false; | ||
| WidgetsBinding.instance.addPostFrameCallback((_) { | ||
| if (cancelled || | ||
| !context.mounted || | ||
| ModalRoute.of(context)?.isCurrent != true) { | ||
| return; | ||
| } | ||
| final error = ref.read(channelMessagesProvider(channelId)).error; | ||
| if (error != null && isRelayChannelAccessDenied(error)) return; | ||
| if (channelHead == null && rootId != null) { | ||
| final current = ref.read( | ||
| savedThreadPreviewProvider((channelId: channelId, rootId: rootId)), | ||
| ); | ||
| if (current.isLoading || !identical(current.value, saved)) return; | ||
| } | ||
| opened.value = true; | ||
| final route = MaterialPageRoute<void>( | ||
| builder: (_) => ThreadDetailPage( | ||
| threadHead: head, | ||
| headFromSavedPage: channelHead == null, | ||
| allMessages: allMessages, | ||
| channelId: channelId, | ||
| currentPubkey: currentPubkey, | ||
| isMember: isMember, | ||
| isArchived: isArchived, | ||
| initialMessageId: initialMessageId, | ||
| ), | ||
| ); | ||
| final navigator = Navigator.of(context); | ||
| switch (initialThreadRouteBehavior) { | ||
| case InitialThreadRouteBehavior.push: | ||
| navigator.push(route); | ||
| case InitialThreadRouteBehavior.replaceCurrentRoute: | ||
| navigator.pushReplacement(route); | ||
| } | ||
| }); | ||
| return () => cancelled = true; | ||
| }, [head, channelHead, allMessages, initialThreadRouteBehavior]); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤖 Recommended blocker: a deferred deep link can open its thread long after entry. The old effect consumed the intent before its post-frame check. Here
openedis set only afterisCurrentpasses, and the effect re-runs on everyallMessageschange.Failure: a notification opens the channel. The head takes a moment to resolve (history load, or the 250 ms delay plus the disk read for a saved head), and meanwhile the user opens channel details, so this callback bails. They come back and read the channel. The next incoming message rebuilds
allMessages, and the thread pushes over them. WithreplaceCurrentRoute, it replaces the channel page.Fix: either consume the intent when the head resolves while the route is covered, as before, or keep it pending only until the route next becomes current. Don't re-arm it on later
allMessageschanges.