From 098637af54212d4f9d662db092876ef257c562f1 Mon Sep 17 00:00:00 2001 From: zjs81 <30362347+zjs81@users.noreply.github.com> Date: Mon, 23 Nov 2026 18:47:23 -0700 Subject: [PATCH] Wait for bookmark list attach on search jump and update user guides --- documentation/channels.md | 4 +- documentation/chat-and-messaging.md | 4 +- documentation/contacts.md | 1 + lib/screens/bookmarks_screen.dart | 15 +++- test/screens/bookmarks_screen_test.dart | 91 ++++++++++++++----------- 5 files changed, 70 insertions(+), 45 deletions(-) diff --git a/documentation/channels.md b/documentation/channels.md index 6f324f7d..3b3eef57 100644 --- a/documentation/channels.md +++ b/documentation/channels.md @@ -79,7 +79,7 @@ Tap a channel card to open the channel chat screen. - Tap the title or landscape icon to select a region; see [Regions](regions.md) - Overflow menu (⋮) → **Notifications**: choose all messages, mentions only or muted for this channel. The row shows the current mode - Overflow menu (⋮) → **Edit channel** and **Delete channel**: the same sheet and confirmation as a long-press in the channel list -- Overflow menu (⋮) → **Show bookmarks** toggles the channel's bookmarked-message filter; the bookmark icon is filled while active and outlined while inactive. +- Overflow menu (⋮) → **Bookmarks**: opens the **Bookmarks** screen scoped to this channel, with a split pill at the top to switch between **All** and `#channel` (plus in-screen search, copy, and single or bulk removal with confirmation). - Overflow menu (⋮) → **Chat background**: a color or picture, with a fade slider, behind this channel only. See [Chat backgrounds](themes.md#chat-backgrounds). Holiday greetings in new messages play a short animation, as in [direct chat](chat-and-messaging.md#message-list) ### Compression Strip @@ -92,7 +92,7 @@ Below the app bar, above the messages, the same strip as in [direct chats](chat- - **Incoming messages**: Colored avatar with sender's initial (or first emoji if name starts with one; color is deterministic from sender name hash), sender name in primary color, message bubble - **Outgoing messages**: Primary container color bubble with a small status icon: pending (clock), sent (checkmark), or failed (red error circle) - Automatic older-message loading on scroll-to-top -- Long-press a message and choose **Bookmark** to mark it with a yellow icon. Bookmarks are stored separately from channel history and remain available after a channel is deleted. +- Long-press a message and choose **Bookmark** (or choose **Select messages** and tap the bookmark button in the selection bar to bookmark several messages at once) to mark it with a yellow icon; removing a bookmark prompts for confirmation. Bookmarks are stored separately from channel history and remain available after a channel is deleted. - Jump-to-bottom button when scrolled up - **Pinch-to-zoom**: Two-finger zoom (0.8x–1.8x) and double-tap to reset text size - **Message tracing mode** (when enabled in App Settings): Each bubble additionally shows path prefix bytes (`via XX,YY,...`), a timestamp, and a repeat count icon diff --git a/documentation/chat-and-messaging.md b/documentation/chat-and-messaging.md index 40826682..4bca0684 100644 --- a/documentation/chat-and-messaging.md +++ b/documentation/chat-and-messaging.md @@ -20,7 +20,7 @@ From the Contacts screen, tap any Chat-type contact to open the ChatScreen. - **Subtitle**: Current routing path label (e.g., "2 hops", "flood (auto)", "direct (forced)") and unread count. Tapping the subtitle shows the full path details. - **Action buttons**: - **Search** (magnifier icon): Replaces the title with a search field and lists every message in this conversation's full history whose text (or translation) contains the typed word, newest first, with matches highlighted. Channel search also matches sender names and skips messages caught by the [message filter](message-filter.md). Back, Esc or the arrow closes search. Channel chats have the same button. - - **Overflow menu** (⋮ icon): Contains Routing, Info, Telemetry, Settings (link images and telemetry permissions), Chat background, Clear Chat, and Remove from contacts (rooms also have Room Server Management). Routing opens the routing sheet where you can switch between Auto, Direct, and Flood routing and manage recent paths (hop count, round-trip time, age, success count, color-coded by repeater). Info shows a dialog with contact type, path, GPS coordinates, and public key. Chat background sets a color or picture (with a fade slider) behind this chat only; see [Chat backgrounds](themes.md#chat-backgrounds). + - **Overflow menu** (⋮ icon): Contains Routing, Info, Bookmarks, Telemetry, Settings (link images and telemetry permissions), Chat background, Clear Chat, and Remove from contacts (rooms also have Room Server Management). Routing opens the routing sheet where you can switch between Auto, Direct, and Flood routing and manage recent paths (hop count, round-trip time, age, success count, color-coded by repeater). Info shows a dialog with contact type, path, GPS coordinates, and public key. Chat background sets a color or picture (with a fade slider) behind this chat only; see [Chat backgrounds](themes.md#chat-backgrounds). ### Compression Strip @@ -33,7 +33,7 @@ Below the app bar, above the messages, a strip shows **Compression: Off**, **SMA - **Holiday animations**: A new message with a holiday greeting ("Happy Halloween", "Merry Christmas", and so on, in any app language) plays a short animation. Turn off in App Settings → Appearance; see [Holiday message animations](themes.md#holiday-message-animations) - **Outgoing messages**: Right-aligned, primary color background. **Failed messages** change to a red-toned error container background - **Incoming messages**: Left-aligned, grey background with a colored avatar (initial letter or first emoji of sender name; color is deterministic from a hash of the sender name) -- Long-press a message and choose **Bookmark** to show a yellow bookmark on the bubble. **Show bookmarks** in the chat menu toggles a filter for bookmarked messages; use **Bookmarks** in the Channels screen menu to browse saved messages, including those from deleted contacts or channels. From the bookmarks list, copy a message with its copy button. It is ordered oldest-to-newest and opens at the newest message. The Export screen can save or share a dated Markdown file, grouped by contact and then channel, with linked URLs and URL-image embeds. Links remain tappable, and supported URL-image previews are shown when **Load images from links** is enabled in App Settings. +- Long-press a message and choose **Bookmark** to show a yellow bookmark on the bubble (choosing **Remove bookmark** prompts for confirmation before removing it). **Bookmarks** in the chat menu opens the **Bookmarks** screen scoped to this conversation, with a split pill at the top to switch between **All** and the current contact; use **Bookmarks** in the Contacts or Channels screen menu to browse all saved messages across conversations, including those from deleted contacts or channels. The **Bookmarks** screen includes search (matching message text, translations, sender names, and conversation names, and scrolling to the highlighted card when a result is tapped), a copy button and remove button on each card, long-press multi-selection for bulk removal, and a confirmation dialog before removing single or selected bookmarks. It is ordered oldest-to-newest and opens at the newest message. The Export screen can save or share a dated Markdown file, grouped by contact and then channel, with linked URLs and URL-image embeds. Links remain tappable, and supported URL-image previews are shown when **Load images from links** is enabled in App Settings. - Bubble width capped at 72% of screen width - Hyperlinks rendered as tappable underlined text; inline decimal GPS coordinates are rendered as bold underlined links (see [Inline GPS Coordinates](#inline-gps-coordinates)) - Message text follows the system font size (Android/iOS accessibility text size); pinch-to-zoom scales on top of it diff --git a/documentation/contacts.md b/documentation/contacts.md index 5a310a7d..c203f173 100644 --- a/documentation/contacts.md +++ b/documentation/contacts.md @@ -93,6 +93,7 @@ The Contacts screen has a single **three-dot overflow menu** (`⋮`) in the app - Add Contact — opens the Add Contact page - Discovered Contacts — opens the DiscoveryScreen +- Bookmarks — opens the Bookmarks screen showing all saved messages - *(divider)* - Zero-Hop Advert — broadcasts your advertisement to immediately adjacent nodes - Flood Advert — broadcasts across the full mesh network diff --git a/lib/screens/bookmarks_screen.dart b/lib/screens/bookmarks_screen.dart index 5d6603b4..a4f282e6 100644 --- a/lib/screens/bookmarks_screen.dart +++ b/lib/screens/bookmarks_screen.dart @@ -41,6 +41,7 @@ class BookmarksScreen extends StatefulWidget { class _BookmarksScreenState extends State { late Future> _bookmarks; List _loadedBookmarks = const []; + bool _hasLoadedBookmarks = false; late bool _filterToInitialSource; final ScrollController _scrollController = ScrollController(); @@ -77,6 +78,7 @@ class _BookmarksScreenState extends State { .loadBookmarkedMessages(); if (mounted) { _loadedBookmarks = loaded; + _hasLoadedBookmarks = true; } return loaded; } @@ -161,6 +163,7 @@ class _BookmarksScreenState extends State { final all = await connector.loadBookmarkedMessages(); if (mounted) { _loadedBookmarks = all; + _hasLoadedBookmarks = true; } final visible = _filteredBookmarks(all, connector); return [ @@ -179,7 +182,12 @@ class _BookmarksScreenState extends State { Future _jumpToSearchResult(String storageId) async { FocusScope.of(context).unfocus(); _closeSearch(); + await _bookmarks; + if (!mounted) return; await WidgetsBinding.instance.endOfFrame; + for (var i = 0; i < 5 && mounted && !_scrollController.hasClients; i++) { + await WidgetsBinding.instance.endOfFrame; + } if (!mounted) return; final connector = context.read(); final visible = _filteredBookmarks(_loadedBookmarks, connector); @@ -406,8 +414,12 @@ class _BookmarksScreenState extends State { ) : FutureBuilder>( future: _bookmarks, + initialData: _hasLoadedBookmarks + ? _loadedBookmarks + : null, builder: (context, snapshot) { - if (snapshot.connectionState != ConnectionState.done) { + if (!snapshot.hasData && + snapshot.connectionState != ConnectionState.done) { return const Center( child: CircularProgressIndicator(), ); @@ -416,6 +428,7 @@ class _BookmarksScreenState extends State { final allBookmarks = snapshot.data ?? const []; _loadedBookmarks = allBookmarks; + _hasLoadedBookmarks = true; final bookmarks = _filteredBookmarks( allBookmarks, connector, diff --git a/test/screens/bookmarks_screen_test.dart b/test/screens/bookmarks_screen_test.dart index b8d75ac5..b5483907 100644 --- a/test/screens/bookmarks_screen_test.dart +++ b/test/screens/bookmarks_screen_test.dart @@ -341,44 +341,44 @@ void main() { ); testWidgets( - 'Search in BookmarksScreen finds matching bookmarks and jumping highlights target card', + 'Search in BookmarksScreen finds matching bookmarks and jumping scrolls to and highlights offscreen target card', (tester) async { final env = await _createEnv(tester); - final b1 = BookmarkedMessage( - sourceType: BookmarkSourceType.channel, - sourceId: 'slot:0', - sourceName: 'Public', - messageId: 'm1', - senderName: 'Sam', - text: 'Alpha repeater check on ridge', - timestamp: DateTime(2026, 1, 1, 9), - receivedAt: DateTime(2026, 1, 1, 9), - isOutgoing: false, - ); - final b2 = BookmarkedMessage( - sourceType: BookmarkSourceType.contact, - sourceId: 'contact-1', - sourceName: 'Maya', - messageId: 'm2', - senderName: 'Maya', - text: 'Bravo solar battery voltage update', - timestamp: DateTime(2026, 1, 1, 10), - receivedAt: DateTime(2026, 1, 1, 10), - isOutgoing: false, - ); - - await _pumpFuture( - tester, - env.connector.setBookmarkedMessage(b1, isBookmarked: true), - ); - await _pumpFuture( - tester, - env.connector.setBookmarkedMessage(b2, isBookmarked: true), - ); + for (var i = 1; i <= 25; i++) { + final bookmark = BookmarkedMessage( + sourceType: i.isEven + ? BookmarkSourceType.contact + : BookmarkSourceType.channel, + sourceId: i.isEven ? 'contact-1' : 'slot:0', + sourceName: i.isEven ? 'Maya' : 'Public', + messageId: 'm$i', + senderName: i.isEven ? 'Maya' : 'Sam', + text: i == 1 + ? 'Oldest offscreen solar telemetry beacon check #1' + : 'Recent repeater status update #$i', + timestamp: DateTime(2026, 1, 1, 9).add(Duration(minutes: i)), + receivedAt: DateTime(2026, 1, 1, 9).add(Duration(minutes: i)), + isOutgoing: false, + ); + await _pumpFuture( + tester, + env.connector.setBookmarkedMessage(bookmark, isBookmarked: true), + ); + } await tester.pumpWidget(env.wrap(const BookmarksScreen())); await _pumpFrames(tester); + // Reversed ListView opens at the newest bookmarks (offset 0), so the oldest (#1) is offscreen. + final scrollableState = tester.state( + find.byType(Scrollable), + ); + expect(scrollableState.position.pixels, 0); + expect( + find.text('Oldest offscreen solar telemetry beacon check #1'), + findsNothing, + ); + await tester.tap(find.byIcon(Icons.search)); await _pumpFrames(tester); @@ -387,19 +387,30 @@ void main() { await _pumpFrames(tester); expect( - find.textContaining('Bravo solar battery voltage update'), + find.textContaining('Oldest offscreen solar telemetry beacon check #1'), findsOneWidget, ); - expect(find.textContaining('Alpha repeater check'), findsNothing); - - // Tap the search result to close search and highlight the card. - await tester.tap( - find.textContaining('Bravo solar battery voltage update'), + expect( + find.textContaining('Recent repeater status update #25'), + findsNothing, ); - await _pumpFrames(tester); - // Search field closed and AnimatedContainer highlight is active. + // Tap the search result to close search, scroll the restored list to the offscreen bookmark, and highlight it. + await tester.tap( + find.textContaining('Oldest offscreen solar telemetry beacon check #1'), + ); + await _pumpFrames(tester, 12); + + // Search field closed, list scrolled to the offscreen card, and AnimatedContainer highlight is active. expect(find.byType(TextField), findsNothing); + final restoredScrollable = tester.state( + find.byType(Scrollable), + ); + expect(restoredScrollable.position.pixels, greaterThan(0)); + expect( + find.text('Oldest offscreen solar telemetry beacon check #1'), + findsOneWidget, + ); expect(find.byType(AnimatedContainer), findsOneWidget); // Highlight clears after 2 seconds.