- Czech UI locale (app_cs.arb), selectable in the language picker and as a message translation language; language names added to every locale. - Fix wrong language names: Slovak shown as Slovenian in it/ja/pt/sl, garbled Slovak/Bulgarian in pl, Ukrainian in ru, Hungarian in ko/zh. - Search inside DM and channel chats across the full stored history, with highlighted matches; filtered channel messages are excluded. - Path trace by typed hashes (e.g. A1,B2,C3) from the Contacts and map menus, without needing node locations; the map trace panel can hand its hops to it. - Share contacts in chats using the official app's <pubkey:type:name> format; received cards have a one-tap Add contact button that reuses the QR card import path. - Translations for all new strings in every locale; docs updated.
46 lines
1.3 KiB
Dart
46 lines
1.3 KiB
Dart
/// One searchable message, independent of DM or channel model.
|
|
class ChatSearchEntry {
|
|
final String id;
|
|
final String sender;
|
|
final String text;
|
|
final String? translatedText;
|
|
final DateTime time;
|
|
|
|
/// Whether [sender] is part of the searchable text (channels only).
|
|
final bool matchSender;
|
|
|
|
const ChatSearchEntry({
|
|
required this.id,
|
|
required this.sender,
|
|
required this.text,
|
|
required this.time,
|
|
this.translatedText,
|
|
this.matchSender = false,
|
|
});
|
|
}
|
|
|
|
String normalizeSearchQuery(String query) => query.trim().toLowerCase();
|
|
|
|
bool searchEntryMatches(ChatSearchEntry entry, String query) {
|
|
final needle = normalizeSearchQuery(query);
|
|
if (needle.isEmpty) return false;
|
|
if (entry.text.toLowerCase().contains(needle)) return true;
|
|
final translated = entry.translatedText;
|
|
if (translated != null && translated.toLowerCase().contains(needle)) {
|
|
return true;
|
|
}
|
|
return entry.matchSender && entry.sender.toLowerCase().contains(needle);
|
|
}
|
|
|
|
/// Matches for [query], newest first. [entries] must be oldest first.
|
|
List<ChatSearchEntry> searchEntries(
|
|
List<ChatSearchEntry> entries,
|
|
String query,
|
|
) {
|
|
if (normalizeSearchQuery(query).isEmpty) return const [];
|
|
return [
|
|
for (final entry in entries.reversed)
|
|
if (searchEntryMatches(entry, query)) entry,
|
|
];
|
|
}
|