Routing - Auto routing picks routes by Thompson sampling over faded delivery stats (24 h half-life, capped evidence), weighted by what the radio currently hears; retries prefer a different route; last attempt floods. - Route failures are held until a message's fate is known, so an offline contact no longer wrecks its route history; failing routes are only deleted after a week without a delivery. - Direct (zero-hop) path is a rotation candidate (#643) and a new Direct mode in the routing sheet; history routes are used for repeater logins. - Remove the route-weight sliders the new chooser no longer uses. Chats - Bulk selection in channel chats (spam / not spam / delete / copy) and in the Filtered messages list. - Tapping a search result jumps to the message. - Swipe-to-reply ignores vertical scrolls. - Active conversation follows route lifecycle, so covered chats count unread again. Notifications - Tapping a notification opens its conversation. - Per-conversation coalescing and one alert per queued-message sync. - Monochrome status-bar icon; background service stops when the app is swiped away; stale notifications cleared on radio or slot change. Other - Online map: opaque links and painted dots for dense areas to avoid an Impeller GPU crash; expandable hop list on path maps. - Contact share: clipboard import of shared contacts, "Add again". - Android: enableEdgeToEdge and scrolling-screenshot support. - Translations for all new strings; fix mistranslated routing labels.
79 lines
2.5 KiB
Dart
79 lines
2.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../connector/meshcore_connector.dart';
|
|
import '../connector/meshcore_protocol.dart';
|
|
import '../screens/channel_chat_screen.dart';
|
|
import '../screens/chat_screen.dart';
|
|
import 'notification_service.dart';
|
|
|
|
/// Opens the conversation behind a tapped message notification instead of
|
|
/// leaving the user on whatever screen they last had open.
|
|
///
|
|
/// Only acts while a radio is connected: chats need its contacts/channels, and
|
|
/// a cold start goes through the scanner anyway, so a stale tap is dropped.
|
|
class NotificationNavigator {
|
|
final GlobalKey<NavigatorState> navigatorKey;
|
|
final MeshCoreConnector connector;
|
|
final NotificationService notifications;
|
|
|
|
NotificationNavigator({
|
|
required this.navigatorKey,
|
|
required this.connector,
|
|
required this.notifications,
|
|
});
|
|
|
|
void attach() {
|
|
notifications.pendingTap.addListener(_handleTap);
|
|
_handleTap();
|
|
}
|
|
|
|
void dispose() {
|
|
notifications.pendingTap.removeListener(_handleTap);
|
|
}
|
|
|
|
void _handleTap() {
|
|
final payload = notifications.pendingTap.value;
|
|
if (payload == null) return;
|
|
notifications.pendingTap.value = null;
|
|
final navigator = navigatorKey.currentState;
|
|
if (navigator == null || !connector.isConnected) return;
|
|
|
|
final sep = payload.indexOf(':');
|
|
if (sep <= 0) return;
|
|
final kind = payload.substring(0, sep);
|
|
final value = payload.substring(sep + 1);
|
|
|
|
if (kind == 'message') {
|
|
if (connector.activeContactKey == value) return;
|
|
final contact = connector.getContactByPubKeyHex(value);
|
|
if (contact == null ||
|
|
(contact.type != advTypeChat && contact.type != advTypeRoom)) {
|
|
return;
|
|
}
|
|
final unread = connector.getUnreadCountForContactKey(value);
|
|
connector.markContactRead(value);
|
|
navigator.push(
|
|
MaterialPageRoute(
|
|
builder: (_) =>
|
|
ChatScreen(contact: contact, initialUnreadCount: unread),
|
|
),
|
|
);
|
|
} else if (kind == 'channel') {
|
|
final index = int.tryParse(value);
|
|
if (index == null || connector.activeChannelIndex == index) return;
|
|
final channel = connector.channels
|
|
.where((c) => c.index == index)
|
|
.firstOrNull;
|
|
if (channel == null) return;
|
|
final unread = connector.getUnreadCountForChannelIndex(index);
|
|
connector.markChannelRead(index);
|
|
navigator.push(
|
|
MaterialPageRoute(
|
|
builder: (_) =>
|
|
ChannelChatScreen(channel: channel, initialUnreadCount: unread),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
}
|