diff --git a/.gitignore b/.gitignore index 235938fa2..7fdb9b2ac 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ build/.last_build_id widgets/matrix_widget_api/build/.last_build_id widgets/calendar/android/local.properties .vscode/settings.json +.idea/ \ No newline at end of file diff --git a/commet/lib/config/preferences.dart b/commet/lib/config/preferences.dart index 06ed65264..ed5d56ed7 100644 --- a/commet/lib/config/preferences.dart +++ b/commet/lib/config/preferences.dart @@ -37,6 +37,8 @@ class Preferences { static const String _fallbackTurnServer = "fallback_turn_server"; static const String _urlPreviewInE2EEChat = "use_url_preview_in_e2ee_chat"; static const String _messageEffectsEnabled = "message_effects_enabled"; + static const String _askBeforeDeletingMessageEnabled = + "ask_before_deleting_message_enabled"; static const String _lastForegroundServiceSucceeded = "did_last_foreground_service_run_succeed"; static const String _showRoomAvatars = "show_room_avatars"; @@ -331,6 +333,13 @@ class Preferences { } } + Future setAskBeforeDeletingMessageEnabled(bool value) async { + await _preferences!.setBool(_askBeforeDeletingMessageEnabled, value); + } + + bool get askBeforeDeletingMessageEnabled => + _preferences!.getBool(_askBeforeDeletingMessageEnabled) ?? true; + Future setMessageEffectsEnabled(bool value) async { await _preferences!.setBool(_messageEffectsEnabled, value); } diff --git a/commet/lib/ui/molecules/timeline_events/timeline_event_menu.dart b/commet/lib/ui/molecules/timeline_events/timeline_event_menu.dart index a78d24319..eb1ced059 100644 --- a/commet/lib/ui/molecules/timeline_events/timeline_event_menu.dart +++ b/commet/lib/ui/molecules/timeline_events/timeline_event_menu.dart @@ -263,13 +263,18 @@ class TimelineEventMenu { TimelineEventMenuEntry( name: CommonStrings.promptDelete, icon: Icons.delete, - action: (BuildContext context) => { - AdaptiveDialog.confirmation(context).then((value) { - if (value == true) { - timeline.deleteEvent(event); - } + action: (BuildContext context) { + if (preferences.askBeforeDeletingMessageEnabled) { + AdaptiveDialog.confirmation(context).then((value) { + if (value == true) { + timeline.deleteEvent(event); + } + onActionFinished?.call(); + }); + } else { + timeline.deleteEvent(event); onActionFinished?.call(); - }), + } }, ), ]; diff --git a/commet/lib/ui/pages/settings/categories/app/general_settings_page.dart b/commet/lib/ui/pages/settings/categories/app/general_settings_page.dart index dad9240fd..2db88a7c7 100644 --- a/commet/lib/ui/pages/settings/categories/app/general_settings_page.dart +++ b/commet/lib/ui/pages/settings/categories/app/general_settings_page.dart @@ -45,6 +45,22 @@ class GeneralSettingsPageState extends State { "description for the toggle for enabling and disabling use of url previews in encrypted chats", name: "labelUrlPreviewInEncryptedChatDescription"); + String get labelAppBehaviourTitle => Intl.message("App Behaviour", + desc: "Header for the app behaviour section in settings", + name: "labelAppBehaviourTitle"); + + String get labelAskBeforeDeletingMessageToggle => Intl.message( + "Ask before deleting messages", + desc: + "Label for the toggle for enabling and disabling message deletion confirmation", + name: "labelAskBeforeDeletingMessageToggle"); + + String get labelAskBeforeDeletingMessageDescription => Intl.message( + "Enables the pop-up asking for confirmation when deleting a message.", + desc: + "Label describing what 'asking before deleting messages' even means", + name: "labelAskBeforeDeletingMessageDescription"); + String get labelMessageEffectsTitle => Intl.message("Message Effects", desc: "Header for the settings tile for message effects, such as confetti", @@ -136,6 +152,24 @@ class GeneralSettingsPageState extends State { const SizedBox( height: 10, ), + Panel( + header: labelAppBehaviourTitle, + mode: TileType.surfaceContainerLow, + child: Column(children: [ + settingToggle( + preferences.askBeforeDeletingMessageEnabled, + title: labelAskBeforeDeletingMessageToggle, + description: labelAskBeforeDeletingMessageDescription, + onChanged: (value) async { + await preferences.setAskBeforeDeletingMessageEnabled(value); + setState(() {}); + }, + ), + ]), + ), + const SizedBox( + height: 10, + ), Panel( header: labelMessageEffectsTitle, mode: TileType.surfaceContainerLow,