diff --git a/documentation/channels.md b/documentation/channels.md index be8537f5..682c8d82 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 @@ -92,7 +92,7 @@ The top-right menu has the same Compression item as [direct chats](chat-and-mess - **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 b49aec52..c9a53f1e 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 @@ -33,7 +33,7 @@ The top-right menu has a **Compression: Off**, **SMAZ** or **Cyr2Lat** item for - **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/documentation/design.md b/documentation/design.md index e3f5b7fb..b1e5ff4b 100644 --- a/documentation/design.md +++ b/documentation/design.md @@ -156,7 +156,7 @@ Icon sizes in use: 24 for tile and banner icons, 20 for menu icons and small act - `FilledButton.tonal`: a secondary action that still needs weight (rare). - `OutlinedButton(.icon)`: secondary actions next to a filled one. - `TextButton`: Cancel and low-emphasis actions in dialogs; inline actions in cards. -- Destructive confirm: `FilledButton` with `backgroundColor: scheme.error`, `foregroundColor: scheme.onError` (`showConfirmClearDialog` in `widgets/confirm_clear_dialog.dart`), or a `TextButton` with `foregroundColor: scheme.error` when it is not the primary action. Use `showConfirmClearDialog(confirmLabel:)` for any confirm dialog; `warning: true` makes the button `scheme.tertiary` for disruptive, non-destructive actions (Reboot in Settings). +- Destructive confirm: destructive or data-removing actions (such as clearing a chat, deleting a channel or contact, or removing single or bulk bookmarks) always prompt with a confirmation `AlertDialog` pairing a `Cancel` `TextButton` with an error-styled destructive action: `FilledButton` with `backgroundColor: scheme.error`, `foregroundColor: scheme.onError` (`showConfirmClearDialog` in `widgets/confirm_clear_dialog.dart`), or a `TextButton` with `foregroundColor: scheme.error` when it is not the primary action (as in `confirmClearChat` and `confirmRemoveBookmarks`). Use `showConfirmClearDialog(confirmLabel:)` for any confirm dialog; `warning: true` makes the button `scheme.tertiary` for disruptive, non-destructive actions (Reboot in Settings). - Dialog action order: Cancel first, primary last. - Avoid `ElevatedButton` in new code. @@ -237,7 +237,7 @@ What the code does: Rules for new UI: 1. **Settings → page.** A row in Settings, App Settings or a repeater screen that opens settings opens a page, even for a single field. See [Settings pages](#settings-pages). -2. **Confirmation or a single short input → dialog.** Title, one sentence, Cancel + one action. Inside settings, dialogs only confirm actions (Reboot, Delete all paths, unsaved changes). +2. **Confirmation or a single short input → dialog.** Title, one sentence, Cancel + one action. Destructive or data-removing actions (clearing a chat, deleting a channel/contact, or removing single/bulk bookmarks) always use this `AlertDialog` pattern (`Cancel` + `scheme.error` destructive action button). Inside settings, dialogs only confirm actions (Reboot, Delete all paths, unsaved changes). 3. **Pick one of several options, or act on one item → sheet.** Use `showMeshSheet` and start the content with `BottomSheetHeader(title:, subtitle:)`. It handles the keyboard and navigation-bar insets. Use raw `showModalBottomSheet` only when you need `DraggableScrollableSheet`. 4. **Forms with sections, live remote values, or anything that needs Save/Discard → page.** Guard unsaved changes with `UnsavedChangesGuard` (built into `SaveToRadioPage`). 5. Never stack a dialog on a sheet on a dialog. Close the sheet first, or move the flow to a page. diff --git a/lib/helpers/link_handler.dart b/lib/helpers/link_handler.dart index 473758cb..b4d1a366 100644 --- a/lib/helpers/link_handler.dart +++ b/lib/helpers/link_handler.dart @@ -61,6 +61,7 @@ class LinkHandler { TextStyle? coordinateStyle, Color? backgroundColor, VoidCallback? onSecondaryTap, + bool selectable = true, }) { return _InteractiveMessageText( text: text, @@ -69,6 +70,7 @@ class LinkHandler { coordinateStyle: coordinateStyle, backgroundColor: backgroundColor, onSecondaryTap: onSecondaryTap, + selectable: selectable, ); } @@ -272,6 +274,7 @@ class _InteractiveMessageText extends StatefulWidget { final TextStyle? coordinateStyle; final Color? backgroundColor; final VoidCallback? onSecondaryTap; + final bool selectable; const _InteractiveMessageText({ required this.text, @@ -280,6 +283,7 @@ class _InteractiveMessageText extends StatefulWidget { this.coordinateStyle, this.backgroundColor, this.onSecondaryTap, + this.selectable = true, }); @override @@ -393,7 +397,7 @@ class _InteractiveMessageTextState extends State<_InteractiveMessageText> { ], ); - if (PlatformInfo.isDesktop) { + if (widget.selectable && PlatformInfo.isDesktop) { final selectable = SelectableText.rich(span); if (widget.onSecondaryTap == null) return selectable; return Listener( diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index d913ff08..d83ada3f 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -1230,6 +1230,17 @@ "bookmarks_channel": "Channel", "bookmarks_contact": "Contact", "bookmarks_remove": "Remove bookmark", + "bookmarks_removeConfirmTitle": "Remove Bookmark", + "bookmarks_removeConfirmMessage": "Remove this message from your bookmarks?", + "bookmarks_removeSelectedConfirmTitle": "Remove Bookmarks", + "bookmarks_removeSelectedConfirmMessage": "Remove {count} messages from your bookmarks?", + "@bookmarks_removeSelectedConfirmMessage": { + "placeholders": { + "count": { + "type": "int" + } + } + }, "chat_selectMessages": "Select messages", "chat_selectedCount": "{count} selected", "@chat_selectedCount": { diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart index bac9d912..f423338c 100644 --- a/lib/l10n/app_localizations.dart +++ b/lib/l10n/app_localizations.dart @@ -4345,6 +4345,30 @@ abstract class AppLocalizations { /// **'Remove bookmark'** String get bookmarks_remove; + /// No description provided for @bookmarks_removeConfirmTitle. + /// + /// In en, this message translates to: + /// **'Remove Bookmark'** + String get bookmarks_removeConfirmTitle; + + /// No description provided for @bookmarks_removeConfirmMessage. + /// + /// In en, this message translates to: + /// **'Remove this message from your bookmarks?'** + String get bookmarks_removeConfirmMessage; + + /// No description provided for @bookmarks_removeSelectedConfirmTitle. + /// + /// In en, this message translates to: + /// **'Remove Bookmarks'** + String get bookmarks_removeSelectedConfirmTitle; + + /// No description provided for @bookmarks_removeSelectedConfirmMessage. + /// + /// In en, this message translates to: + /// **'Remove {count} messages from your bookmarks?'** + String bookmarks_removeSelectedConfirmMessage(int count); + /// No description provided for @chat_selectMessages. /// /// In en, this message translates to: diff --git a/lib/l10n/app_localizations_bg.dart b/lib/l10n/app_localizations_bg.dart index b156d74c..1caf63f5 100644 --- a/lib/l10n/app_localizations_bg.dart +++ b/lib/l10n/app_localizations_bg.dart @@ -2474,6 +2474,21 @@ class AppLocalizationsBg extends AppLocalizations { @override String get bookmarks_remove => 'Премахни от отметките'; + @override + String get bookmarks_removeConfirmTitle => 'Remove Bookmark'; + + @override + String get bookmarks_removeConfirmMessage => + 'Remove this message from your bookmarks?'; + + @override + String get bookmarks_removeSelectedConfirmTitle => 'Remove Bookmarks'; + + @override + String bookmarks_removeSelectedConfirmMessage(int count) { + return 'Remove $count messages from your bookmarks?'; + } + @override String get chat_selectMessages => 'Избор на съобщения'; diff --git a/lib/l10n/app_localizations_cs.dart b/lib/l10n/app_localizations_cs.dart index c7cb9709..3228c100 100644 --- a/lib/l10n/app_localizations_cs.dart +++ b/lib/l10n/app_localizations_cs.dart @@ -2460,6 +2460,21 @@ class AppLocalizationsCs extends AppLocalizations { @override String get bookmarks_remove => 'Odebrat záložku'; + @override + String get bookmarks_removeConfirmTitle => 'Remove Bookmark'; + + @override + String get bookmarks_removeConfirmMessage => + 'Remove this message from your bookmarks?'; + + @override + String get bookmarks_removeSelectedConfirmTitle => 'Remove Bookmarks'; + + @override + String bookmarks_removeSelectedConfirmMessage(int count) { + return 'Remove $count messages from your bookmarks?'; + } + @override String get chat_selectMessages => 'Vybrat zprávy'; diff --git a/lib/l10n/app_localizations_de.dart b/lib/l10n/app_localizations_de.dart index 35fe52af..a5992b04 100644 --- a/lib/l10n/app_localizations_de.dart +++ b/lib/l10n/app_localizations_de.dart @@ -2477,6 +2477,21 @@ class AppLocalizationsDe extends AppLocalizations { @override String get bookmarks_remove => 'Lesezeichen entfernen'; + @override + String get bookmarks_removeConfirmTitle => 'Remove Bookmark'; + + @override + String get bookmarks_removeConfirmMessage => + 'Remove this message from your bookmarks?'; + + @override + String get bookmarks_removeSelectedConfirmTitle => 'Remove Bookmarks'; + + @override + String bookmarks_removeSelectedConfirmMessage(int count) { + return 'Remove $count messages from your bookmarks?'; + } + @override String get chat_selectMessages => 'Nachrichten auswählen'; diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart index 996eae3d..aef6e653 100644 --- a/lib/l10n/app_localizations_en.dart +++ b/lib/l10n/app_localizations_en.dart @@ -2430,6 +2430,21 @@ class AppLocalizationsEn extends AppLocalizations { @override String get bookmarks_remove => 'Remove bookmark'; + @override + String get bookmarks_removeConfirmTitle => 'Remove Bookmark'; + + @override + String get bookmarks_removeConfirmMessage => + 'Remove this message from your bookmarks?'; + + @override + String get bookmarks_removeSelectedConfirmTitle => 'Remove Bookmarks'; + + @override + String bookmarks_removeSelectedConfirmMessage(int count) { + return 'Remove $count messages from your bookmarks?'; + } + @override String get chat_selectMessages => 'Select messages'; diff --git a/lib/l10n/app_localizations_es.dart b/lib/l10n/app_localizations_es.dart index 93e3bc3c..f0640741 100644 --- a/lib/l10n/app_localizations_es.dart +++ b/lib/l10n/app_localizations_es.dart @@ -2468,6 +2468,21 @@ class AppLocalizationsEs extends AppLocalizations { @override String get bookmarks_remove => 'Quitar marcador'; + @override + String get bookmarks_removeConfirmTitle => 'Remove Bookmark'; + + @override + String get bookmarks_removeConfirmMessage => + 'Remove this message from your bookmarks?'; + + @override + String get bookmarks_removeSelectedConfirmTitle => 'Remove Bookmarks'; + + @override + String bookmarks_removeSelectedConfirmMessage(int count) { + return 'Remove $count messages from your bookmarks?'; + } + @override String get chat_selectMessages => 'Seleccionar mensajes'; diff --git a/lib/l10n/app_localizations_fr.dart b/lib/l10n/app_localizations_fr.dart index ab882eb8..2dabd038 100644 --- a/lib/l10n/app_localizations_fr.dart +++ b/lib/l10n/app_localizations_fr.dart @@ -2473,6 +2473,21 @@ class AppLocalizationsFr extends AppLocalizations { @override String get bookmarks_remove => 'Retirer des favoris'; + @override + String get bookmarks_removeConfirmTitle => 'Remove Bookmark'; + + @override + String get bookmarks_removeConfirmMessage => + 'Remove this message from your bookmarks?'; + + @override + String get bookmarks_removeSelectedConfirmTitle => 'Remove Bookmarks'; + + @override + String bookmarks_removeSelectedConfirmMessage(int count) { + return 'Remove $count messages from your bookmarks?'; + } + @override String get chat_selectMessages => 'Sélectionner des messages'; diff --git a/lib/l10n/app_localizations_hu.dart b/lib/l10n/app_localizations_hu.dart index 1c007755..6587c589 100644 --- a/lib/l10n/app_localizations_hu.dart +++ b/lib/l10n/app_localizations_hu.dart @@ -2465,6 +2465,21 @@ class AppLocalizationsHu extends AppLocalizations { @override String get bookmarks_remove => 'Könyvjelző eltávolítása'; + @override + String get bookmarks_removeConfirmTitle => 'Remove Bookmark'; + + @override + String get bookmarks_removeConfirmMessage => + 'Remove this message from your bookmarks?'; + + @override + String get bookmarks_removeSelectedConfirmTitle => 'Remove Bookmarks'; + + @override + String bookmarks_removeSelectedConfirmMessage(int count) { + return 'Remove $count messages from your bookmarks?'; + } + @override String get chat_selectMessages => 'Üzenetek kijelölése'; diff --git a/lib/l10n/app_localizations_it.dart b/lib/l10n/app_localizations_it.dart index 61d66edc..326c40fa 100644 --- a/lib/l10n/app_localizations_it.dart +++ b/lib/l10n/app_localizations_it.dart @@ -2470,6 +2470,21 @@ class AppLocalizationsIt extends AppLocalizations { @override String get bookmarks_remove => 'Rimuovi segnalibro'; + @override + String get bookmarks_removeConfirmTitle => 'Remove Bookmark'; + + @override + String get bookmarks_removeConfirmMessage => + 'Remove this message from your bookmarks?'; + + @override + String get bookmarks_removeSelectedConfirmTitle => 'Remove Bookmarks'; + + @override + String bookmarks_removeSelectedConfirmMessage(int count) { + return 'Remove $count messages from your bookmarks?'; + } + @override String get chat_selectMessages => 'Seleziona messaggi'; diff --git a/lib/l10n/app_localizations_ja.dart b/lib/l10n/app_localizations_ja.dart index 77e504ec..445ea161 100644 --- a/lib/l10n/app_localizations_ja.dart +++ b/lib/l10n/app_localizations_ja.dart @@ -2355,6 +2355,21 @@ class AppLocalizationsJa extends AppLocalizations { @override String get bookmarks_remove => 'ブックマークを削除'; + @override + String get bookmarks_removeConfirmTitle => 'Remove Bookmark'; + + @override + String get bookmarks_removeConfirmMessage => + 'Remove this message from your bookmarks?'; + + @override + String get bookmarks_removeSelectedConfirmTitle => 'Remove Bookmarks'; + + @override + String bookmarks_removeSelectedConfirmMessage(int count) { + return 'Remove $count messages from your bookmarks?'; + } + @override String get chat_selectMessages => 'メッセージを選択'; diff --git a/lib/l10n/app_localizations_ko.dart b/lib/l10n/app_localizations_ko.dart index ac0efb97..95df0d0b 100644 --- a/lib/l10n/app_localizations_ko.dart +++ b/lib/l10n/app_localizations_ko.dart @@ -2357,6 +2357,21 @@ class AppLocalizationsKo extends AppLocalizations { @override String get bookmarks_remove => '북마크 삭제'; + @override + String get bookmarks_removeConfirmTitle => 'Remove Bookmark'; + + @override + String get bookmarks_removeConfirmMessage => + 'Remove this message from your bookmarks?'; + + @override + String get bookmarks_removeSelectedConfirmTitle => 'Remove Bookmarks'; + + @override + String bookmarks_removeSelectedConfirmMessage(int count) { + return 'Remove $count messages from your bookmarks?'; + } + @override String get chat_selectMessages => '메시지 선택'; diff --git a/lib/l10n/app_localizations_nl.dart b/lib/l10n/app_localizations_nl.dart index 2cd9302f..955d48c1 100644 --- a/lib/l10n/app_localizations_nl.dart +++ b/lib/l10n/app_localizations_nl.dart @@ -2455,6 +2455,21 @@ class AppLocalizationsNl extends AppLocalizations { @override String get bookmarks_remove => 'Bladwijzer verwijderen'; + @override + String get bookmarks_removeConfirmTitle => 'Remove Bookmark'; + + @override + String get bookmarks_removeConfirmMessage => + 'Remove this message from your bookmarks?'; + + @override + String get bookmarks_removeSelectedConfirmTitle => 'Remove Bookmarks'; + + @override + String bookmarks_removeSelectedConfirmMessage(int count) { + return 'Remove $count messages from your bookmarks?'; + } + @override String get chat_selectMessages => 'Berichten selecteren'; diff --git a/lib/l10n/app_localizations_pl.dart b/lib/l10n/app_localizations_pl.dart index 1c85e5e5..4e416a1e 100644 --- a/lib/l10n/app_localizations_pl.dart +++ b/lib/l10n/app_localizations_pl.dart @@ -2488,6 +2488,21 @@ class AppLocalizationsPl extends AppLocalizations { @override String get bookmarks_remove => 'Usuń zakładkę'; + @override + String get bookmarks_removeConfirmTitle => 'Remove Bookmark'; + + @override + String get bookmarks_removeConfirmMessage => + 'Remove this message from your bookmarks?'; + + @override + String get bookmarks_removeSelectedConfirmTitle => 'Remove Bookmarks'; + + @override + String bookmarks_removeSelectedConfirmMessage(int count) { + return 'Remove $count messages from your bookmarks?'; + } + @override String get chat_selectMessages => 'Wybierz wiadomości'; diff --git a/lib/l10n/app_localizations_pt.dart b/lib/l10n/app_localizations_pt.dart index a47767f3..b9c5a009 100644 --- a/lib/l10n/app_localizations_pt.dart +++ b/lib/l10n/app_localizations_pt.dart @@ -2466,6 +2466,21 @@ class AppLocalizationsPt extends AppLocalizations { @override String get bookmarks_remove => 'Remover marcador'; + @override + String get bookmarks_removeConfirmTitle => 'Remove Bookmark'; + + @override + String get bookmarks_removeConfirmMessage => + 'Remove this message from your bookmarks?'; + + @override + String get bookmarks_removeSelectedConfirmTitle => 'Remove Bookmarks'; + + @override + String bookmarks_removeSelectedConfirmMessage(int count) { + return 'Remove $count messages from your bookmarks?'; + } + @override String get chat_selectMessages => 'Selecionar mensagens'; diff --git a/lib/l10n/app_localizations_ru.dart b/lib/l10n/app_localizations_ru.dart index 812d0b1c..30cb0e50 100644 --- a/lib/l10n/app_localizations_ru.dart +++ b/lib/l10n/app_localizations_ru.dart @@ -2469,6 +2469,21 @@ class AppLocalizationsRu extends AppLocalizations { @override String get bookmarks_remove => 'Убрать из закладок'; + @override + String get bookmarks_removeConfirmTitle => 'Remove Bookmark'; + + @override + String get bookmarks_removeConfirmMessage => + 'Remove this message from your bookmarks?'; + + @override + String get bookmarks_removeSelectedConfirmTitle => 'Remove Bookmarks'; + + @override + String bookmarks_removeSelectedConfirmMessage(int count) { + return 'Remove $count messages from your bookmarks?'; + } + @override String get chat_selectMessages => 'Выбрать сообщения'; diff --git a/lib/l10n/app_localizations_sk.dart b/lib/l10n/app_localizations_sk.dart index 6eba4525..93543323 100644 --- a/lib/l10n/app_localizations_sk.dart +++ b/lib/l10n/app_localizations_sk.dart @@ -2461,6 +2461,21 @@ class AppLocalizationsSk extends AppLocalizations { @override String get bookmarks_remove => 'Odstrániť záložku'; + @override + String get bookmarks_removeConfirmTitle => 'Remove Bookmark'; + + @override + String get bookmarks_removeConfirmMessage => + 'Remove this message from your bookmarks?'; + + @override + String get bookmarks_removeSelectedConfirmTitle => 'Remove Bookmarks'; + + @override + String bookmarks_removeSelectedConfirmMessage(int count) { + return 'Remove $count messages from your bookmarks?'; + } + @override String get chat_selectMessages => 'Vybrať správy'; diff --git a/lib/l10n/app_localizations_sl.dart b/lib/l10n/app_localizations_sl.dart index 223174c2..d414a474 100644 --- a/lib/l10n/app_localizations_sl.dart +++ b/lib/l10n/app_localizations_sl.dart @@ -2462,6 +2462,21 @@ class AppLocalizationsSl extends AppLocalizations { @override String get bookmarks_remove => 'Odstrani zaznamek'; + @override + String get bookmarks_removeConfirmTitle => 'Remove Bookmark'; + + @override + String get bookmarks_removeConfirmMessage => + 'Remove this message from your bookmarks?'; + + @override + String get bookmarks_removeSelectedConfirmTitle => 'Remove Bookmarks'; + + @override + String bookmarks_removeSelectedConfirmMessage(int count) { + return 'Remove $count messages from your bookmarks?'; + } + @override String get chat_selectMessages => 'Izberi sporočila'; diff --git a/lib/l10n/app_localizations_sv.dart b/lib/l10n/app_localizations_sv.dart index d014986c..957b7df4 100644 --- a/lib/l10n/app_localizations_sv.dart +++ b/lib/l10n/app_localizations_sv.dart @@ -2444,6 +2444,21 @@ class AppLocalizationsSv extends AppLocalizations { @override String get bookmarks_remove => 'Ta bort bokmärke'; + @override + String get bookmarks_removeConfirmTitle => 'Remove Bookmark'; + + @override + String get bookmarks_removeConfirmMessage => + 'Remove this message from your bookmarks?'; + + @override + String get bookmarks_removeSelectedConfirmTitle => 'Remove Bookmarks'; + + @override + String bookmarks_removeSelectedConfirmMessage(int count) { + return 'Remove $count messages from your bookmarks?'; + } + @override String get chat_selectMessages => 'Markera meddelanden'; diff --git a/lib/l10n/app_localizations_uk.dart b/lib/l10n/app_localizations_uk.dart index e98348b2..b75de25e 100644 --- a/lib/l10n/app_localizations_uk.dart +++ b/lib/l10n/app_localizations_uk.dart @@ -2466,6 +2466,21 @@ class AppLocalizationsUk extends AppLocalizations { @override String get bookmarks_remove => 'Прибрати із закладок'; + @override + String get bookmarks_removeConfirmTitle => 'Remove Bookmark'; + + @override + String get bookmarks_removeConfirmMessage => + 'Remove this message from your bookmarks?'; + + @override + String get bookmarks_removeSelectedConfirmTitle => 'Remove Bookmarks'; + + @override + String bookmarks_removeSelectedConfirmMessage(int count) { + return 'Remove $count messages from your bookmarks?'; + } + @override String get chat_selectMessages => 'Вибрати повідомлення'; diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart index ae846a22..9a0444ae 100644 --- a/lib/l10n/app_localizations_zh.dart +++ b/lib/l10n/app_localizations_zh.dart @@ -2325,6 +2325,21 @@ class AppLocalizationsZh extends AppLocalizations { @override String get bookmarks_remove => '移除书签'; + @override + String get bookmarks_removeConfirmTitle => 'Remove Bookmark'; + + @override + String get bookmarks_removeConfirmMessage => + 'Remove this message from your bookmarks?'; + + @override + String get bookmarks_removeSelectedConfirmTitle => 'Remove Bookmarks'; + + @override + String bookmarks_removeSelectedConfirmMessage(int count) { + return 'Remove $count messages from your bookmarks?'; + } + @override String get chat_selectMessages => '选择消息'; diff --git a/lib/screens/bookmarks_screen.dart b/lib/screens/bookmarks_screen.dart index 2001db4a..a4f282e6 100644 --- a/lib/screens/bookmarks_screen.dart +++ b/lib/screens/bookmarks_screen.dart @@ -1,17 +1,38 @@ +import 'dart:async'; + import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:provider/provider.dart'; import '../connector/meshcore_connector.dart'; +import '../helpers/chat_jump.dart'; +import '../helpers/message_search.dart'; import '../helpers/message_url_image_helper.dart'; +import '../helpers/snack_bar_builder.dart'; import '../l10n/l10n.dart'; import '../models/bookmarked_message.dart'; import '../services/app_settings_service.dart'; +import '../services/chat_text_scale_service.dart'; +import '../theme/mesh_theme.dart'; +import '../widgets/chat_search_results.dart'; import '../widgets/chat_send_pipeline.dart'; import '../widgets/empty_state.dart'; +import '../widgets/mesh_ui.dart'; import '../widgets/translated_message_content.dart'; class BookmarksScreen extends StatefulWidget { - const BookmarksScreen({super.key}); + final BookmarkSourceType? initialSourceType; + final String? initialSourceId; + final List sourceIdAliases; + final String? initialSourceName; + + const BookmarksScreen({ + super.key, + this.initialSourceType, + this.initialSourceId, + this.sourceIdAliases = const [], + this.initialSourceName, + }); @override State createState() => _BookmarksScreenState(); @@ -19,168 +40,603 @@ class BookmarksScreen extends StatefulWidget { class _BookmarksScreenState extends State { late Future> _bookmarks; + List _loadedBookmarks = const []; + bool _hasLoadedBookmarks = false; + late bool _filterToInitialSource; + + final ScrollController _scrollController = ScrollController(); + final TextEditingController _searchController = TextEditingController(); + bool _searching = false; + String _searchQuery = ''; + String? _highlightedStorageId; + Timer? _highlightTimer; + + final Set _selectedIds = {}; + + bool get _hasInitialSource => widget.initialSourceId != null; + bool get _selecting => _selectedIds.isNotEmpty; + bool get _showSearchResults => _searching && _searchQuery.trim().isNotEmpty; @override void initState() { super.initState(); - _bookmarks = context.read().loadBookmarkedMessages(); + _filterToInitialSource = widget.initialSourceId != null; + _bookmarks = _fetchBookmarks(); + } + + @override + void dispose() { + _highlightTimer?.cancel(); + _searchController.dispose(); + _scrollController.dispose(); + super.dispose(); + } + + Future> _fetchBookmarks() async { + final loaded = await context + .read() + .loadBookmarkedMessages(); + if (mounted) { + _loadedBookmarks = loaded; + _hasLoadedBookmarks = true; + } + return loaded; } void _reload() { setState(() { - _bookmarks = context.read().loadBookmarkedMessages(); + _bookmarks = _fetchBookmarks(); }); } + bool _matchesInitialSource( + BookmarkedMessage bookmark, + MeshCoreConnector connector, + ) { + final sourceId = widget.initialSourceId; + if (sourceId == null) return true; + if (widget.initialSourceType != null && + bookmark.sourceType != widget.initialSourceType) { + return false; + } + final validIds = {sourceId, ...widget.sourceIdAliases}; + if (bookmark.sourceType == BookmarkSourceType.channel) { + for (final channel in connector.channels) { + final slotId = 'slot:${channel.index}'; + final storageId = channel.storageId; + if (validIds.contains(slotId) || + (storageId != null && validIds.contains(storageId))) { + validIds.add(slotId); + if (storageId != null) validIds.add(storageId); + } + } + } + return validIds.contains(bookmark.sourceId); + } + + List _filteredBookmarks( + List all, + MeshCoreConnector connector, + ) { + final filtered = [ + for (final bookmark in all) + if (!_hasInitialSource || + !_filterToInitialSource || + _matchesInitialSource(bookmark, connector)) + bookmark, + ]; + filtered.sort((a, b) => a.receivedAt.compareTo(b.receivedAt)); + return filtered; + } + + void _openSearch() => setState(() => _searching = true); + + void _closeSearch() { + _searchController.clear(); + setState(() { + _searching = false; + _searchQuery = ''; + }); + } + + Widget _buildSearchField() { + return CallbackShortcuts( + bindings: { + const SingleActivator(LogicalKeyboardKey.escape): _closeSearch, + }, + child: TextField( + controller: _searchController, + autofocus: true, + textInputAction: TextInputAction.search, + style: const TextStyle(fontSize: 16), + decoration: InputDecoration( + hintText: context.l10n.chatSearch_hint, + border: InputBorder.none, + ), + onChanged: (value) => setState(() => _searchQuery = value), + ), + ); + } + + Future> _loadSearchEntries() async { + final connector = context.read(); + final all = await connector.loadBookmarkedMessages(); + if (mounted) { + _loadedBookmarks = all; + _hasLoadedBookmarks = true; + } + final visible = _filteredBookmarks(all, connector); + return [ + for (final bookmark in visible) + ChatSearchEntry( + id: bookmark.storageId, + sender: '${bookmark.senderName} · ${bookmark.sourceName}', + text: bookmark.text, + translatedText: bookmark.translatedText, + time: bookmark.receivedAt, + matchSender: true, + ), + ]; + } + + 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); + final index = visible.indexWhere((b) => b.storageId == storageId); + if (index < 0) { + showDismissibleSnackBar( + context, + content: Text(context.l10n.chatSearch_jumpFailed), + ); + return; + } + final targetIndex = visible.length - 1 - index; + if (_scrollController.hasClients) { + await scrollListToIndex( + controller: _scrollController, + targetIndex: targetIndex, + itemCount: visible.length, + isMounted: () => mounted, + ); + } + if (!mounted) return; + _highlightTimer?.cancel(); + setState(() => _highlightedStorageId = storageId); + _highlightTimer = Timer(const Duration(seconds: 2), () { + if (mounted) setState(() => _highlightedStorageId = null); + }); + } + + void _toggleSelected(BookmarkedMessage bookmark) { + HapticFeedback.selectionClick(); + setState(() { + if (!_selectedIds.remove(bookmark.storageId)) { + _selectedIds.add(bookmark.storageId); + } + }); + } + + void _clearSelection() => setState(_selectedIds.clear); + Future _remove(BookmarkedMessage bookmark) async { + final confirmed = await confirmRemoveBookmarks(context); + if (!confirmed || !mounted) return; await context.read().setBookmarkedMessage( bookmark, isBookmarked: false, ); + if (!mounted) return; + _selectedIds.remove(bookmark.storageId); + _reload(); + } + + Future _removeSelected() async { + if (_selectedIds.isEmpty) return; + final connector = context.read(); + final visible = _filteredBookmarks(_loadedBookmarks, connector); + final toRemove = [ + for (final bookmark in visible) + if (_selectedIds.contains(bookmark.storageId)) bookmark, + ]; + final count = toRemove.isNotEmpty ? toRemove.length : _selectedIds.length; + final confirmed = await confirmRemoveBookmarks(context, count: count); + if (!confirmed || !mounted) return; + final targets = toRemove.isNotEmpty + ? toRemove + : [ + for (final bookmark in _loadedBookmarks) + if (_selectedIds.contains(bookmark.storageId)) bookmark, + ]; + _clearSelection(); + for (final bookmark in targets) { + await connector.setBookmarkedMessage(bookmark, isBookmarked: false); + } if (mounted) _reload(); } + PreferredSizeWidget _buildSelectionAppBar(BuildContext context) { + final l10n = context.l10n; + return AppBar( + leading: IconButton( + tooltip: l10n.chat_clearSelection, + icon: const Icon(Icons.close), + onPressed: _clearSelection, + ), + title: Text(l10n.chat_selectedCount(_selectedIds.length)), + centerTitle: false, + actions: [ + IconButton( + tooltip: l10n.bookmarks_remove, + icon: const Icon(Icons.delete_outline), + onPressed: _selectedIds.isEmpty ? null : _removeSelected, + ), + ], + ); + } + + Widget _buildScopePill(BuildContext context) { + final sourceLabel = + (widget.initialSourceName != null && + widget.initialSourceName!.trim().isNotEmpty) + ? widget.initialSourceName! + : widget.initialSourceId!; + return Padding( + padding: const EdgeInsets.fromLTRB(16, 12, 16, 4), + child: SizedBox( + width: double.infinity, + child: SegmentedButton( + showSelectedIcon: false, + style: SegmentedButton.styleFrom( + minimumSize: const Size(48, 48), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(MeshRadii.pill), + ), + ), + segments: [ + ButtonSegment( + value: false, + label: MeshSegmentLabel(context.l10n.listFilter_all), + ), + ButtonSegment( + value: true, + label: MeshSegmentLabel(sourceLabel), + ), + ], + selected: {_filterToInitialSource}, + onSelectionChanged: (selection) { + setState(() { + _filterToInitialSource = selection.first; + _selectedIds.clear(); + }); + }, + ), + ), + ); + } + + Widget _buildSelectableRow(BookmarkedMessage bookmark, Widget cardBody) { + final scheme = Theme.of(context).colorScheme; + final selected = _selectedIds.contains(bookmark.storageId); + return Semantics( + selected: selected, + button: true, + child: Material( + color: selected + ? scheme.primary.withValues(alpha: 0.16) + : Colors.transparent, + borderRadius: BorderRadius.circular(MeshRadii.md), + child: InkWell( + borderRadius: BorderRadius.circular(MeshRadii.md), + onTap: () => _toggleSelected(bookmark), + onLongPress: () => _toggleSelected(bookmark), + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 3, horizontal: 4), + child: Row( + children: [ + Icon( + selected ? Icons.check_circle : Icons.radio_button_unchecked, + size: 28, + color: selected ? scheme.primary : scheme.onSurfaceVariant, + ), + const SizedBox(width: 8), + Expanded(child: AbsorbPointer(child: cardBody)), + ], + ), + ), + ), + ), + ); + } + @override Widget build(BuildContext context) { final l10n = context.l10n; - final publicIpfsGateway = context - .watch() - .settings - .publicIpfsGateway; - return Scaffold( - appBar: AppBar(title: Text(l10n.bookmarks_title), centerTitle: true), - body: FutureBuilder>( - future: _bookmarks, - builder: (context, snapshot) { - if (snapshot.connectionState != ConnectionState.done) { - return const Center(child: CircularProgressIndicator()); - } - final bookmarks = snapshot.data ?? const []; - if (bookmarks.isEmpty) { - return EmptyState( - icon: Icons.bookmark_border, - title: l10n.bookmarks_empty, - ); - } - bookmarks.sort((a, b) => a.receivedAt.compareTo(b.receivedAt)); - return ListView.builder( - reverse: true, - padding: const EdgeInsets.all(12), - itemCount: bookmarks.length, - itemBuilder: (context, index) { - final bookmark = bookmarks[bookmarks.length - 1 - index]; - final sourceType = - bookmark.sourceType == BookmarkSourceType.channel - ? l10n.bookmarks_channel - : l10n.bookmarks_contact; - final receivedAt = bookmark.receivedAt.toLocal(); - final localizations = MaterialLocalizations.of(context); - final time = localizations.formatTimeOfDay( - TimeOfDay.fromDateTime(receivedAt), - alwaysUse24HourFormat: MediaQuery.alwaysUse24HourFormatOf( - context, - ), - ); - final dateTime = - '${localizations.formatShortDate(receivedAt)} $time'; - final translation = bookmark.translatedText?.trim(); - final displayText = translation?.isNotEmpty == true - ? translation! - : bookmark.text; - final textStyle = - Theme.of(context).textTheme.bodyMedium ?? const TextStyle(); - final textContent = TranslatedMessageContent( - displayText: displayText, - originalText: displayText == bookmark.text + final publicIpfsGateway = + context.watch()?.settings.publicIpfsGateway ?? ''; + final textScale = context.watch()?.scale ?? 1.0; + + return PopScope( + canPop: !_searching && !_selecting, + onPopInvokedWithResult: (didPop, _) { + if (didPop) return; + if (_selecting) { + _clearSelection(); + } else if (_searching) { + _closeSearch(); + } + }, + child: Scaffold( + appBar: _selecting + ? _buildSelectionAppBar(context) + : AppBar( + leading: _searching + ? IconButton( + tooltip: l10n.chatSearch_close, + icon: const Icon(Icons.arrow_back), + onPressed: _closeSearch, + ) + : null, + title: _searching + ? _buildSearchField() + : Text(l10n.bookmarks_title), + centerTitle: !_searching, + actions: _searching ? null - : bookmark.text, - style: textStyle, - originalStyle: textStyle.copyWith(fontStyle: FontStyle.italic), - backgroundColor: - Theme.of(context).cardTheme.color ?? - Theme.of(context).colorScheme.surfaceContainerLow, - ); - return Card( - margin: const EdgeInsets.only(bottom: 10), - child: Padding( - padding: const EdgeInsets.fromLTRB(16, 12, 8, 12), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Padding( - padding: EdgeInsets.only(top: 2, right: 8), - child: Icon( - Icons.bookmark, - size: 20, - color: Color(0xFFFFE54A), - ), - ), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - '$sourceType · ${bookmark.sourceName}', - style: Theme.of(context).textTheme.titleSmall, + : [ + IconButton( + tooltip: l10n.chatSearch_tooltip, + icon: const Icon(Icons.search), + onPressed: _openSearch, + ), + ], + ), + body: Column( + children: [ + if (_hasInitialSource) _buildScopePill(context), + Expanded( + child: _showSearchResults + ? ChatSearchResults( + key: ValueKey(_filterToInitialSource), + query: _searchQuery.trim(), + loadEntries: _loadSearchEntries, + textScale: textScale, + onSelect: (entry) => + unawaited(_jumpToSearchResult(entry.id)), + ) + : FutureBuilder>( + future: _bookmarks, + initialData: _hasLoadedBookmarks + ? _loadedBookmarks + : null, + builder: (context, snapshot) { + if (!snapshot.hasData && + snapshot.connectionState != ConnectionState.done) { + return const Center( + child: CircularProgressIndicator(), + ); + } + final connector = context.watch(); + final allBookmarks = + snapshot.data ?? const []; + _loadedBookmarks = allBookmarks; + _hasLoadedBookmarks = true; + final bookmarks = _filteredBookmarks( + allBookmarks, + connector, + ); + if (bookmarks.isEmpty) { + return EmptyState( + icon: Icons.bookmark_border, + title: l10n.bookmarks_empty, + ); + } + return ListView.builder( + controller: _scrollController, + reverse: true, + padding: const EdgeInsets.all(12), + itemCount: bookmarks.length, + itemBuilder: (context, index) { + final bookmark = + bookmarks[bookmarks.length - 1 - index]; + final sourceType = + bookmark.sourceType == + BookmarkSourceType.channel + ? l10n.bookmarks_channel + : l10n.bookmarks_contact; + final receivedAt = bookmark.receivedAt.toLocal(); + final localizations = MaterialLocalizations.of( + context, + ); + final time = localizations.formatTimeOfDay( + TimeOfDay.fromDateTime(receivedAt), + alwaysUse24HourFormat: + MediaQuery.alwaysUse24HourFormatOf(context), + ); + final dateTime = + '${localizations.formatShortDate(receivedAt)} $time'; + final translation = bookmark.translatedText?.trim(); + final displayText = translation?.isNotEmpty == true + ? translation! + : bookmark.text; + final textStyle = + Theme.of(context).textTheme.bodyMedium ?? + const TextStyle(); + final scheme = Theme.of(context).colorScheme; + final baseCardColor = + Theme.of(context).cardTheme.color ?? + scheme.surfaceContainerLow; + final highlighted = + bookmark.storageId == _highlightedStorageId; + final cardColor = highlighted + ? Color.alphaBlend( + scheme.primary.withValues(alpha: 0.18), + baseCardColor, + ) + : baseCardColor; + final textContent = TranslatedMessageContent( + displayText: displayText, + originalText: displayText == bookmark.text + ? null + : bookmark.text, + style: textStyle, + originalStyle: textStyle.copyWith( + fontStyle: FontStyle.italic, + ), + backgroundColor: cardColor, + selectable: false, + ); + final card = Card( + margin: EdgeInsets.zero, + color: cardColor, + child: InkWell( + borderRadius: BorderRadius.circular( + MeshRadii.md, ), - const SizedBox(height: 2), - Text( - '${bookmark.senderName} · $dateTime', - style: Theme.of(context).textTheme.bodySmall, - ), - ], - ), - ), - IconButton( - tooltip: l10n.common_copy, - onPressed: () => - copyChatMessageText(context, bookmark.text), - icon: const Icon(Icons.copy), - ), - IconButton( - tooltip: l10n.bookmarks_remove, - onPressed: () => _remove(bookmark), - icon: const Icon(Icons.bookmark_remove_outlined), - ), - ], - ), - const SizedBox(height: 8), - if (MessageUrlImageHelper.hasPotentialImageUrl( - bookmark.text, - )) - MessageUrlImageFutureBuilder( - messageId: bookmark.messageId, - text: bookmark.text, - publicGateway: publicIpfsGateway, - builder: (context, snapshot) { - final imageUrl = snapshot.data; - if (imageUrl == null) return textContent; - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.only(bottom: 8), - child: MessageUrlImagePreview( - imageUrl: imageUrl, + onLongPress: _selecting + ? null + : () => _toggleSelected(bookmark), + child: Padding( + padding: const EdgeInsets.fromLTRB( + 16, + 12, + 8, + 12, + ), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + const Padding( + padding: EdgeInsets.only( + top: 2, + right: 8, + ), + child: Icon( + Icons.bookmark, + size: 20, + color: Color(0xFFFFE54A), + ), + ), + Expanded( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + '$sourceType · ${bookmark.sourceName}', + style: Theme.of( + context, + ).textTheme.titleSmall, + ), + const SizedBox(height: 2), + Text( + '${bookmark.senderName} · $dateTime', + style: Theme.of( + context, + ).textTheme.bodySmall, + ), + ], + ), + ), + IconButton( + tooltip: l10n.common_copy, + onPressed: () => + copyChatMessageText( + context, + bookmark.text, + ), + icon: const Icon(Icons.copy), + ), + IconButton( + tooltip: l10n.bookmarks_remove, + onPressed: () => _remove(bookmark), + icon: const Icon( + Icons.bookmark_remove_outlined, + ), + ), + ], + ), + const SizedBox(height: 8), + if (MessageUrlImageHelper.hasPotentialImageUrl( + bookmark.text, + )) + MessageUrlImageFutureBuilder( + messageId: bookmark.messageId, + text: bookmark.text, + publicGateway: publicIpfsGateway, + builder: (context, snapshot) { + final imageUrl = snapshot.data; + if (imageUrl == null) { + return textContent; + } + return Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Padding( + padding: + const EdgeInsets.only( + bottom: 8, + ), + child: MessageUrlImagePreview( + imageUrl: imageUrl, + ), + ), + textContent, + ], + ); + }, + ) + else + textContent, + ], ), ), - textContent, - ], + ), + ); + final highlightedCard = highlighted + ? AnimatedContainer( + duration: const Duration(milliseconds: 300), + decoration: BoxDecoration( + color: scheme.primary.withValues( + alpha: 0.18, + ), + borderRadius: BorderRadius.circular( + MeshRadii.md, + ), + ), + child: card, + ) + : card; + return Padding( + padding: const EdgeInsets.only(bottom: 10), + child: _selecting + ? _buildSelectableRow( + bookmark, + highlightedCard, + ) + : highlightedCard, ); }, - ) - else - textContent, - ], - ), - ), - ); - }, - ); - }, + ); + }, + ), + ), + ], + ), ), ); } diff --git a/lib/screens/channel_chat_screen.dart b/lib/screens/channel_chat_screen.dart index ff01f571..5c1e7d23 100644 --- a/lib/screens/channel_chat_screen.dart +++ b/lib/screens/channel_chat_screen.dart @@ -74,6 +74,7 @@ import '../widgets/mesh_ui.dart'; import '../widgets/share_contact_sheet.dart'; import '../widgets/shared_contact_card.dart'; import 'app_settings_screen.dart'; +import 'bookmarks_screen.dart'; import 'channel_chat_transcript_grouping.dart'; import 'chat_compression_screen.dart'; import 'channels_screen.dart' show confirmDeleteChannel, showEditChannelSheet; @@ -178,7 +179,6 @@ class _ChannelChatScreenState extends State /// Message ids picked for a bulk action. Non-empty means selection mode: /// taps toggle messages and the app bar shows the bulk actions. final Set _selectedIds = {}; - bool _showBookmarkedOnly = false; bool get _selecting => _selectedIds.isNotEmpty; @override @@ -611,10 +611,27 @@ class _ChannelChatScreenState extends State onSaved: _onChannelEdited, ); case 'showBookmarks': - setState(() { - _showBookmarkedOnly = !_showBookmarkedOnly; - _selectedIds.clear(); - }); + final channelLabel = widget.channel.name.isEmpty + ? '#${context.l10n.channels_channelIndex(widget.channel.index)}' + : (widget.channel.name.startsWith('#') + ? widget.channel.name + : '#${widget.channel.name}'); + Navigator.push( + context, + MaterialPageRoute( + builder: (_) => BookmarksScreen( + initialSourceType: BookmarkSourceType.channel, + initialSourceId: + widget.channel.storageId ?? + 'slot:${widget.channel.index}', + sourceIdAliases: [ + ?widget.channel.storageId, + 'slot:${widget.channel.index}', + ], + initialSourceName: channelLabel, + ), + ), + ); case 'background': showChatBackgroundSheet( context, @@ -687,9 +704,8 @@ class _ChannelChatScreenState extends State PopupMenuItem( value: 'showBookmarks', child: _menuRow( - _showBookmarkedOnly ? Icons.bookmark : Icons.bookmark_border, - context.l10n.chat_showBookmarks, - color: _showBookmarkedOnly ? const Color(0xFFFFE54A) : null, + Icons.bookmark_border, + context.l10n.bookmarks_title, ), ), PopupMenuItem( @@ -923,22 +939,13 @@ class _ChannelChatScreenState extends State final layout = _transcriptLayoutFor( context, messages, - showBookmarkedOnly: _showBookmarkedOnly, ); // Fewer entries than messages means the message filter - // hid or collapsed some; bookmark filtering is deliberate. - final hidesMessages = - !_showBookmarkedOnly && - layout.length < messages.length; + // hid or collapsed some. + final hidesMessages = layout.length < messages.length; if (hidesMessages) _scheduleHiddenHistoryBackfill(); if (layout.length == 0) { - if (_showBookmarkedOnly) { - return EmptyState( - icon: Icons.bookmark_border, - title: context.l10n.bookmarks_empty, - ); - } final canLoadOlder = hidesMessages && !_olderHistoryExhausted; return EmptyState( @@ -1264,7 +1271,7 @@ class _ChannelChatScreenState extends State : null, child: MessageBubbleFrame( isOutgoing: isOutgoing, - isBookmarked: message.isBookmarked || _showBookmarkedOnly, + isBookmarked: message.isBookmarked, compact: gifId != null, maxWidth: constraints.maxWidth, child: Column( @@ -2306,9 +2313,8 @@ class _ChannelChatScreenState extends State /// `State`'s) — `watch` asserts on that. _TranscriptLayout _transcriptLayoutFor( BuildContext context, - List messages, { - bool showBookmarkedOnly = false, - }) { + List messages, + ) { ReceivedImageStore? store; try { store = context.watch(); @@ -2337,7 +2343,6 @@ class _ChannelChatScreenState extends State displayMode, filterActive, _revealVersion, - showBookmarkedOnly, _filteredMessagesSignature(messages), Object.hashAll( messages @@ -2346,8 +2351,7 @@ class _ChannelChatScreenState extends State ), ); final cached = _transcriptLayout; - if (!showBookmarkedOnly && - cached != null && + if (cached != null && cached.matches( messages, _imageStoreVersion, @@ -2356,14 +2360,11 @@ class _ChannelChatScreenState extends State )) { return cached; } - final displayedMessages = showBookmarkedOnly - ? messages.where((message) => message.isBookmarked).toList() - : messages; - final images = store == null || showBookmarkedOnly + final images = store == null ? const [] : store.entriesForChannel(widget.channel.storageId); final layout = _TranscriptLayout.build( - messages: displayedMessages, + messages: messages, images: images, imageVersion: _imageStoreVersion, channelIndex: widget.channel.index, @@ -3218,8 +3219,14 @@ class _ChannelChatScreenState extends State ? context.l10n.chat_removeBookmark : context.l10n.chat_bookmark, ), - onTap: () { + onTap: () async { + final connector = context.read(); + final selfLabel = connector.selfName ?? context.l10n.chat_me; Navigator.pop(sheetContext); + if (message.isBookmarked) { + final confirmed = await confirmRemoveBookmarks(context); + if (!confirmed || !mounted) return; + } final bookmark = BookmarkedMessage.fromChannel( message: message, channelId: @@ -3227,15 +3234,12 @@ class _ChannelChatScreenState extends State 'slot:${widget.channel.index}', channelName: widget.channel.name, senderName: message.isOutgoing - ? (context.read().selfName ?? - context.l10n.chat_me) + ? selfLabel : message.senderName, ); - unawaited( - context.read().setBookmarkedMessage( - bookmark, - isBookmarked: !message.isBookmarked, - ), + await connector.setBookmarkedMessage( + bookmark, + isBookmarked: !message.isBookmarked, ); }, ), @@ -3339,10 +3343,9 @@ class _ChannelChatScreenState extends State final filterActive = _transcriptLayout?.filterActive ?? true; return [ for (final m in messages) - if ((!_showBookmarkedOnly || m.isBookmarked) && - !(filterActive && - m.isFiltered && - !_revealedFilteredIds.contains(m.messageId))) + if (!(filterActive && + m.isFiltered && + !_revealedFilteredIds.contains(m.messageId))) m, ]; } @@ -3421,6 +3424,11 @@ class _ChannelChatScreenState extends State icon: const Icon(Icons.visibility_outlined), onPressed: () => _bulkMarkNotSpam(notSpamCandidates), ), + IconButton( + tooltip: l10n.chat_bookmark, + icon: const Icon(Icons.bookmark_add_outlined), + onPressed: selected.isEmpty ? null : () => _bulkBookmark(selected), + ), IconButton( tooltip: l10n.common_delete, icon: const Icon(Icons.delete_outline), @@ -3495,6 +3503,25 @@ class _ChannelChatScreenState extends State showDismissibleSnackBar(context, content: Text(text)); } + Future _bulkBookmark(List messages) async { + final connector = context.read(); + final selfLabel = connector.selfName ?? context.l10n.chat_me; + final channelId = + widget.channel.storageId ?? 'slot:${widget.channel.index}'; + final channelName = widget.channel.name; + final toBookmark = messages.where((m) => !m.isBookmarked).toList(); + _clearSelection(); + for (final message in toBookmark) { + final bookmark = BookmarkedMessage.fromChannel( + message: message, + channelId: channelId, + channelName: channelName, + senderName: message.isOutgoing ? selfLabel : message.senderName, + ); + await connector.setBookmarkedMessage(bookmark, isBookmarked: true); + } + } + Future _bulkDelete(List messages) async { final connector = context.read(); final confirmed = await confirmBulkDelete(context, messages.length); diff --git a/lib/screens/chat_screen.dart b/lib/screens/chat_screen.dart index 7a4fc444..65e80ce9 100644 --- a/lib/screens/chat_screen.dart +++ b/lib/screens/chat_screen.dart @@ -43,6 +43,7 @@ import '../widgets/chat_zoom_wrapper.dart'; import '../widgets/message_bubble_frame.dart'; import '../widgets/reaction_chips.dart'; import '../widgets/chat_day_separator.dart'; +import 'bookmarks_screen.dart'; import 'channel_message_path_screen.dart'; import 'chat_compression_screen.dart'; import 'contacts_screen.dart' show confirmRemoveContact; @@ -97,13 +98,12 @@ class _ChatScreenState extends State with WidgetsBindingObserver { final _textController = TextEditingController(); final _scrollController = ChatScrollController(); final _scrollAnchor = ChatScrollAnchor(); - ({String id, bool bookmarksOnly})? _newestRow; + String? _newestRowId; final _textFieldFocusNode = FocusNode(); bool _focusLostWhileAway = false; bool _focusLostToRoute = false; final GlobalKey _unreadScrollKey = GlobalKey(); bool _isLoadingOlder = false; - bool _showBookmarkedOnly = false; final Set _selectedIds = {}; bool get _selecting => _selectedIds.isNotEmpty; MeshCoreConnector? _connector; @@ -532,9 +532,17 @@ class _ChatScreenState extends State with WidgetsBindingObserver { case 'settings': _showContactSettings(context); case 'showBookmarks': - setState( - () => _showBookmarkedOnly = - !_showBookmarkedOnly, + Navigator.push( + context, + MaterialPageRoute( + builder: (_) => BookmarksScreen( + initialSourceType: + BookmarkSourceType.contact, + initialSourceId: + widget.contact.publicKeyHex, + initialSourceName: contact.name, + ), + ), ); case 'background': showChatBackgroundSheet( @@ -621,13 +629,8 @@ class _ChatScreenState extends State with WidgetsBindingObserver { PopupMenuItem( value: 'showBookmarks', child: MeshMenuItemRow( - icon: _showBookmarkedOnly - ? Icons.bookmark - : Icons.bookmark_border, - label: context.l10n.chat_showBookmarks, - color: _showBookmarkedOnly - ? const Color(0xFFFFE54A) - : null, + icon: Icons.bookmark_border, + label: context.l10n.bookmarks_title, ), ), PopupMenuItem( @@ -738,7 +741,6 @@ class _ChatScreenState extends State with WidgetsBindingObserver { } Widget _buildEmptyState() { - if (_showBookmarkedOnly) return _buildBookmarkEmptyState(); return EmptyState( icon: Icons.chat_bubble_outline, title: context.l10n.chat_noMessages, @@ -748,40 +750,25 @@ class _ChatScreenState extends State with WidgetsBindingObserver { ); } - Widget _buildBookmarkEmptyState() => EmptyState( - icon: Icons.bookmark_border, - title: context.l10n.bookmarks_empty, - ); - Widget _buildMessageList( List messages, MeshCoreConnector connector, ) { - final visibleMessages = _showBookmarkedOnly - ? messages.where((message) => message.isBookmarked).toList() - : messages; - if (_showBookmarkedOnly && visibleMessages.isEmpty) { - return _buildBookmarkEmptyState(); - } // Reverse messages so newest appear at bottom with reverse: true - final reversedMessages = visibleMessages.reversed.toList(); + final reversedMessages = messages.reversed.toList(); final itemCount = reversedMessages.length + (_isLoadingOlder ? 1 : 0); // A reader scrolled up keeps their place when messages arrive below, as // a room's backlog does in a burst right after login. - final previous = _newestRow; - final newest = ( - id: reversedMessages.first.messageId, - bookmarksOnly: _showBookmarkedOnly, - ); - _newestRow = newest; - if (previous != null && - previous.bookmarksOnly == newest.bookmarksOnly && - previous.id != newest.id && + final previousId = _newestRowId; + final newestId = reversedMessages.first.messageId; + _newestRowId = newestId; + if (previousId != null && + previousId != newestId && _pendingUnreadScrollTarget == null && _scrollController.showJumpToBottom.value) { final inserted = reversedMessages.indexWhere( - (m) => m.messageId == previous.id, + (m) => m.messageId == previousId, ); if (inserted > 0) _scrollAnchor.rowsInsertedBelow(inserted); } @@ -862,7 +849,7 @@ class _ChatScreenState extends State with WidgetsBindingObserver { : contact.name, sourceId: widget.contact.publicKeyHex, textScale: textScale, - isBookmarked: message.isBookmarked || _showBookmarkedOnly, + isBookmarked: message.isBookmarked, onLongPress: () => _showMessageActions(message, contact), onRetryReaction: (msg, emoji) => _sendReaction(msg, contact, emoji), @@ -1545,22 +1532,23 @@ class _ChatScreenState extends State with WidgetsBindingObserver { ? context.l10n.chat_removeBookmark : context.l10n.chat_bookmark, ), - onTap: () { + onTap: () async { + final connector = context.read(); + final selfLabel = connector.selfName ?? context.l10n.chat_me; Navigator.pop(sheetContext); + if (message.isBookmarked) { + final confirmed = await confirmRemoveBookmarks(context); + if (!confirmed || !mounted) return; + } final bookmark = BookmarkedMessage.fromContact( message: message, contactKey: widget.contact.publicKeyHex, contactName: widget.contact.name, - senderName: message.isOutgoing - ? (context.read().selfName ?? - context.l10n.chat_me) - : contact.name, + senderName: message.isOutgoing ? selfLabel : contact.name, ); - unawaited( - context.read().setBookmarkedMessage( - bookmark, - isBookmarked: !message.isBookmarked, - ), + await connector.setBookmarkedMessage( + bookmark, + isBookmarked: !message.isBookmarked, ); }, ), diff --git a/lib/screens/contacts_screen.dart b/lib/screens/contacts_screen.dart index d7f6dd28..5299a9ea 100644 --- a/lib/screens/contacts_screen.dart +++ b/lib/screens/contacts_screen.dart @@ -37,6 +37,7 @@ import '../widgets/sync_progress_overlay.dart'; import '../widgets/unread_badge.dart'; import '../helpers/snack_bar_builder.dart'; import 'add_contact_screen.dart'; +import 'bookmarks_screen.dart'; import 'channels_screen.dart'; import 'chat_screen.dart'; import 'discovery_screen.dart'; @@ -384,6 +385,16 @@ class _ContactsScreenState extends State { MaterialPageRoute(builder: (_) => const DiscoveryScreen()), ), ), + PopupMenuItem( + child: MeshMenuItemRow( + icon: Icons.bookmark_border, + label: menuContext.l10n.bookmarks_title, + ), + onTap: () => Navigator.push( + context, + MaterialPageRoute(builder: (_) => const BookmarksScreen()), + ), + ), const PopupMenuDivider(), PopupMenuItem( enabled: !readOnly, diff --git a/lib/storage/bookmark_store.dart b/lib/storage/bookmark_store.dart index 3b4ca251..d6a6669f 100644 --- a/lib/storage/bookmark_store.dart +++ b/lib/storage/bookmark_store.dart @@ -13,11 +13,11 @@ class BookmarkStore { String get keyFor => '$_keyPrefix$publicKeyHex'; - Future _pendingWrites = Future.value(); + Future? _pendingWrites; Future> loadBookmarks() async { final writes = _pendingWrites; - await writes; + if (writes != null) await writes; return _readBookmarks(keyFor); } @@ -47,11 +47,20 @@ class BookmarkStore { } Future _enqueue(Future Function() operation) { - final next = _pendingWrites.then((_) => operation()); - _pendingWrites = next.then( + final previous = _pendingWrites; + final next = previous == null + ? Future.sync(operation) + : previous.then((_) => operation()); + final completion = next.then( (_) {}, onError: (Object _, StackTrace _) {}, ); + _pendingWrites = completion; + completion.whenComplete(() { + if (identical(_pendingWrites, completion)) { + _pendingWrites = null; + } + }); return next; } diff --git a/lib/widgets/chat_send_pipeline.dart b/lib/widgets/chat_send_pipeline.dart index 2d437857..af65e3e9 100644 --- a/lib/widgets/chat_send_pipeline.dart +++ b/lib/widgets/chat_send_pipeline.dart @@ -219,3 +219,42 @@ Future confirmClearChat( ); return confirmed == true; } + +/// Asks before removing [count] bookmarked messages. +Future confirmRemoveBookmarks( + BuildContext context, { + int count = 1, +}) async { + final confirmed = await showDialog( + context: context, + builder: (dialogContext) { + final l10n = dialogContext.l10n; + return AlertDialog( + title: Text( + count == 1 + ? l10n.bookmarks_removeConfirmTitle + : l10n.bookmarks_removeSelectedConfirmTitle, + ), + content: Text( + count == 1 + ? l10n.bookmarks_removeConfirmMessage + : l10n.bookmarks_removeSelectedConfirmMessage(count), + ), + actions: [ + TextButton( + onPressed: () => Navigator.pop(dialogContext, false), + child: Text(l10n.common_cancel), + ), + TextButton( + onPressed: () => Navigator.pop(dialogContext, true), + style: TextButton.styleFrom( + foregroundColor: Theme.of(dialogContext).colorScheme.error, + ), + child: Text(l10n.common_remove), + ), + ], + ); + }, + ); + return confirmed == true; +} diff --git a/lib/widgets/translated_message_content.dart b/lib/widgets/translated_message_content.dart index c015585e..913beb9a 100644 --- a/lib/widgets/translated_message_content.dart +++ b/lib/widgets/translated_message_content.dart @@ -10,6 +10,7 @@ class TranslatedMessageContent extends StatelessWidget { final Color? backgroundColor; final bool showOriginalFirst; final VoidCallback? onSecondaryTap; + final bool selectable; const TranslatedMessageContent({ super.key, @@ -20,6 +21,7 @@ class TranslatedMessageContent extends StatelessWidget { this.backgroundColor, this.showOriginalFirst = true, this.onSecondaryTap, + this.selectable = true, }); @override @@ -42,6 +44,7 @@ class TranslatedMessageContent extends StatelessWidget { ), backgroundColor: backgroundColor, onSecondaryTap: onSecondaryTap, + selectable: selectable, ) : null; final translatedWidget = LinkHandler.buildLinkifyText( @@ -50,6 +53,7 @@ class TranslatedMessageContent extends StatelessWidget { style: style, backgroundColor: backgroundColor, onSecondaryTap: onSecondaryTap, + selectable: selectable, ); if (!shouldShowOriginal) { diff --git a/test/screens/bookmarks_screen_test.dart b/test/screens/bookmarks_screen_test.dart new file mode 100644 index 00000000..b5483907 --- /dev/null +++ b/test/screens/bookmarks_screen_test.dart @@ -0,0 +1,752 @@ +import 'dart:io'; + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_localizations/flutter_localizations.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:provider/provider.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +import 'package:meshcore_open/connector/meshcore_connector.dart'; +import 'package:meshcore_open/l10n/app_localizations.dart'; +import 'package:meshcore_open/models/bookmarked_message.dart'; +import 'package:meshcore_open/review_mode/review_radio.dart'; +import 'package:meshcore_open/screens/bookmarks_screen.dart'; +import 'package:meshcore_open/screens/channel_chat_screen.dart'; +import 'package:meshcore_open/screens/chat_screen.dart'; +import 'package:meshcore_open/screens/contacts_screen.dart'; +import 'package:meshcore_open/services/app_debug_log_service.dart'; +import 'package:meshcore_open/services/app_settings_service.dart'; +import 'package:meshcore_open/services/ble_debug_log_service.dart'; +import 'package:meshcore_open/services/chat_text_scale_service.dart'; +import 'package:meshcore_open/services/image_codec_service.dart'; +import 'package:meshcore_open/services/map_tile_cache_service.dart'; +import 'package:meshcore_open/services/message_retry_service.dart'; +import 'package:meshcore_open/services/network_map/network_map_upload_service.dart'; +import 'package:meshcore_open/services/path_history_service.dart'; +import 'package:meshcore_open/services/received_image_store.dart'; +import 'package:meshcore_open/services/storage_service.dart'; +import 'package:meshcore_open/services/timeout_prediction_service.dart'; +import 'package:meshcore_open/services/translation_service.dart'; +import 'package:meshcore_open/services/ui_view_state_service.dart'; +import 'package:meshcore_open/storage/prefs_manager.dart'; +import 'package:meshcore_open/theme/mesh_theme.dart'; +import 'package:meshcore_open/widgets/mesh_ui.dart'; +import 'package:meshcore_open/widgets/message_bubble_frame.dart'; + +final _l10n = lookupAppLocalizations(const Locale('en')); + +class _TestEnv { + final MeshCoreConnector connector; + final Widget Function(Widget home, {double textScale}) wrap; + + _TestEnv({required this.connector, required this.wrap}); +} + +_TestEnv? _sharedEnv; + +Future _pumpFuture(WidgetTester tester, Future future) async { + var done = false; + late T result; + Object? error; + StackTrace? stack; + future.then( + (value) { + result = value; + done = true; + }, + onError: (Object e, StackTrace s) { + error = e; + stack = s; + done = true; + }, + ); + for (var i = 0; i < 50 && !done; i++) { + await tester.pump(const Duration(milliseconds: 10)); + } + if (!done) { + throw StateError('Timed out pumping future in FakeAsync'); + } + if (error != null) Error.throwWithStackTrace(error!, stack!); + return result; +} + +Future<_TestEnv> _createEnv(WidgetTester tester) async { + if (_sharedEnv != null) { + final existing = _sharedEnv!; + final bookmarks = await _pumpFuture( + tester, + existing.connector.loadBookmarkedMessages(), + ); + for (final bookmark in bookmarks) { + await _pumpFuture( + tester, + existing.connector.setBookmarkedMessage(bookmark, isBookmarked: false), + ); + } + for (final channel in existing.connector.channels) { + for (final msg in existing.connector.getChannelMessages(channel)) { + if (msg.isBookmarked) { + await _pumpFuture( + tester, + existing.connector.setBookmarkedMessage( + BookmarkedMessage.fromChannel( + message: msg, + channelId: channel.storageId ?? 'slot:${channel.index}', + channelName: channel.name, + senderName: msg.senderName, + ), + isBookmarked: false, + ), + ); + } + } + } + return existing; + } + late final StorageService storage; + late final MeshCoreConnector connector; + late final MessageRetryService retry; + late final AppSettingsService settings; + late final TranslationService translation; + late final UiViewStateService viewState; + + await tester.runAsync(() async { + storage = StorageService(); + connector = MeshCoreConnector(); + retry = MessageRetryService(); + settings = AppSettingsService(); + translation = TranslationService(settings); + viewState = UiViewStateService(); + await settings.loadSettings(); + connector.initialize( + retryService: retry, + pathHistoryService: PathHistoryService(storage), + appSettingsService: settings, + translationService: translation, + ); + connector.reviewRadioFactoryForTest = () => ReviewRadio( + scheduledMessageInterval: const Duration(hours: 1), + ackDelay: const Duration(hours: 1), + replyDelay: const Duration(hours: 1), + ); + await connector.connectReview(); + final end = DateTime.now().add(const Duration(seconds: 8)); + while ((connector.contacts.isEmpty || + connector.channels.isEmpty || + !connector.channelMapConfirmed) && + DateTime.now().isBefore(end)) { + await Future.delayed(const Duration(milliseconds: 25)); + } + await Future.delayed(const Duration(milliseconds: 1200)); + }); + + final providers = [ + ChangeNotifierProvider.value(value: connector), + ChangeNotifierProvider.value(value: retry), + ChangeNotifierProvider.value(value: PathHistoryService(storage)), + ChangeNotifierProvider.value(value: settings), + ChangeNotifierProvider.value(value: BleDebugLogService()), + ChangeNotifierProvider.value(value: AppDebugLogService()), + ChangeNotifierProvider.value(value: ChatTextScaleService()), + ChangeNotifierProvider.value(value: translation), + ChangeNotifierProvider.value(value: viewState), + Provider.value(value: storage), + ChangeNotifierProvider.value( + value: MapTileCacheService(appSettingsService: settings), + ), + ChangeNotifierProvider.value(value: TimeoutPredictionService(storage)), + ChangeNotifierProvider.value(value: ImageCodecService(settings)), + ChangeNotifierProvider.value(value: ReceivedImageStore()), + ChangeNotifierProvider.value( + value: NetworkMapUploadService(connector: connector, settings: settings), + ), + ]; + + Widget wrap(Widget home, {double textScale = 1.0}) { + return MultiProvider( + providers: providers, + child: MaterialApp( + key: UniqueKey(), + theme: MeshTheme.light(), + locale: const Locale('en'), + localizationsDelegates: const [ + AppLocalizations.delegate, + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + GlobalCupertinoLocalizations.delegate, + ], + supportedLocales: AppLocalizations.supportedLocales, + builder: (context, child) => MediaQuery( + data: MediaQuery.of( + context, + ).copyWith(textScaler: TextScaler.linear(textScale)), + child: child!, + ), + home: home, + ), + ); + } + + return _sharedEnv = _TestEnv(connector: connector, wrap: wrap); +} + +Future _pumpFrames(WidgetTester tester, [int count = 8]) async { + for (var i = 0; i < count; i++) { + await tester.pump(const Duration(milliseconds: 100)); + } +} + +Finder _segmentByText(String label) => + find.byWidgetPredicate((w) => w is MeshSegmentLabel && w.text == label); + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + final tempDir = Directory.systemTemp.createTempSync('bookmarks_screen_test'); + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger + .setMockMethodCallHandler( + const MethodChannel('plugins.flutter.io/path_provider'), + (call) async => tempDir.path, + ); + + setUpAll(() async { + SharedPreferences.setMockInitialValues({}); + PrefsManager.reset(); + await PrefsManager.initialize(); + }); + + testWidgets( + 'Contacts overflow menu includes Bookmarks after Discovered Contacts and opens BookmarksScreen', + (tester) async { + final env = await _createEnv(tester); + await tester.pumpWidget(env.wrap(const ContactsScreen())); + await _pumpFrames(tester); + + await tester.tap(find.byIcon(Icons.more_vert)); + await _pumpFrames(tester); + + expect(find.text(_l10n.discoveredContacts_Title), findsOneWidget); + expect(find.text(_l10n.bookmarks_title), findsOneWidget); + + await tester.tap(find.text(_l10n.bookmarks_title)); + await _pumpFrames(tester); + + expect(find.byType(BookmarksScreen), findsOneWidget); + // No split pill when opened from main Contacts screen. + expect(find.byType(SegmentedButton), findsNothing); + + await tester.pumpWidget(const SizedBox()); + await tester.pump(const Duration(minutes: 1)); + }, + ); + + testWidgets( + 'ChannelChatScreen and ChatScreen overflow menus open BookmarksScreen with split pill filter', + (tester) async { + final env = await _createEnv(tester); + final channel = env.connector.channels.firstWhere( + (c) => c.name == 'Public', + ); + final contact = env.connector.contacts.firstWhere( + (c) => c.name == 'Maya', + ); + + final channelBookmark = BookmarkedMessage( + sourceType: BookmarkSourceType.channel, + sourceId: channel.storageId ?? 'slot:${channel.index}', + sourceName: channel.name, + messageId: 'ch-msg-1', + senderName: 'Maya', + text: 'Public channel bookmarked note', + timestamp: DateTime(2026, 1, 1, 10), + receivedAt: DateTime(2026, 1, 1, 10), + isOutgoing: false, + ); + final contactBookmark = BookmarkedMessage( + sourceType: BookmarkSourceType.contact, + sourceId: contact.publicKeyHex, + sourceName: contact.name, + messageId: 'dm-msg-1', + senderName: contact.name, + text: 'Direct message bookmarked note', + timestamp: DateTime(2026, 1, 1, 11), + receivedAt: DateTime(2026, 1, 1, 11), + isOutgoing: false, + ); + + await _pumpFuture( + tester, + env.connector.setBookmarkedMessage(channelBookmark, isBookmarked: true), + ); + await _pumpFuture( + tester, + env.connector.setBookmarkedMessage(contactBookmark, isBookmarked: true), + ); + + // 1. Open from ChannelChatScreen + await tester.pumpWidget(env.wrap(ChannelChatScreen(channel: channel))); + await _pumpFrames(tester); + + await tester.tap(find.byIcon(Icons.more_vert)); + await _pumpFrames(tester); + expect(find.text(_l10n.bookmarks_title), findsOneWidget); + + await tester.tap(find.text(_l10n.bookmarks_title)); + await _pumpFrames(tester); + + expect(find.byType(BookmarksScreen), findsOneWidget); + expect(find.byType(SegmentedButton), findsOneWidget); + expect(_segmentByText(_l10n.listFilter_all), findsOneWidget); + expect(_segmentByText('#Public'), findsOneWidget); + + // Defaults to current channel's bookmarks only. + expect(find.text('Public channel bookmarked note'), findsOneWidget); + expect(find.text('Direct message bookmarked note'), findsNothing); + + // Tap "All" segment to view all bookmarks across the app. + await tester.tap(_segmentByText(_l10n.listFilter_all)); + await _pumpFrames(tester); + + expect(find.text('Public channel bookmarked note'), findsOneWidget); + expect(find.text('Direct message bookmarked note'), findsOneWidget); + + // Tap "#Public" segment to scope back to channel. + await tester.tap(_segmentByText('#Public')); + await _pumpFrames(tester); + + expect(find.text('Public channel bookmarked note'), findsOneWidget); + expect(find.text('Direct message bookmarked note'), findsNothing); + + // 2. Open from ChatScreen (contact DM) + await tester.pumpWidget(env.wrap(ChatScreen(contact: contact))); + await _pumpFrames(tester); + + await tester.tap(find.byIcon(Icons.more_vert)); + await _pumpFrames(tester); + expect(find.text(_l10n.bookmarks_title), findsOneWidget); + + await tester.tap(find.text(_l10n.bookmarks_title)); + await _pumpFrames(tester); + + expect(find.byType(BookmarksScreen), findsOneWidget); + expect(_segmentByText(_l10n.listFilter_all), findsOneWidget); + expect(_segmentByText('Maya'), findsOneWidget); + expect(find.text('Direct message bookmarked note'), findsOneWidget); + expect(find.text('Public channel bookmarked note'), findsNothing); + + await tester.pumpWidget(const SizedBox()); + await tester.pump(const Duration(minutes: 1)); + }, + ); + + testWidgets( + 'Search in BookmarksScreen finds matching bookmarks and jumping scrolls to and highlights offscreen target card', + (tester) async { + final env = await _createEnv(tester); + 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); + + await tester.enterText(find.byType(TextField), 'solar'); + await tester.pump(const Duration(milliseconds: 350)); + await _pumpFrames(tester); + + expect( + find.textContaining('Oldest offscreen solar telemetry beacon check #1'), + findsOneWidget, + ); + expect( + find.textContaining('Recent repeater status update #25'), + findsNothing, + ); + + // 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. + await tester.pump(const Duration(seconds: 3)); + expect(find.byType(AnimatedContainer), findsNothing); + + await tester.pumpWidget(const SizedBox()); + await tester.pump(const Duration(minutes: 1)); + }, + ); + + testWidgets( + 'Single removal and bulk removal in BookmarksScreen show confirmation AlertDialog', + (tester) async { + final env = await _createEnv(tester); + final b1 = BookmarkedMessage( + sourceType: BookmarkSourceType.channel, + sourceId: 'slot:0', + sourceName: 'Public', + messageId: 'm1', + senderName: 'Sam', + text: 'First bookmarked message', + timestamp: DateTime(2026, 1, 1, 9), + receivedAt: DateTime(2026, 1, 1, 9), + isOutgoing: false, + ); + final b2 = BookmarkedMessage( + sourceType: BookmarkSourceType.channel, + sourceId: 'slot:0', + sourceName: 'Public', + messageId: 'm2', + senderName: 'Maya', + text: 'Second bookmarked message', + timestamp: DateTime(2026, 1, 1, 10), + receivedAt: DateTime(2026, 1, 1, 10), + isOutgoing: false, + ); + final b3 = BookmarkedMessage( + sourceType: BookmarkSourceType.contact, + sourceId: 'contact-1', + sourceName: 'Maya', + messageId: 'm3', + senderName: 'Maya', + text: 'Third bookmarked message', + timestamp: DateTime(2026, 1, 1, 11), + receivedAt: DateTime(2026, 1, 1, 11), + isOutgoing: false, + ); + + await _pumpFuture( + tester, + env.connector.setBookmarkedMessage(b1, isBookmarked: true), + ); + await _pumpFuture( + tester, + env.connector.setBookmarkedMessage(b2, isBookmarked: true), + ); + await _pumpFuture( + tester, + env.connector.setBookmarkedMessage(b3, isBookmarked: true), + ); + + await tester.pumpWidget(env.wrap(const BookmarksScreen())); + await _pumpFrames(tester); + + expect(find.text('Third bookmarked message'), findsOneWidget); + + // 1. Single remove -> Cancel keeps bookmark intact. + await tester.tap(find.byIcon(Icons.bookmark_remove_outlined).first); + await _pumpFrames(tester); + + expect(find.byType(AlertDialog), findsOneWidget); + expect(find.text(_l10n.bookmarks_removeConfirmTitle), findsOneWidget); + expect(find.text(_l10n.bookmarks_removeConfirmMessage), findsOneWidget); + + await tester.tap(find.text(_l10n.common_cancel)); + await _pumpFrames(tester); + expect(find.byType(AlertDialog), findsNothing); + expect(find.text('Third bookmarked message'), findsOneWidget); + + // 2. Single remove -> Confirm removes bookmark. + await tester.tap(find.byIcon(Icons.bookmark_remove_outlined).first); + await _pumpFrames(tester); + await tester.tap(find.text(_l10n.common_remove)); + await _pumpFrames(tester); + + expect(find.text('Third bookmarked message'), findsNothing); + expect(find.text('Second bookmarked message'), findsOneWidget); + expect(find.text('First bookmarked message'), findsOneWidget); + + // 3. Long-press to enter bulk selection mode and select both remaining bookmarks. + await tester.longPress(find.text('Second bookmarked message')); + await _pumpFrames(tester); + + expect(find.text(_l10n.chat_selectedCount(1)), findsOneWidget); + await tester.tap( + find.text('First bookmarked message'), + warnIfMissed: false, + ); + await _pumpFrames(tester); + expect(find.text(_l10n.chat_selectedCount(2)), findsOneWidget); + + // Tap bulk delete icon -> Cancel keeps both bookmarks. + await tester.tap(find.byIcon(Icons.delete_outline)); + await _pumpFrames(tester); + + expect(find.byType(AlertDialog), findsOneWidget); + expect( + find.text(_l10n.bookmarks_removeSelectedConfirmTitle), + findsOneWidget, + ); + expect( + find.text(_l10n.bookmarks_removeSelectedConfirmMessage(2)), + findsOneWidget, + ); + + await tester.tap(find.text(_l10n.common_cancel)); + await _pumpFrames(tester); + expect(find.text('Second bookmarked message'), findsOneWidget); + expect(find.text('First bookmarked message'), findsOneWidget); + + // Tap bulk delete icon -> Confirm removes selected bookmarks. + await tester.tap(find.byIcon(Icons.delete_outline)); + await _pumpFrames(tester); + await tester.tap(find.text(_l10n.common_remove)); + await _pumpFrames(tester); + + expect(find.text(_l10n.bookmarks_empty), findsOneWidget); + + await tester.pumpWidget(const SizedBox()); + await tester.pump(const Duration(minutes: 1)); + }, + ); + + testWidgets( + 'ChannelChatScreen bulk selection bookmarks selected messages and in-chat remove prompts for confirmation', + (tester) async { + final env = await _createEnv(tester); + final channel = env.connector.channels.firstWhere( + (c) => c.name == 'Hiking Group', + ); + + await tester.pumpWidget(env.wrap(ChannelChatScreen(channel: channel))); + await _pumpFrames(tester); + + final messages = env.connector.getChannelMessages(channel); + expect(messages.length, greaterThanOrEqualTo(2)); + final firstMsg = messages[messages.length - 1]; + final secondMsg = messages[messages.length - 2]; + + Future longPressBubble(String text) async { + final bubble = find.ancestor( + of: find.text(text), + matching: find.byType(MessageBubbleFrame), + ); + await tester.longPressAt( + tester.getTopLeft(bubble) + const Offset(8, 8), + ); + await _pumpFrames(tester); + } + + // Long-press newest message to open action sheet -> Select messages + await longPressBubble(firstMsg.text); + + await tester.tap(find.text(_l10n.chat_selectMessages)); + await _pumpFrames(tester); + + // Select second message too + await tester.tap(find.text(secondMsg.text), warnIfMissed: false); + await _pumpFrames(tester); + expect(find.text(_l10n.chat_selectedCount(2)), findsOneWidget); + + // Tap bulk Bookmark action in selection AppBar + final bookmarkBtn = find.byTooltip(_l10n.chat_bookmark); + expect(bookmarkBtn, findsOneWidget); + await tester.tap(bookmarkBtn); + await _pumpFrames(tester); + + final saved = await _pumpFuture( + tester, + env.connector.loadBookmarkedMessages(), + ); + expect(saved, hasLength(2)); + + // Now long-press the bookmarked message in ChannelChatScreen and tap "Remove bookmark" + await longPressBubble(firstMsg.text); + expect(find.text(_l10n.chat_removeBookmark), findsOneWidget); + + await tester.tap(find.text(_l10n.chat_removeBookmark)); + await _pumpFrames(tester); + + // Confirmation dialog appears + expect(find.byType(AlertDialog), findsOneWidget); + expect(find.text(_l10n.bookmarks_removeConfirmTitle), findsOneWidget); + + // Cancel keeps it bookmarked + await tester.tap(find.text(_l10n.common_cancel)); + await _pumpFrames(tester); + expect( + await _pumpFuture(tester, env.connector.loadBookmarkedMessages()), + hasLength(2), + ); + + // Confirm removes the bookmark + await longPressBubble(firstMsg.text); + await tester.tap(find.text(_l10n.chat_removeBookmark)); + await _pumpFrames(tester); + await tester.tap(find.text(_l10n.common_remove)); + await _pumpFrames(tester); + + expect( + await _pumpFuture(tester, env.connector.loadBookmarkedMessages()), + hasLength(1), + ); + + // Also verify ChatScreen (direct message) bookmark removal confirmation dialog + final contact = env.connector.contacts.firstWhere( + (c) => c.name == 'Maya', + ); + await tester.pumpWidget(env.wrap(ChatScreen(contact: contact))); + await _pumpFrames(tester); + + final dmMessages = env.connector.getMessages(contact); + expect(dmMessages, isNotEmpty); + final dmMsg = dmMessages.last; + + // Bookmark the DM first + await longPressBubble(dmMsg.text); + await tester.tap(find.text(_l10n.chat_bookmark)); + await _pumpFrames(tester); + expect( + await _pumpFuture(tester, env.connector.loadBookmarkedMessages()), + hasLength(2), + ); + + // Long-press and tap Remove bookmark -> Cancel keeps it + await longPressBubble(dmMsg.text); + await tester.tap(find.text(_l10n.chat_removeBookmark)); + await _pumpFrames(tester); + expect(find.byType(AlertDialog), findsOneWidget); + await tester.tap(find.text(_l10n.common_cancel)); + await _pumpFrames(tester); + expect( + await _pumpFuture(tester, env.connector.loadBookmarkedMessages()), + hasLength(2), + ); + + // Confirm removes it + await longPressBubble(dmMsg.text); + await tester.tap(find.text(_l10n.chat_removeBookmark)); + await _pumpFrames(tester); + await tester.tap(find.text(_l10n.common_remove)); + await _pumpFrames(tester); + expect( + await _pumpFuture(tester, env.connector.loadBookmarkedMessages()), + hasLength(1), + ); + + await tester.pumpWidget(const SizedBox()); + await tester.pump(const Duration(minutes: 1)); + }, + ); + + group('BookmarksScreen fits 320dp at 1.3x and 2.0x text scale', () { + for (final scale in [1.3, 2.0]) { + testWidgets('no layout overflow at 320dp and ${scale}x text scale', ( + tester, + ) async { + tester.view.physicalSize = const Size(320, 568); + tester.view.devicePixelRatio = 1.0; + addTearDown(tester.view.reset); + + final env = await _createEnv(tester); + final channel = env.connector.channels.firstWhere( + (c) => c.name == 'Hiking Group', + ); + await _pumpFuture( + tester, + env.connector.setBookmarkedMessage( + BookmarkedMessage( + sourceType: BookmarkSourceType.channel, + sourceId: channel.storageId ?? 'slot:${channel.index}', + sourceName: channel.name, + messageId: 'scale-msg-1', + senderName: 'Ranger Pat', + text: + 'Checking layout on 320dp screen with large text scale enabled.', + timestamp: DateTime(2026, 1, 1, 12), + receivedAt: DateTime(2026, 1, 1, 12), + isOutgoing: false, + ), + isBookmarked: true, + ), + ); + + final overflows = []; + final previous = FlutterError.onError; + FlutterError.onError = (details) { + final text = details.exceptionAsString(); + if (!text.contains('overflowed')) { + previous?.call(details); + return; + } + overflows.add(text.split('\n').first); + }; + addTearDown(() => FlutterError.onError = previous); + + await tester.pumpWidget( + env.wrap( + BookmarksScreen( + initialSourceType: BookmarkSourceType.channel, + initialSourceId: channel.storageId ?? 'slot:${channel.index}', + sourceIdAliases: [?channel.storageId, 'slot:${channel.index}'], + initialSourceName: '#${channel.name}', + ), + textScale: scale, + ), + ); + await _pumpFrames(tester); + + // Enter bulk selection mode and open remove confirmation dialog at scale + await tester.longPress( + find.textContaining('Checking layout on 320dp screen'), + ); + await _pumpFrames(tester); + await tester.tap(find.byIcon(Icons.delete_outline)); + await _pumpFrames(tester); + await tester.tap(find.text(_l10n.common_cancel)); + await _pumpFrames(tester); + + await tester.pumpWidget(const SizedBox()); + await tester.pump(const Duration(minutes: 1)); + FlutterError.onError = previous; + + expect(overflows, isEmpty, reason: overflows.join('\n')); + }); + } + }); +} diff --git a/test/screens/main_overflow_menus_test.dart b/test/screens/main_overflow_menus_test.dart index 51a2e7d5..3f9ff767 100644 --- a/test/screens/main_overflow_menus_test.dart +++ b/test/screens/main_overflow_menus_test.dart @@ -373,6 +373,7 @@ void main() { expect(_openMenuEntries(tester), [ _l10n.addContact_title, _l10n.discoveredContacts_Title, + _l10n.bookmarks_title, '---', _l10n.contacts_zeroHopAdvert, _l10n.contacts_floodAdvert, @@ -387,6 +388,7 @@ void main() { _menuItemByLabel(_l10n.discoveredContacts_Title).enabled, isTrue, ); + expect(_menuItemByLabel(_l10n.bookmarks_title).enabled, isTrue); expect( _menuItemByLabel(_l10n.contacts_zeroHopAdvert).enabled, connected, diff --git a/untranslated.json b/untranslated.json index 54058ad7..309eb1ec 100644 --- a/untranslated.json +++ b/untranslated.json @@ -1,96 +1,191 @@ { "bg": [ + "bookmarks_removeConfirmTitle", + "bookmarks_removeConfirmMessage", + "bookmarks_removeSelectedConfirmTitle", + "bookmarks_removeSelectedConfirmMessage", "chat_resendSelectedTitle", - "chat_resendSelectedConfirm" + "chat_resendSelectedConfirm", + "messageUrlImageLoadFailed" ], "cs": [ + "bookmarks_removeConfirmTitle", + "bookmarks_removeConfirmMessage", + "bookmarks_removeSelectedConfirmTitle", + "bookmarks_removeSelectedConfirmMessage", "chat_resendSelectedTitle", - "chat_resendSelectedConfirm" + "chat_resendSelectedConfirm", + "messageUrlImageLoadFailed" ], "de": [ + "bookmarks_removeConfirmTitle", + "bookmarks_removeConfirmMessage", + "bookmarks_removeSelectedConfirmTitle", + "bookmarks_removeSelectedConfirmMessage", "chat_resendSelectedTitle", - "chat_resendSelectedConfirm" + "chat_resendSelectedConfirm", + "messageUrlImageLoadFailed" ], "es": [ + "bookmarks_removeConfirmTitle", + "bookmarks_removeConfirmMessage", + "bookmarks_removeSelectedConfirmTitle", + "bookmarks_removeSelectedConfirmMessage", "chat_resendSelectedTitle", - "chat_resendSelectedConfirm" + "chat_resendSelectedConfirm", + "messageUrlImageLoadFailed" ], "fr": [ + "bookmarks_removeConfirmTitle", + "bookmarks_removeConfirmMessage", + "bookmarks_removeSelectedConfirmTitle", + "bookmarks_removeSelectedConfirmMessage", "chat_resendSelectedTitle", - "chat_resendSelectedConfirm" + "chat_resendSelectedConfirm", + "messageUrlImageLoadFailed" ], "hu": [ + "bookmarks_removeConfirmTitle", + "bookmarks_removeConfirmMessage", + "bookmarks_removeSelectedConfirmTitle", + "bookmarks_removeSelectedConfirmMessage", "chat_resendSelectedTitle", - "chat_resendSelectedConfirm" + "chat_resendSelectedConfirm", + "messageUrlImageLoadFailed" ], "it": [ + "bookmarks_removeConfirmTitle", + "bookmarks_removeConfirmMessage", + "bookmarks_removeSelectedConfirmTitle", + "bookmarks_removeSelectedConfirmMessage", "chat_resendSelectedTitle", - "chat_resendSelectedConfirm" + "chat_resendSelectedConfirm", + "messageUrlImageLoadFailed" ], "ja": [ + "bookmarks_removeConfirmTitle", + "bookmarks_removeConfirmMessage", + "bookmarks_removeSelectedConfirmTitle", + "bookmarks_removeSelectedConfirmMessage", "chat_resendSelectedTitle", - "chat_resendSelectedConfirm" + "chat_resendSelectedConfirm", + "messageUrlImageLoadFailed" ], "ko": [ + "bookmarks_removeConfirmTitle", + "bookmarks_removeConfirmMessage", + "bookmarks_removeSelectedConfirmTitle", + "bookmarks_removeSelectedConfirmMessage", "chat_resendSelectedTitle", - "chat_resendSelectedConfirm" + "chat_resendSelectedConfirm", + "messageUrlImageLoadFailed" ], "nl": [ + "bookmarks_removeConfirmTitle", + "bookmarks_removeConfirmMessage", + "bookmarks_removeSelectedConfirmTitle", + "bookmarks_removeSelectedConfirmMessage", "chat_resendSelectedTitle", - "chat_resendSelectedConfirm" + "chat_resendSelectedConfirm", + "messageUrlImageLoadFailed" ], "pl": [ + "bookmarks_removeConfirmTitle", + "bookmarks_removeConfirmMessage", + "bookmarks_removeSelectedConfirmTitle", + "bookmarks_removeSelectedConfirmMessage", "chat_resendSelectedTitle", - "chat_resendSelectedConfirm" + "chat_resendSelectedConfirm", + "messageUrlImageLoadFailed" ], "pt": [ + "bookmarks_removeConfirmTitle", + "bookmarks_removeConfirmMessage", + "bookmarks_removeSelectedConfirmTitle", + "bookmarks_removeSelectedConfirmMessage", "chat_resendSelectedTitle", - "chat_resendSelectedConfirm" + "chat_resendSelectedConfirm", + "messageUrlImageLoadFailed" ], "pt_PT": [ + "bookmarks_removeConfirmTitle", + "bookmarks_removeConfirmMessage", + "bookmarks_removeSelectedConfirmTitle", + "bookmarks_removeSelectedConfirmMessage", "chat_resendSelectedTitle", - "chat_resendSelectedConfirm" + "chat_resendSelectedConfirm", + "messageUrlImageLoadFailed" ], "ru": [ + "bookmarks_removeConfirmTitle", + "bookmarks_removeConfirmMessage", + "bookmarks_removeSelectedConfirmTitle", + "bookmarks_removeSelectedConfirmMessage", "chat_resendSelectedTitle", - "chat_resendSelectedConfirm" + "chat_resendSelectedConfirm", + "messageUrlImageLoadFailed" ], "sk": [ + "bookmarks_removeConfirmTitle", + "bookmarks_removeConfirmMessage", + "bookmarks_removeSelectedConfirmTitle", + "bookmarks_removeSelectedConfirmMessage", "chat_resendSelectedTitle", - "chat_resendSelectedConfirm" + "chat_resendSelectedConfirm", + "messageUrlImageLoadFailed" ], "sl": [ + "bookmarks_removeConfirmTitle", + "bookmarks_removeConfirmMessage", + "bookmarks_removeSelectedConfirmTitle", + "bookmarks_removeSelectedConfirmMessage", "chat_resendSelectedTitle", - "chat_resendSelectedConfirm" + "chat_resendSelectedConfirm", + "messageUrlImageLoadFailed" ], "sv": [ + "bookmarks_removeConfirmTitle", + "bookmarks_removeConfirmMessage", + "bookmarks_removeSelectedConfirmTitle", + "bookmarks_removeSelectedConfirmMessage", "chat_resendSelectedTitle", - "chat_resendSelectedConfirm" + "chat_resendSelectedConfirm", + "messageUrlImageLoadFailed" ], "uk": [ + "bookmarks_removeConfirmTitle", + "bookmarks_removeConfirmMessage", + "bookmarks_removeSelectedConfirmTitle", + "bookmarks_removeSelectedConfirmMessage", "chat_resendSelectedTitle", - "chat_resendSelectedConfirm" + "chat_resendSelectedConfirm", + "messageUrlImageLoadFailed" ], "zh": [ + "bookmarks_removeConfirmTitle", + "bookmarks_removeConfirmMessage", + "bookmarks_removeSelectedConfirmTitle", + "bookmarks_removeSelectedConfirmMessage", "chat_resendSelectedTitle", - "chat_resendSelectedConfirm" + "chat_resendSelectedConfirm", + "messageUrlImageLoadFailed" ] }