Skip to content
Snippets Groups Projects
Commit 8d7e37b6 authored by Daniel Brötzmann's avatar Daniel Brötzmann
Browse files

Preferences: Add Purge Chat History button

parent b3686347
No related branches found
No related tags found
No related merge requests found
......@@ -1375,6 +1375,18 @@ def forget_jid_data(self, account: str, jid: JID) -> None:
self._delayed_commit()
log.info('Forgot data for: %s', jid)
def remove_all_history(self) -> None:
"""
Remove all messages for all accounts
"""
statements = [
'DELETE FROM logs',
'DELETE FROM jids',
'DELETE FROM last_archive_message'
]
self._execute_multiple(statements)
log.info('Removed all chat history')
def _cleanup_chat_history(self) -> None:
"""
Remove messages from account where messages are older than max_age
......
This diff is collapsed.
......@@ -41,6 +41,8 @@
from .const import SettingKind
from .const import SettingType
from .controls.groupchat import GroupchatControl
from .dialogs import DialogButton
from .dialogs import ConfirmationDialog
from .emoji_chooser import emoji_chooser
from .settings import PopoverSetting
from .settings import SettingsBox
......@@ -920,6 +922,9 @@ def __init__(self, pref_window: Preferences) -> None:
reset_button.connect('clicked', self._on_reset_hints)
reset_button.set_sensitive(self._check_hints_reset)
purge_history_button = pref_window.get_ui().purge_history_button
purge_history_button.connect('clicked', self._on_purge_history_clicked)
@staticmethod
def _get_proxies() -> dict[str, str]:
return {proxy: proxy for proxy in app.settings.get_proxies()}
......@@ -943,6 +948,23 @@ def _on_reset_hints(self, button: Gtk.Button) -> None:
app.settings.set(hint, True)
button.set_sensitive(False)
@staticmethod
def _on_purge_history_clicked(button: Gtk.Button) -> None:
def _purge() -> None:
button.set_sensitive(False)
app.storage.archive.remove_all_history()
app.window.quit()
ConfirmationDialog(
_('Purge all Chat History'),
_('Purge all Chat History'),
_('Do you really want to remove all chat messages from Gajim?\n'
'Warning: This can’t be undone!\n'
'Gajim will quit afterwards.'),
[DialogButton.make('Cancel'),
DialogButton.make('Remove',
text=_('_Purge'),
callback=_purge)]).show()
class Advanced(PreferenceBox):
def __init__(self, pref_window: Preferences) -> None:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment