feat: add per-channel notification modes (all/mentions only/muted)
- Add ChannelNotificationMode enum with all, mentionsOnly, muted options - Replace mutedChannels Set with channelNotificationModes Map for per-channel settings - Add mention detection for @username in channel messages - Update channels list and chat UI with notification mode selector - Add localization strings for new notification modes - Automatic migration from old mutedChannels to new system - Update user documentation - Preserve backward compatibility with existing mute/unmute API
This commit is contained in:
1 parent
caee4d5c19
commit
caad3dd703
29 files changed
+647
-66
No files matched your search
@@ -99,15 +99,23 @@ Access via **App Settings → Notifications**:
|
|||||||
| Channel Message Notifications | On | Channel alerts (greyed out if master is off) |
|
| Channel Message Notifications | On | Channel alerts (greyed out if master is off) |
|
||||||
| Advertisement Notifications | On | New node alerts (greyed out if master is off) |
|
| Advertisement Notifications | On | New node alerts (greyed out if master is off) |
|
||||||
|
|
||||||
### Per-Channel Muting
|
### Per-Channel Notification Modes
|
||||||
|
|
||||||
Mute or unmute a channel from any of these places. Muted channels do not generate OS notifications.
|
Each channel supports three notification modes:
|
||||||
|
|
||||||
- The bell icon in the channel chat app bar
|
| Mode | Icon | Behavior |
|
||||||
- Long-press a channel in the channels list → "Mute channel" / "Unmute channel"
|
|---|---|---|
|
||||||
- **Mute channel** on a channel notification (Android)
|
| **All messages** | 🔔 | Receive notifications for every message |
|
||||||
|
| **Mentions only (@)** | @ | Only notify when someone mentions you with "@yourname" |
|
||||||
|
| **Muted** | 🔇 | No notifications |
|
||||||
|
|
||||||
There is no per-contact muting.
|
Set the mode from:
|
||||||
|
|
||||||
|
- The notifications icon in the channel chat app bar (tap to cycle through modes)
|
||||||
|
- Long-press a channel in the channels list → **Notification settings** → select mode
|
||||||
|
- Channel notification actions (Android)
|
||||||
|
|
||||||
|
Mentions are detected by looking for "@" followed by your username at word boundaries. The comparison is case-insensitive.
|
||||||
|
|
||||||
## Rate Limiting
|
## Rate Limiting
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,8 @@ import '../services/image_codec_service.dart';
|
|||||||
import '../services/received_image_store.dart';
|
import '../services/received_image_store.dart';
|
||||||
import '../services/message_retry_service.dart';
|
import '../services/message_retry_service.dart';
|
||||||
import '../services/path_history_service.dart';
|
import '../services/path_history_service.dart';
|
||||||
import '../services/app_settings_service.dart';
|
import '../services/app_settings_service.dart'
|
||||||
|
show AppSettingsService, ChannelNotificationMode;
|
||||||
import '../services/background_service.dart';
|
import '../services/background_service.dart';
|
||||||
import '../services/timeout_prediction_service.dart';
|
import '../services/timeout_prediction_service.dart';
|
||||||
import '../services/translation_service.dart';
|
import '../services/translation_service.dart';
|
||||||
@@ -7353,7 +7354,12 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final label = channelName ?? _channelDisplayName(channelIndex);
|
final label = channelName ?? _channelDisplayName(channelIndex);
|
||||||
if (_appSettingsService!.isChannelMuted(label)) return;
|
final notificationMode = _appSettingsService!.getChannelNotificationMode(
|
||||||
|
label,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Check if channel is muted
|
||||||
|
if (notificationMode == ChannelNotificationMode.muted) return;
|
||||||
|
|
||||||
// Reuse translation result only if completed and non-empty; else use original text
|
// Reuse translation result only if completed and non-empty; else use original text
|
||||||
final resolvedText =
|
final resolvedText =
|
||||||
@@ -7362,6 +7368,12 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||||||
translationResult.translatedText.trim().isNotEmpty)
|
translationResult.translatedText.trim().isNotEmpty)
|
||||||
? translationResult.translatedText.trim()
|
? translationResult.translatedText.trim()
|
||||||
: message.text.trim();
|
: message.text.trim();
|
||||||
|
|
||||||
|
// If mode is mentionsOnly, check if message mentions us
|
||||||
|
if (notificationMode == ChannelNotificationMode.mentionsOnly) {
|
||||||
|
if (!_doesMessageMentionUs(resolvedText)) return;
|
||||||
|
}
|
||||||
|
|
||||||
unawaited(() async {
|
unawaited(() async {
|
||||||
await _notificationService.showChannelMessageNotification(
|
await _notificationService.showChannelMessageNotification(
|
||||||
channelName: label,
|
channelName: label,
|
||||||
@@ -7374,6 +7386,22 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||||||
}());
|
}());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Checks if a message text mentions the current user.
|
||||||
|
/// Looks for "@username" pattern where username matches our self name.
|
||||||
|
bool _doesMessageMentionUs(String messageText) {
|
||||||
|
final selfName = _selfName;
|
||||||
|
if (selfName == null || selfName.isEmpty) return false;
|
||||||
|
|
||||||
|
// Check for @username at word boundaries (start of message or after whitespace)
|
||||||
|
// Case-insensitive comparison
|
||||||
|
final lowerSelfName = selfName.toLowerCase();
|
||||||
|
final lowerMessage = messageText.toLowerCase();
|
||||||
|
final mentionPattern = RegExp(
|
||||||
|
r'\b@(' + RegExp.escape(lowerSelfName) + r')\b',
|
||||||
|
);
|
||||||
|
return mentionPattern.hasMatch(lowerMessage);
|
||||||
|
}
|
||||||
|
|
||||||
/// Handles RESP_CODE_CHANNEL_DATA_RECV (GRP_DATA). Frames whose dataType is
|
/// Handles RESP_CODE_CHANNEL_DATA_RECV (GRP_DATA). Frames whose dataType is
|
||||||
/// not 0xAE1C — or that arrive before an [ImageChunkTransport] is installed —
|
/// not 0xAE1C — or that arrive before an [ImageChunkTransport] is installed —
|
||||||
/// are ignored without disturbing any other behaviour.
|
/// are ignored without disturbing any other behaviour.
|
||||||
|
|||||||
@@ -715,6 +715,10 @@
|
|||||||
"channels_addSectionCreate": "Create new",
|
"channels_addSectionCreate": "Create new",
|
||||||
"channels_dragToReorder": "Drag to reorder",
|
"channels_dragToReorder": "Drag to reorder",
|
||||||
"channels_editChannel": "Edit channel",
|
"channels_editChannel": "Edit channel",
|
||||||
|
"channels_notificationSettings": "Notification settings",
|
||||||
|
"channels_notifyAll": "All messages",
|
||||||
|
"channels_notifyMentionsOnly": "Mentions only (@)",
|
||||||
|
"channels_notifyNone": "Muted",
|
||||||
"channels_muteChannel": "Mute channel",
|
"channels_muteChannel": "Mute channel",
|
||||||
"channels_unmuteChannel": "Unmute channel",
|
"channels_unmuteChannel": "Unmute channel",
|
||||||
"channels_deleteChannel": "Delete channel",
|
"channels_deleteChannel": "Delete channel",
|
||||||
|
|||||||
@@ -369,6 +369,10 @@
|
|||||||
"channels_public": "Public",
|
"channels_public": "Public",
|
||||||
"channels_private": "Privé",
|
"channels_private": "Privé",
|
||||||
"channels_editChannel": "Modifier le canal",
|
"channels_editChannel": "Modifier le canal",
|
||||||
|
"channels_notificationSettings": "Paramètres des notifications",
|
||||||
|
"channels_notifyAll": "Tous les messages",
|
||||||
|
"channels_notifyMentionsOnly": "Mentions uniquement (@)",
|
||||||
|
"channels_notifyNone": "Désactivé",
|
||||||
"channels_muteChannel": "Désactiver les notifications du canal",
|
"channels_muteChannel": "Désactiver les notifications du canal",
|
||||||
"channels_unmuteChannel": "Réactiver les notifications du canal",
|
"channels_unmuteChannel": "Réactiver les notifications du canal",
|
||||||
"channels_deleteChannel": "Supprimer le canal",
|
"channels_deleteChannel": "Supprimer le canal",
|
||||||
|
|||||||
@@ -2620,6 +2620,30 @@ abstract class AppLocalizations {
|
|||||||
/// **'Edit channel'**
|
/// **'Edit channel'**
|
||||||
String get channels_editChannel;
|
String get channels_editChannel;
|
||||||
|
|
||||||
|
/// No description provided for @channels_notificationSettings.
|
||||||
|
///
|
||||||
|
/// In en, this message translates to:
|
||||||
|
/// **'Notification settings'**
|
||||||
|
String get channels_notificationSettings;
|
||||||
|
|
||||||
|
/// No description provided for @channels_notifyAll.
|
||||||
|
///
|
||||||
|
/// In en, this message translates to:
|
||||||
|
/// **'All messages'**
|
||||||
|
String get channels_notifyAll;
|
||||||
|
|
||||||
|
/// No description provided for @channels_notifyMentionsOnly.
|
||||||
|
///
|
||||||
|
/// In en, this message translates to:
|
||||||
|
/// **'Mentions only (@)'**
|
||||||
|
String get channels_notifyMentionsOnly;
|
||||||
|
|
||||||
|
/// No description provided for @channels_notifyNone.
|
||||||
|
///
|
||||||
|
/// In en, this message translates to:
|
||||||
|
/// **'Muted'**
|
||||||
|
String get channels_notifyNone;
|
||||||
|
|
||||||
/// No description provided for @channels_muteChannel.
|
/// No description provided for @channels_muteChannel.
|
||||||
///
|
///
|
||||||
/// In en, this message translates to:
|
/// In en, this message translates to:
|
||||||
|
|||||||
@@ -1464,6 +1464,18 @@ class AppLocalizationsBg extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get channels_editChannel => 'Редактирай канал';
|
String get channels_editChannel => 'Редактирай канал';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notificationSettings => 'Notification settings';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyAll => 'All messages';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyMentionsOnly => 'Mentions only (@)';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyNone => 'Muted';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get channels_muteChannel => 'Заглуши канала';
|
String get channels_muteChannel => 'Заглуши канала';
|
||||||
|
|
||||||
|
|||||||
@@ -1458,6 +1458,18 @@ class AppLocalizationsDe extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get channels_editChannel => 'Kanal bearbeiten';
|
String get channels_editChannel => 'Kanal bearbeiten';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notificationSettings => 'Notification settings';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyAll => 'All messages';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyMentionsOnly => 'Mentions only (@)';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyNone => 'Muted';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get channels_muteChannel => 'Kanal stummschalten';
|
String get channels_muteChannel => 'Kanal stummschalten';
|
||||||
|
|
||||||
|
|||||||
@@ -1438,6 +1438,18 @@ class AppLocalizationsEn extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get channels_editChannel => 'Edit channel';
|
String get channels_editChannel => 'Edit channel';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notificationSettings => 'Notification settings';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyAll => 'All messages';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyMentionsOnly => 'Mentions only (@)';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyNone => 'Muted';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get channels_muteChannel => 'Mute channel';
|
String get channels_muteChannel => 'Mute channel';
|
||||||
|
|
||||||
|
|||||||
@@ -1457,6 +1457,18 @@ class AppLocalizationsEs extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get channels_editChannel => 'Editar canal';
|
String get channels_editChannel => 'Editar canal';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notificationSettings => 'Notification settings';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyAll => 'All messages';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyMentionsOnly => 'Mentions only (@)';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyNone => 'Muted';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get channels_muteChannel => 'Silenciar canal';
|
String get channels_muteChannel => 'Silenciar canal';
|
||||||
|
|
||||||
|
|||||||
@@ -1462,6 +1462,18 @@ class AppLocalizationsFr extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get channels_editChannel => 'Modifier le canal';
|
String get channels_editChannel => 'Modifier le canal';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notificationSettings => 'Paramètres des notifications';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyAll => 'Tous les messages';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyMentionsOnly => 'Mentions uniquement (@)';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyNone => 'Désactivé';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get channels_muteChannel => 'Désactiver les notifications du canal';
|
String get channels_muteChannel => 'Désactiver les notifications du canal';
|
||||||
|
|
||||||
|
|||||||
@@ -1453,6 +1453,18 @@ class AppLocalizationsHu extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get channels_editChannel => 'Csatorna szerkesztése';
|
String get channels_editChannel => 'Csatorna szerkesztése';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notificationSettings => 'Notification settings';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyAll => 'All messages';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyMentionsOnly => 'Mentions only (@)';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyNone => 'Muted';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get channels_muteChannel => 'Csatorna némítása';
|
String get channels_muteChannel => 'Csatorna némítása';
|
||||||
|
|
||||||
|
|||||||
@@ -1461,6 +1461,18 @@ class AppLocalizationsIt extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get channels_editChannel => 'Modifica canale';
|
String get channels_editChannel => 'Modifica canale';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notificationSettings => 'Notification settings';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyAll => 'All messages';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyMentionsOnly => 'Mentions only (@)';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyNone => 'Muted';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get channels_muteChannel => 'Silenzia canale';
|
String get channels_muteChannel => 'Silenzia canale';
|
||||||
|
|
||||||
|
|||||||
@@ -1385,6 +1385,18 @@ class AppLocalizationsJa extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get channels_editChannel => 'チャンネルを編集';
|
String get channels_editChannel => 'チャンネルを編集';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notificationSettings => 'Notification settings';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyAll => 'All messages';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyMentionsOnly => 'Mentions only (@)';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyNone => 'Muted';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get channels_muteChannel => 'チャンネルをミュート';
|
String get channels_muteChannel => 'チャンネルをミュート';
|
||||||
|
|
||||||
|
|||||||
@@ -1390,6 +1390,18 @@ class AppLocalizationsKo extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get channels_editChannel => '채널 편집';
|
String get channels_editChannel => '채널 편집';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notificationSettings => 'Notification settings';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyAll => 'All messages';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyMentionsOnly => 'Mentions only (@)';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyNone => 'Muted';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get channels_muteChannel => '음소거 채널';
|
String get channels_muteChannel => '음소거 채널';
|
||||||
|
|
||||||
|
|||||||
@@ -1449,6 +1449,18 @@ class AppLocalizationsNl extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get channels_editChannel => 'Kanaal bewerken';
|
String get channels_editChannel => 'Kanaal bewerken';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notificationSettings => 'Notification settings';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyAll => 'All messages';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyMentionsOnly => 'Mentions only (@)';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyNone => 'Muted';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get channels_muteChannel => 'Kanaal dempen';
|
String get channels_muteChannel => 'Kanaal dempen';
|
||||||
|
|
||||||
|
|||||||
@@ -1475,6 +1475,18 @@ class AppLocalizationsPl extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get channels_editChannel => 'Edytuj kanał';
|
String get channels_editChannel => 'Edytuj kanał';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notificationSettings => 'Notification settings';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyAll => 'All messages';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyMentionsOnly => 'Mentions only (@)';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyNone => 'Muted';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get channels_muteChannel => 'Wycisz kanał';
|
String get channels_muteChannel => 'Wycisz kanał';
|
||||||
|
|
||||||
|
|||||||
@@ -1460,6 +1460,18 @@ class AppLocalizationsPt extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get channels_editChannel => 'Editar canal';
|
String get channels_editChannel => 'Editar canal';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notificationSettings => 'Notification settings';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyAll => 'All messages';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyMentionsOnly => 'Mentions only (@)';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyNone => 'Muted';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get channels_muteChannel => 'Silenciar canal';
|
String get channels_muteChannel => 'Silenciar canal';
|
||||||
|
|
||||||
|
|||||||
@@ -1464,6 +1464,18 @@ class AppLocalizationsRu extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get channels_editChannel => 'Изменить канал';
|
String get channels_editChannel => 'Изменить канал';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notificationSettings => 'Notification settings';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyAll => 'All messages';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyMentionsOnly => 'Mentions only (@)';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyNone => 'Muted';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get channels_muteChannel => 'Отключить уведомления канала';
|
String get channels_muteChannel => 'Отключить уведомления канала';
|
||||||
|
|
||||||
|
|||||||
@@ -1452,6 +1452,18 @@ class AppLocalizationsSk extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get channels_editChannel => 'Upraviť kanál';
|
String get channels_editChannel => 'Upraviť kanál';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notificationSettings => 'Notification settings';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyAll => 'All messages';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyMentionsOnly => 'Mentions only (@)';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyNone => 'Muted';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get channels_muteChannel => 'Stlmiť kanál';
|
String get channels_muteChannel => 'Stlmiť kanál';
|
||||||
|
|
||||||
|
|||||||
@@ -1450,6 +1450,18 @@ class AppLocalizationsSl extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get channels_editChannel => 'Uredi kanal';
|
String get channels_editChannel => 'Uredi kanal';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notificationSettings => 'Notification settings';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyAll => 'All messages';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyMentionsOnly => 'Mentions only (@)';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyNone => 'Muted';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get channels_muteChannel => 'Utišaj kanal';
|
String get channels_muteChannel => 'Utišaj kanal';
|
||||||
|
|
||||||
|
|||||||
@@ -1439,6 +1439,18 @@ class AppLocalizationsSv extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get channels_editChannel => 'Redigera kanal';
|
String get channels_editChannel => 'Redigera kanal';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notificationSettings => 'Notification settings';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyAll => 'All messages';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyMentionsOnly => 'Mentions only (@)';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyNone => 'Muted';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get channels_muteChannel => 'Tysta kanal';
|
String get channels_muteChannel => 'Tysta kanal';
|
||||||
|
|
||||||
|
|||||||
@@ -1455,6 +1455,18 @@ class AppLocalizationsUk extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get channels_editChannel => 'Редагувати канал';
|
String get channels_editChannel => 'Редагувати канал';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notificationSettings => 'Notification settings';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyAll => 'All messages';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyMentionsOnly => 'Mentions only (@)';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyNone => 'Muted';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get channels_muteChannel => 'Вимкнути сповіщення каналу';
|
String get channels_muteChannel => 'Вимкнути сповіщення каналу';
|
||||||
|
|
||||||
|
|||||||
@@ -1367,6 +1367,18 @@ class AppLocalizationsZh extends AppLocalizations {
|
|||||||
@override
|
@override
|
||||||
String get channels_editChannel => '编辑频道';
|
String get channels_editChannel => '编辑频道';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notificationSettings => 'Notification settings';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyAll => 'All messages';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyMentionsOnly => 'Mentions only (@)';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channels_notifyNone => 'Muted';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get channels_muteChannel => '静音频道';
|
String get channels_muteChannel => '静音频道';
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ import 'translation_support.dart';
|
|||||||
|
|
||||||
enum UnitSystem { metric, imperial }
|
enum UnitSystem { metric, imperial }
|
||||||
|
|
||||||
|
enum ChannelNotificationMode { all, mentionsOnly, muted }
|
||||||
|
|
||||||
extension UnitSystemValue on UnitSystem {
|
extension UnitSystemValue on UnitSystem {
|
||||||
String get value {
|
String get value {
|
||||||
switch (this) {
|
switch (this) {
|
||||||
@@ -123,7 +125,7 @@ class AppSettings {
|
|||||||
final Map<String, String> batteryChemistryByDeviceId;
|
final Map<String, String> batteryChemistryByDeviceId;
|
||||||
final Map<String, String> batteryChemistryByRepeaterId;
|
final Map<String, String> batteryChemistryByRepeaterId;
|
||||||
final UnitSystem unitSystem;
|
final UnitSystem unitSystem;
|
||||||
final Set<String> mutedChannels;
|
final Map<String, ChannelNotificationMode> channelNotificationModes;
|
||||||
final bool mapShowDiscoveryContacts;
|
final bool mapShowDiscoveryContacts;
|
||||||
final bool evictDiscoveredContactsEnabled;
|
final bool evictDiscoveredContactsEnabled;
|
||||||
final String tcpServerAddress;
|
final String tcpServerAddress;
|
||||||
@@ -196,6 +198,12 @@ class AppSettings {
|
|||||||
return profile.charMap;
|
return profile.charMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Backward compatibility: returns true if channel is muted (mode == muted)
|
||||||
|
bool isChannelMuted(String channelName) {
|
||||||
|
return channelNotificationModes[channelName] ==
|
||||||
|
ChannelNotificationMode.muted;
|
||||||
|
}
|
||||||
|
|
||||||
AppSettings({
|
AppSettings({
|
||||||
this.clearPathOnMaxRetry = false,
|
this.clearPathOnMaxRetry = false,
|
||||||
this.mapShowRepeaters = true,
|
this.mapShowRepeaters = true,
|
||||||
@@ -238,7 +246,7 @@ class AppSettings {
|
|||||||
Map<String, String>? batteryChemistryByDeviceId,
|
Map<String, String>? batteryChemistryByDeviceId,
|
||||||
Map<String, String>? batteryChemistryByRepeaterId,
|
Map<String, String>? batteryChemistryByRepeaterId,
|
||||||
this.unitSystem = UnitSystem.metric,
|
this.unitSystem = UnitSystem.metric,
|
||||||
Set<String>? mutedChannels,
|
Map<String, ChannelNotificationMode>? channelNotificationModes,
|
||||||
this.mapShowDiscoveryContacts = true,
|
this.mapShowDiscoveryContacts = true,
|
||||||
this.evictDiscoveredContactsEnabled = true,
|
this.evictDiscoveredContactsEnabled = true,
|
||||||
this.tcpServerAddress = '',
|
this.tcpServerAddress = '',
|
||||||
@@ -264,7 +272,7 @@ class AppSettings {
|
|||||||
String? selectedCyr2latProfileId,
|
String? selectedCyr2latProfileId,
|
||||||
}) : batteryChemistryByDeviceId = batteryChemistryByDeviceId ?? {},
|
}) : batteryChemistryByDeviceId = batteryChemistryByDeviceId ?? {},
|
||||||
batteryChemistryByRepeaterId = batteryChemistryByRepeaterId ?? {},
|
batteryChemistryByRepeaterId = batteryChemistryByRepeaterId ?? {},
|
||||||
mutedChannels = mutedChannels ?? {},
|
channelNotificationModes = channelNotificationModes ?? {},
|
||||||
imageCodecDownloadedModels = imageCodecDownloadedModels ?? const [],
|
imageCodecDownloadedModels = imageCodecDownloadedModels ?? const [],
|
||||||
translationDownloadedModels = translationDownloadedModels ?? const [],
|
translationDownloadedModels = translationDownloadedModels ?? const [],
|
||||||
cyr2latProfiles =
|
cyr2latProfiles =
|
||||||
@@ -322,7 +330,9 @@ class AppSettings {
|
|||||||
'battery_chemistry_by_device_id': batteryChemistryByDeviceId,
|
'battery_chemistry_by_device_id': batteryChemistryByDeviceId,
|
||||||
'battery_chemistry_by_repeater_id': batteryChemistryByRepeaterId,
|
'battery_chemistry_by_repeater_id': batteryChemistryByRepeaterId,
|
||||||
'unit_system': unitSystem.value,
|
'unit_system': unitSystem.value,
|
||||||
'muted_channels': mutedChannels.toList(),
|
'channel_notification_modes': channelNotificationModes.map(
|
||||||
|
(key, value) => MapEntry(key, value.index),
|
||||||
|
),
|
||||||
'map_show_discovery_contacts': mapShowDiscoveryContacts,
|
'map_show_discovery_contacts': mapShowDiscoveryContacts,
|
||||||
'evict_discovered_contacts_enabled': evictDiscoveredContactsEnabled,
|
'evict_discovered_contacts_enabled': evictDiscoveredContactsEnabled,
|
||||||
'tcp_server_address': tcpServerAddress,
|
'tcp_server_address': tcpServerAddress,
|
||||||
@@ -363,6 +373,38 @@ class AppSettings {
|
|||||||
return UnitSystem.metric;
|
return UnitSystem.metric;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, ChannelNotificationMode> parseChannelNotificationModes(
|
||||||
|
Map<String, dynamic> json,
|
||||||
|
) {
|
||||||
|
// Migration from old muted_channels (Set<String>) to new system
|
||||||
|
final mutedList = json['muted_channels'] as List?;
|
||||||
|
final newModes = json['channel_notification_modes'] as Map?;
|
||||||
|
|
||||||
|
final result = <String, ChannelNotificationMode>{};
|
||||||
|
|
||||||
|
// Migrate old muted channels
|
||||||
|
if (mutedList != null) {
|
||||||
|
for (final channelName in mutedList) {
|
||||||
|
result[channelName.toString()] = ChannelNotificationMode.muted;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load new modes (overrides old muted channels if present)
|
||||||
|
if (newModes != null) {
|
||||||
|
for (final entry in newModes.entries) {
|
||||||
|
final channelName = entry.key;
|
||||||
|
final modeIndex = entry.value as int?;
|
||||||
|
if (modeIndex != null &&
|
||||||
|
modeIndex >= 0 &&
|
||||||
|
modeIndex < ChannelNotificationMode.values.length) {
|
||||||
|
result[channelName] = ChannelNotificationMode.values[modeIndex];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
return AppSettings(
|
return AppSettings(
|
||||||
clearPathOnMaxRetry: json['clear_path_on_max_retry'] as bool? ?? false,
|
clearPathOnMaxRetry: json['clear_path_on_max_retry'] as bool? ?? false,
|
||||||
mapShowRepeaters: json['map_show_repeaters'] as bool? ?? true,
|
mapShowRepeaters: json['map_show_repeaters'] as bool? ?? true,
|
||||||
@@ -425,11 +467,7 @@ class AppSettings {
|
|||||||
) ??
|
) ??
|
||||||
{},
|
{},
|
||||||
unitSystem: parseUnitSystem(json['unit_system']),
|
unitSystem: parseUnitSystem(json['unit_system']),
|
||||||
mutedChannels:
|
channelNotificationModes: parseChannelNotificationModes(json),
|
||||||
((json['muted_channels'] as List?)
|
|
||||||
?.map((e) => e.toString())
|
|
||||||
.toSet()) ??
|
|
||||||
{},
|
|
||||||
mapShowDiscoveryContacts:
|
mapShowDiscoveryContacts:
|
||||||
json['map_show_discovery_contacts'] as bool? ?? true,
|
json['map_show_discovery_contacts'] as bool? ?? true,
|
||||||
evictDiscoveredContactsEnabled:
|
evictDiscoveredContactsEnabled:
|
||||||
@@ -554,7 +592,7 @@ class AppSettings {
|
|||||||
Map<String, String>? batteryChemistryByDeviceId,
|
Map<String, String>? batteryChemistryByDeviceId,
|
||||||
Map<String, String>? batteryChemistryByRepeaterId,
|
Map<String, String>? batteryChemistryByRepeaterId,
|
||||||
UnitSystem? unitSystem,
|
UnitSystem? unitSystem,
|
||||||
Set<String>? mutedChannels,
|
Map<String, ChannelNotificationMode>? channelNotificationModes,
|
||||||
bool? mapShowDiscoveryContacts,
|
bool? mapShowDiscoveryContacts,
|
||||||
bool? evictDiscoveredContactsEnabled,
|
bool? evictDiscoveredContactsEnabled,
|
||||||
String? tcpServerAddress,
|
String? tcpServerAddress,
|
||||||
@@ -639,7 +677,8 @@ class AppSettings {
|
|||||||
batteryChemistryByRepeaterId:
|
batteryChemistryByRepeaterId:
|
||||||
batteryChemistryByRepeaterId ?? this.batteryChemistryByRepeaterId,
|
batteryChemistryByRepeaterId ?? this.batteryChemistryByRepeaterId,
|
||||||
unitSystem: unitSystem ?? this.unitSystem,
|
unitSystem: unitSystem ?? this.unitSystem,
|
||||||
mutedChannels: mutedChannels ?? this.mutedChannels,
|
channelNotificationModes:
|
||||||
|
channelNotificationModes ?? this.channelNotificationModes,
|
||||||
mapShowDiscoveryContacts:
|
mapShowDiscoveryContacts:
|
||||||
mapShowDiscoveryContacts ?? this.mapShowDiscoveryContacts,
|
mapShowDiscoveryContacts ?? this.mapShowDiscoveryContacts,
|
||||||
evictDiscoveredContactsEnabled:
|
evictDiscoveredContactsEnabled:
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import '../services/app_settings_service.dart';
|
import '../services/app_settings_service.dart'
|
||||||
|
show AppSettingsService, ChannelNotificationMode;
|
||||||
import '../services/storage_service.dart';
|
import '../services/storage_service.dart';
|
||||||
import '../services/timeout_prediction_service.dart';
|
import '../services/timeout_prediction_service.dart';
|
||||||
import '../storage/legacy_key_migration.dart';
|
import '../storage/legacy_key_migration.dart';
|
||||||
@@ -48,10 +49,13 @@ Future<void> beginReviewModeSession(AppSettingsService? settings) async {
|
|||||||
}
|
}
|
||||||
// An earlier interrupted session's record holds the real pre-review state.
|
// An earlier interrupted session's record holds the real pre-review state.
|
||||||
if (settings != null && !prefs.containsKey(_savedMutedChannelsKey)) {
|
if (settings != null && !prefs.containsKey(_savedMutedChannelsKey)) {
|
||||||
await prefs.setStringList(
|
// Save all channel notification modes
|
||||||
_savedMutedChannelsKey,
|
final channelModes = settings.settings.channelNotificationModes;
|
||||||
settings.settings.mutedChannels.toList(),
|
final mutedChannels = channelModes.entries
|
||||||
);
|
.where((e) => e.value == ChannelNotificationMode.muted)
|
||||||
|
.map((e) => e.key)
|
||||||
|
.toList();
|
||||||
|
await prefs.setStringList(_savedMutedChannelsKey, mutedChannels);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,8 +79,17 @@ Future<void> endReviewModeSession(AppSettingsService? settings) async {
|
|||||||
}
|
}
|
||||||
final savedMutes = prefs.getStringList(_savedMutedChannelsKey);
|
final savedMutes = prefs.getStringList(_savedMutedChannelsKey);
|
||||||
if (savedMutes == null || settings == null) return;
|
if (savedMutes == null || settings == null) return;
|
||||||
|
final updatedModes = Map<String, ChannelNotificationMode>.from(
|
||||||
|
settings.settings.channelNotificationModes,
|
||||||
|
);
|
||||||
|
updatedModes.removeWhere(
|
||||||
|
(key, value) => value == ChannelNotificationMode.muted,
|
||||||
|
);
|
||||||
|
for (final channelName in savedMutes) {
|
||||||
|
updatedModes[channelName] = ChannelNotificationMode.muted;
|
||||||
|
}
|
||||||
await settings.updateSettings(
|
await settings.updateSettings(
|
||||||
settings.settings.copyWith(mutedChannels: savedMutes.toSet()),
|
settings.settings.copyWith(channelNotificationModes: updatedModes),
|
||||||
);
|
);
|
||||||
await prefs.remove(_savedMutedChannelsKey);
|
await prefs.remove(_savedMutedChannelsKey);
|
||||||
}
|
}
|
||||||
@@ -26,7 +26,8 @@ import '../l10n/l10n.dart';
|
|||||||
import '../models/channel.dart';
|
import '../models/channel.dart';
|
||||||
import '../models/channel_message.dart';
|
import '../models/channel_message.dart';
|
||||||
import '../models/image_codec_support.dart' show aeicRatePointForUi;
|
import '../models/image_codec_support.dart' show aeicRatePointForUi;
|
||||||
import '../services/app_settings_service.dart';
|
import '../services/app_settings_service.dart'
|
||||||
|
show AppSettingsService, ChannelNotificationMode;
|
||||||
import '../services/chat_text_scale_service.dart';
|
import '../services/chat_text_scale_service.dart';
|
||||||
import '../services/image_chunk_transport.dart';
|
import '../services/image_chunk_transport.dart';
|
||||||
import '../services/image_codec_service.dart';
|
import '../services/image_codec_service.dart';
|
||||||
@@ -403,19 +404,64 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
|||||||
Consumer<AppSettingsService>(
|
Consumer<AppSettingsService>(
|
||||||
builder: (context, settings, _) {
|
builder: (context, settings, _) {
|
||||||
final muteKey = widget.channel.muteKey;
|
final muteKey = widget.channel.muteKey;
|
||||||
final muted = settings.isChannelMuted(muteKey);
|
final notificationMode = settings.getChannelNotificationMode(
|
||||||
return IconButton(
|
muteKey,
|
||||||
tooltip: muted
|
);
|
||||||
? context.l10n.channels_unmuteChannel
|
return PopupMenuButton<ChannelNotificationMode>(
|
||||||
: context.l10n.channels_muteChannel,
|
tooltip: context.l10n.channels_notificationSettings,
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
muted
|
notificationMode == ChannelNotificationMode.muted
|
||||||
? Icons.notifications_off_outlined
|
? Icons.notifications_off_outlined
|
||||||
|
: notificationMode == ChannelNotificationMode.mentionsOnly
|
||||||
|
? Icons.alternate_email
|
||||||
: Icons.notifications_outlined,
|
: Icons.notifications_outlined,
|
||||||
),
|
),
|
||||||
onPressed: () => muted
|
onSelected: (mode) {
|
||||||
? settings.unmuteChannel(muteKey)
|
settings.setChannelNotificationMode(muteKey, mode);
|
||||||
: settings.muteChannel(muteKey),
|
},
|
||||||
|
itemBuilder: (context) => [
|
||||||
|
PopupMenuItem(
|
||||||
|
value: ChannelNotificationMode.all,
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
Icons.notifications_active,
|
||||||
|
color: notificationMode == ChannelNotificationMode.all
|
||||||
|
? Theme.of(context).colorScheme.primary
|
||||||
|
: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Text(context.l10n.channels_notifyAll),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
PopupMenuItem(
|
||||||
|
value: ChannelNotificationMode.mentionsOnly,
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.alternate_email),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Text(context.l10n.channels_notifyMentionsOnly),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
PopupMenuItem(
|
||||||
|
value: ChannelNotificationMode.muted,
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
Icons.notifications_off,
|
||||||
|
color:
|
||||||
|
notificationMode == ChannelNotificationMode.muted
|
||||||
|
? Theme.of(context).colorScheme.primary
|
||||||
|
: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Text(context.l10n.channels_notifyNone),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ import 'package:uuid/uuid.dart';
|
|||||||
|
|
||||||
import '../connector/meshcore_connector.dart';
|
import '../connector/meshcore_connector.dart';
|
||||||
import '../l10n/l10n.dart';
|
import '../l10n/l10n.dart';
|
||||||
import '../services/app_settings_service.dart';
|
import '../services/app_settings_service.dart'
|
||||||
|
show AppSettingsService, ChannelNotificationMode;
|
||||||
import '../services/ui_view_state_service.dart';
|
import '../services/ui_view_state_service.dart';
|
||||||
import '../models/channel.dart';
|
import '../models/channel.dart';
|
||||||
import '../models/community.dart';
|
import '../models/community.dart';
|
||||||
@@ -372,9 +373,9 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
|||||||
int listIndex = 0,
|
int listIndex = 0,
|
||||||
}) {
|
}) {
|
||||||
final unreadCount = connector.getUnreadCountForChannel(channel);
|
final unreadCount = connector.getUnreadCountForChannel(channel);
|
||||||
final isMuted = context.watch<AppSettingsService>().isChannelMuted(
|
final notificationMode = context
|
||||||
channel.muteKey,
|
.watch<AppSettingsService>()
|
||||||
);
|
.getChannelNotificationMode(channel.muteKey);
|
||||||
final scheme = Theme.of(context).colorScheme;
|
final scheme = Theme.of(context).colorScheme;
|
||||||
|
|
||||||
// Determine icon and colors based on channel type
|
// Determine icon and colors based on channel type
|
||||||
@@ -580,9 +581,11 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
|||||||
Row(
|
Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
if (isMuted) ...[
|
if (notificationMode != ChannelNotificationMode.all) ...[
|
||||||
Icon(
|
Icon(
|
||||||
Icons.notifications_off,
|
notificationMode == ChannelNotificationMode.muted
|
||||||
|
? Icons.notifications_off
|
||||||
|
: Icons.alternate_email,
|
||||||
size: 18,
|
size: 18,
|
||||||
color: scheme.onSurfaceVariant,
|
color: scheme.onSurfaceVariant,
|
||||||
),
|
),
|
||||||
@@ -625,8 +628,6 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
|||||||
Channel channel,
|
Channel channel,
|
||||||
) {
|
) {
|
||||||
final parentContext = context;
|
final parentContext = context;
|
||||||
final settingsService = context.read<AppSettingsService>();
|
|
||||||
final isMuted = settingsService.isChannelMuted(channel.muteKey);
|
|
||||||
|
|
||||||
showMeshSheet(
|
showMeshSheet(
|
||||||
parentContext,
|
parentContext,
|
||||||
@@ -645,24 +646,14 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
// Notification mode selection
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: Icon(
|
leading: const Icon(Icons.notifications_outlined),
|
||||||
isMuted
|
title: Text(sheetContext.l10n.channels_notificationSettings),
|
||||||
? Icons.notifications_outlined
|
trailing: const Icon(Icons.chevron_right),
|
||||||
: Icons.notifications_off_outlined,
|
onTap: () {
|
||||||
),
|
|
||||||
title: Text(
|
|
||||||
isMuted
|
|
||||||
? sheetContext.l10n.channels_unmuteChannel
|
|
||||||
: sheetContext.l10n.channels_muteChannel,
|
|
||||||
),
|
|
||||||
onTap: () async {
|
|
||||||
Navigator.pop(sheetContext);
|
Navigator.pop(sheetContext);
|
||||||
if (isMuted) {
|
_showNotificationModeDialog(sheetContext, connector, channel);
|
||||||
await settingsService.unmuteChannel(channel.muteKey);
|
|
||||||
} else {
|
|
||||||
await settingsService.muteChannel(channel.muteKey);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
@@ -690,6 +681,83 @@ 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_active,
|
||||||
|
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.alternate_email),
|
||||||
|
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) {
|
void _handleQuickSwitch(int index, BuildContext context) {
|
||||||
if (index == 1) return;
|
if (index == 1) return;
|
||||||
switch (index) {
|
switch (index) {
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ import 'package:flutter/foundation.dart';
|
|||||||
import '../models/app_settings.dart';
|
import '../models/app_settings.dart';
|
||||||
import '../models/image_codec_support.dart';
|
import '../models/image_codec_support.dart';
|
||||||
import '../models/translation_support.dart';
|
import '../models/translation_support.dart';
|
||||||
|
|
||||||
|
export '../models/app_settings.dart' show ChannelNotificationMode;
|
||||||
import '../storage/prefs_manager.dart';
|
import '../storage/prefs_manager.dart';
|
||||||
import '../utils/app_logger.dart';
|
import '../utils/app_logger.dart';
|
||||||
import '../helpers/cyr2lat.dart';
|
import '../helpers/cyr2lat.dart';
|
||||||
@@ -286,19 +288,36 @@ class AppSettingsService extends ChangeNotifier {
|
|||||||
await updateSettings(_settings.copyWith(unitSystem: value));
|
await updateSettings(_settings.copyWith(unitSystem: value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Backward compatibility: delegates to AppSettings.isChannelMuted
|
||||||
bool isChannelMuted(String channelName) {
|
bool isChannelMuted(String channelName) {
|
||||||
return _settings.mutedChannels.contains(channelName);
|
return _settings.isChannelMuted(channelName);
|
||||||
|
}
|
||||||
|
|
||||||
|
ChannelNotificationMode getChannelNotificationMode(String channelName) {
|
||||||
|
return _settings.channelNotificationModes[channelName] ??
|
||||||
|
ChannelNotificationMode.all;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setChannelNotificationMode(
|
||||||
|
String channelName,
|
||||||
|
ChannelNotificationMode mode,
|
||||||
|
) async {
|
||||||
|
final updated = Map<String, ChannelNotificationMode>.from(
|
||||||
|
_settings.channelNotificationModes,
|
||||||
|
);
|
||||||
|
updated[channelName] = mode;
|
||||||
|
await updateSettings(_settings.copyWith(channelNotificationModes: updated));
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> muteChannel(String channelName) async {
|
Future<void> muteChannel(String channelName) async {
|
||||||
final updated = Set<String>.from(_settings.mutedChannels)..add(channelName);
|
await setChannelNotificationMode(
|
||||||
await updateSettings(_settings.copyWith(mutedChannels: updated));
|
channelName,
|
||||||
|
ChannelNotificationMode.muted,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> unmuteChannel(String channelName) async {
|
Future<void> unmuteChannel(String channelName) async {
|
||||||
final updated = Set<String>.from(_settings.mutedChannels)
|
await setChannelNotificationMode(channelName, ChannelNotificationMode.all);
|
||||||
..remove(channelName);
|
|
||||||
await updateSettings(_settings.copyWith(mutedChannels: updated));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> setTcpServerAddress(String value) async {
|
Future<void> setTcpServerAddress(String value) async {
|
||||||
|
|||||||
+113
-1
@@ -1 +1,113 @@
|
|||||||
{}
|
{
|
||||||
|
"bg": [
|
||||||
|
"channels_notificationSettings",
|
||||||
|
"channels_notifyAll",
|
||||||
|
"channels_notifyMentionsOnly",
|
||||||
|
"channels_notifyNone"
|
||||||
|
],
|
||||||
|
|
||||||
|
"de": [
|
||||||
|
"channels_notificationSettings",
|
||||||
|
"channels_notifyAll",
|
||||||
|
"channels_notifyMentionsOnly",
|
||||||
|
"channels_notifyNone"
|
||||||
|
],
|
||||||
|
|
||||||
|
"es": [
|
||||||
|
"channels_notificationSettings",
|
||||||
|
"channels_notifyAll",
|
||||||
|
"channels_notifyMentionsOnly",
|
||||||
|
"channels_notifyNone"
|
||||||
|
],
|
||||||
|
|
||||||
|
"hu": [
|
||||||
|
"channels_notificationSettings",
|
||||||
|
"channels_notifyAll",
|
||||||
|
"channels_notifyMentionsOnly",
|
||||||
|
"channels_notifyNone"
|
||||||
|
],
|
||||||
|
|
||||||
|
"it": [
|
||||||
|
"channels_notificationSettings",
|
||||||
|
"channels_notifyAll",
|
||||||
|
"channels_notifyMentionsOnly",
|
||||||
|
"channels_notifyNone"
|
||||||
|
],
|
||||||
|
|
||||||
|
"ja": [
|
||||||
|
"channels_notificationSettings",
|
||||||
|
"channels_notifyAll",
|
||||||
|
"channels_notifyMentionsOnly",
|
||||||
|
"channels_notifyNone"
|
||||||
|
],
|
||||||
|
|
||||||
|
"ko": [
|
||||||
|
"channels_notificationSettings",
|
||||||
|
"channels_notifyAll",
|
||||||
|
"channels_notifyMentionsOnly",
|
||||||
|
"channels_notifyNone"
|
||||||
|
],
|
||||||
|
|
||||||
|
"nl": [
|
||||||
|
"channels_notificationSettings",
|
||||||
|
"channels_notifyAll",
|
||||||
|
"channels_notifyMentionsOnly",
|
||||||
|
"channels_notifyNone"
|
||||||
|
],
|
||||||
|
|
||||||
|
"pl": [
|
||||||
|
"channels_notificationSettings",
|
||||||
|
"channels_notifyAll",
|
||||||
|
"channels_notifyMentionsOnly",
|
||||||
|
"channels_notifyNone"
|
||||||
|
],
|
||||||
|
|
||||||
|
"pt": [
|
||||||
|
"channels_notificationSettings",
|
||||||
|
"channels_notifyAll",
|
||||||
|
"channels_notifyMentionsOnly",
|
||||||
|
"channels_notifyNone"
|
||||||
|
],
|
||||||
|
|
||||||
|
"ru": [
|
||||||
|
"channels_notificationSettings",
|
||||||
|
"channels_notifyAll",
|
||||||
|
"channels_notifyMentionsOnly",
|
||||||
|
"channels_notifyNone"
|
||||||
|
],
|
||||||
|
|
||||||
|
"sk": [
|
||||||
|
"channels_notificationSettings",
|
||||||
|
"channels_notifyAll",
|
||||||
|
"channels_notifyMentionsOnly",
|
||||||
|
"channels_notifyNone"
|
||||||
|
],
|
||||||
|
|
||||||
|
"sl": [
|
||||||
|
"channels_notificationSettings",
|
||||||
|
"channels_notifyAll",
|
||||||
|
"channels_notifyMentionsOnly",
|
||||||
|
"channels_notifyNone"
|
||||||
|
],
|
||||||
|
|
||||||
|
"sv": [
|
||||||
|
"channels_notificationSettings",
|
||||||
|
"channels_notifyAll",
|
||||||
|
"channels_notifyMentionsOnly",
|
||||||
|
"channels_notifyNone"
|
||||||
|
],
|
||||||
|
|
||||||
|
"uk": [
|
||||||
|
"channels_notificationSettings",
|
||||||
|
"channels_notifyAll",
|
||||||
|
"channels_notifyMentionsOnly",
|
||||||
|
"channels_notifyNone"
|
||||||
|
],
|
||||||
|
|
||||||
|
"zh": [
|
||||||
|
"channels_notificationSettings",
|
||||||
|
"channels_notifyAll",
|
||||||
|
"channels_notifyMentionsOnly",
|
||||||
|
"channels_notifyNone"
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in new issue
Block a user