diff --git a/lib/backend/modules/chats.dart b/lib/backend/modules/chats.dart index 8ca873d..3532edb 100644 --- a/lib/backend/modules/chats.dart +++ b/lib/backend/modules/chats.dart @@ -312,7 +312,7 @@ class ChatsModule { if ((row['unread_count'] as int? ?? 0) == 0) return; final msgIdNum = int.tryParse(messageId); - if (msgIdNum != null) { + if (msgIdNum != null && !KometSettings.antiRead.value) { try { await api.sendRequest(Opcode.chatMark, { 'type': 'READ_MESSAGE', diff --git a/lib/core/config/komet_settings.dart b/lib/core/config/komet_settings.dart index 896baaf..d257dee 100644 --- a/lib/core/config/komet_settings.dart +++ b/lib/core/config/komet_settings.dart @@ -6,12 +6,14 @@ class KometSettings { static const _kViewRedacted = 'komet_view_redacted'; static const _kFullTimestamp = 'komet_full_timestamp'; static const _kGhostMode = 'komet_ghost_mode'; + static const _kAntiRead = 'komet_anti_read'; static const _kSelfOnlineCheck = 'komet_self_online_check'; static final ValueNotifier viewDeleted = ValueNotifier(false); static final ValueNotifier viewRedacted = ValueNotifier(false); static final ValueNotifier fullTimestamp = ValueNotifier(false); static final ValueNotifier ghostMode = ValueNotifier(false); + static final ValueNotifier antiRead = ValueNotifier(false); static final ValueNotifier selfOnlineCheck = ValueNotifier(true); static Future load() async { @@ -20,6 +22,7 @@ class KometSettings { viewRedacted.value = prefs.getBool(_kViewRedacted) ?? false; fullTimestamp.value = prefs.getBool(_kFullTimestamp) ?? false; ghostMode.value = prefs.getBool(_kGhostMode) ?? false; + antiRead.value = prefs.getBool(_kAntiRead) ?? false; selfOnlineCheck.value = prefs.getBool(_kSelfOnlineCheck) ?? true; } @@ -47,6 +50,12 @@ class KometSettings { await prefs.setBool(_kGhostMode, value); } + static Future setAntiRead(bool value) async { + antiRead.value = value; + final prefs = await SharedPreferences.getInstance(); + await prefs.setBool(_kAntiRead, value); + } + static Future setSelfOnlineCheck(bool value) async { selfOnlineCheck.value = value; final prefs = await SharedPreferences.getInstance(); diff --git a/lib/frontend/screens/profile/komet_settings_screen.dart b/lib/frontend/screens/profile/komet_settings_screen.dart index e6158f0..228bd13 100644 --- a/lib/frontend/screens/profile/komet_settings_screen.dart +++ b/lib/frontend/screens/profile/komet_settings_screen.dart @@ -68,11 +68,20 @@ class KometSettingsScreen extends StatelessWidget { cs, icon: Symbols.visibility_off, label: 'Ghost Mode', - subtitle: 'Не отмечать вас в сети: пинги идут скрытно', + subtitle: 'Вас не видно в сети', notifier: KometSettings.ghostMode, onChanged: _setGhostMode, ), _divider(cs), + _toggle( + cs, + icon: Symbols.mark_chat_read, + label: 'Anti read', + subtitle: 'Нечиталка сообщений', + notifier: KometSettings.antiRead, + onChanged: KometSettings.setAntiRead, + ), + _divider(cs), _toggle( cs, icon: Symbols.radar, diff --git a/lib/frontend/screens/profile/settings_tab.dart b/lib/frontend/screens/profile/settings_tab.dart index 02275a1..08346c0 100644 --- a/lib/frontend/screens/profile/settings_tab.dart +++ b/lib/frontend/screens/profile/settings_tab.dart @@ -467,13 +467,12 @@ class _SettingsTabState extends State { cs, items: [ _SettingsItem( - icon: Symbols.logout, - label: 'Выйти из аккаунта', - tintColor: cs.error, - onTap: _confirmLogout, - ), - _SettingsItem( - icon: Symbols.auto_awesome, + leading: Image.asset( + 'assets/komet.png', + width: 22, + height: 22, + color: cs.onSurfaceVariant, + ), label: 'Komet', onTap: () { Navigator.push( @@ -484,6 +483,12 @@ class _SettingsTabState extends State { ); }, ), + _SettingsItem( + icon: Symbols.logout, + label: 'Выйти из аккаунта', + tintColor: cs.error, + onTap: _confirmLogout, + ), ], ), ), @@ -723,12 +728,13 @@ class _SettingsTabState extends State { padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 17), child: Row( children: [ - Icon( - item.icon, - color: item.tintColor ?? cs.onSurfaceVariant, - size: 22, - weight: 400, - ), + item.leading ?? + Icon( + item.icon, + color: item.tintColor ?? cs.onSurfaceVariant, + size: 22, + weight: 400, + ), const SizedBox(width: 16), Expanded( child: Text( @@ -766,13 +772,15 @@ class _SettingsTabState extends State { } class _SettingsItem { - final IconData icon; + final IconData? icon; + final Widget? leading; final String label; final VoidCallback? onTap; final Color? tintColor; const _SettingsItem({ - required this.icon, + this.icon, + this.leading, required this.label, this.onTap, this.tintColor,