Fix review findings in channel notification modes

- Detect mentions on the original text, as @[name] or a whole-word @name
- Save and restore the full mode map in review mode
- Open the mode picker from the chat bell and show the mode in its tooltip
- Share one mode picker sheet; fix the stale sheet context
- Persist modes by name and skip unknown entries
- Keep writing muted_channels so older builds keep the user's mutes
- Remove the muteChannel/unmuteChannel/isChannelMuted shims
- Update notifications docs to match the behaviour
This commit is contained in:
zjs81 committed 2026-10-24 20:46:49 -07:00
1 parent 705bff2f15
commit f667320608
32 files changed
+502 -196

No files matched your search

+6 -16
View File
@@ -37,6 +37,7 @@ import '../utils/image_save.dart';
import '../utils/lora_airtime.dart';
import '../widgets/marker_label_dialog.dart';
import '../widgets/received_image_message.dart';
import '../widgets/channel_notification_mode_sheet.dart';
import '../widgets/chat_day_separator.dart';
import '../widgets/empty_state.dart';
@@ -408,7 +409,9 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
muteKey,
);
return IconButton(
tooltip: context.l10n.channels_notificationSettings,
tooltip: context.l10n.channels_notificationModeTooltip(
channelNotificationModeLabel(context, notificationMode),
),
icon: Icon(
notificationMode == ChannelNotificationMode.muted
? Icons.notifications_off
@@ -416,21 +419,8 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
? Icons.notification_important
: Icons.notifications,
),
onPressed: () {
final currentMode = settings.getChannelNotificationMode(
muteKey,
);
ChannelNotificationMode newMode;
if (currentMode == ChannelNotificationMode.all) {
newMode = ChannelNotificationMode.mentionsOnly;
} else if (currentMode ==
ChannelNotificationMode.mentionsOnly) {
newMode = ChannelNotificationMode.muted;
} else {
newMode = ChannelNotificationMode.all;
}
settings.setChannelNotificationMode(muteKey, newMode);
},
onPressed: () =>
showChannelNotificationModeSheet(context, muteKey),
);
},
),
+10 -82
View File
@@ -20,6 +20,7 @@ import '../theme/mesh_theme.dart';
import '../utils/dialog_utils.dart';
import '../utils/disconnect_navigation_mixin.dart';
import '../utils/route_transitions.dart';
import '../widgets/channel_notification_mode_sheet.dart';
import '../widgets/list_filter_widget.dart';
import '../widgets/empty_state.dart';
import '../widgets/mesh_ui.dart';
@@ -583,9 +584,7 @@ class _ChannelsScreenState extends State<ChannelsScreen>
children: [
if (notificationMode != ChannelNotificationMode.all) ...[
Icon(
notificationMode == ChannelNotificationMode.muted
? Icons.notifications_off
: Icons.notification_important,
channelNotificationModeIcon(notificationMode),
size: 18,
color: scheme.onSurfaceVariant,
),
@@ -651,9 +650,15 @@ class _ChannelsScreenState extends State<ChannelsScreen>
leading: const Icon(Icons.notifications_outlined),
title: Text(sheetContext.l10n.channels_notificationSettings),
trailing: const Icon(Icons.chevron_right),
onTap: () {
onTap: () async {
Navigator.pop(sheetContext);
_showNotificationModeDialog(sheetContext, connector, channel);
await Future.delayed(const Duration(milliseconds: 100));
if (parentContext.mounted) {
showChannelNotificationModeSheet(
parentContext,
channel.muteKey,
);
}
},
),
ListTile(
@@ -681,83 +686,6 @@ class _ChannelsScreenState extends State<ChannelsScreen>
);
}
void _showNotificationModeDialog(
BuildContext context,
MeshCoreConnector connector,
Channel channel,
) {
final settingsService = context.read<AppSettingsService>();
final currentMode = settingsService.getChannelNotificationMode(
channel.muteKey,
);
showMeshSheet(
context,
builder: (sheetContext) => SafeArea(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// All notifications
ListTile(
leading: Icon(
Icons.notifications,
color: currentMode == ChannelNotificationMode.all
? Theme.of(sheetContext).colorScheme.primary
: Theme.of(sheetContext).colorScheme.onSurfaceVariant,
),
title: Text(sheetContext.l10n.channels_notifyAll),
trailing: currentMode == ChannelNotificationMode.all
? const Icon(Icons.check)
: null,
onTap: () async {
Navigator.pop(sheetContext);
await settingsService.setChannelNotificationMode(
channel.muteKey,
ChannelNotificationMode.all,
);
},
),
// Mentions only
ListTile(
leading: const Icon(Icons.notification_important),
title: Text(sheetContext.l10n.channels_notifyMentionsOnly),
trailing: currentMode == ChannelNotificationMode.mentionsOnly
? const Icon(Icons.check)
: null,
onTap: () async {
Navigator.pop(sheetContext);
await settingsService.setChannelNotificationMode(
channel.muteKey,
ChannelNotificationMode.mentionsOnly,
);
},
),
// Muted
ListTile(
leading: Icon(
Icons.notifications_off,
color: currentMode == ChannelNotificationMode.muted
? Theme.of(sheetContext).colorScheme.primary
: Theme.of(sheetContext).colorScheme.onSurfaceVariant,
),
title: Text(sheetContext.l10n.channels_notifyNone),
trailing: currentMode == ChannelNotificationMode.muted
? const Icon(Icons.check)
: null,
onTap: () async {
Navigator.pop(sheetContext);
await settingsService.setChannelNotificationMode(
channel.muteKey,
ChannelNotificationMode.muted,
);
},
),
],
),
),
);
}
void _handleQuickSwitch(int index, BuildContext context) {
if (index == 1) return;
switch (index) {