Philipp Hörist pushed to branch master at gajim / gajim
Commits:
72340e43 by Nicoco at 2024-09-11T14:05:45+00:00
feat: Add setting to prevent sync of group chats
- - - - -
4 changed files:
- gajim/common/client.py
- gajim/common/modules/bookmarks.py
- gajim/common/setting_values.py
- gajim/gtk/accounts.py
Changes:
=====================================
gajim/common/client.py
=====================================
@@ -206,6 +206,9 @@ def _set_client_available(self) -> None:
self._set_state(ClientState.AVAILABLE)
app.ged.raise_event(AccountConnected(account=self._account))
+ if not app.settings.get_account_setting(self._account,
'autojoin_sync'):
+ self.join_mucs()
+
def disconnect(self,
gracefully: bool,
reconnect: bool,
@@ -639,6 +642,17 @@ def _screensaver_state_changed(application:
Gtk.Application,
active = application.get_property('screensaver-active')
Monitor.set_extended_away(active)
+ def join_mucs(self) -> None:
+ '''Only used when autojoin_sync is False'''
+ self._log.info('Joining all MUCs in all workspaces')
+ for workspace_id in app.settings.get_workspaces():
+ for chat in app.settings.get_workspace_setting(
+ workspace_id, 'chats'):
+ if chat['account'] != self._account:
+ continue
+ if chat['type'] == 'groupchat':
+ self.get_module('MUC').join(chat['jid'])
+
def cleanup(self) -> None:
self.disconnect_signals()
self._destroyed = True
=====================================
gajim/common/modules/bookmarks.py
=====================================
@@ -169,9 +169,10 @@ def _act_on_changed_bookmarks(self,
# If another client creates a MUC, the MUC is locked until the
# configuration is finished. Give the user some time to finish
# the configuration.
- timeout_id = GLib.timeout_add_seconds(
- 10, self._join_with_timeout, bookmarks)
- self._join_timeouts.append(timeout_id)
+ if app.settings.get_account_setting(self._account, 'autojoin_sync'):
+ timeout_id = GLib.timeout_add_seconds(
+ 10, self._join_with_timeout, bookmarks)
+ self._join_timeouts.append(timeout_id)
# TODO: leave mucs
# leave = [jid for jid, autojoin in changed if not autojoin]
@@ -217,7 +218,8 @@ def _bookmarks_received(self, task: Task) -> None:
self._cleanup_bookmarks(bookmarks)
self._bookmarks = self._convert_to_dict(bookmarks)
- self.auto_join_bookmarks(self.bookmarks)
+ if app.settings.get_account_setting(self._account, 'autojoin_sync'):
+ self.auto_join_bookmarks(self.bookmarks)
app.ged.raise_event(
BookmarksReceived(account=self._account))
@@ -269,6 +271,8 @@ def modify(self, jid: JID, **kwargs: Any) -> None:
self.store_bookmarks([new_bookmark])
def add_or_modify(self, jid: JID, **kwargs: Any) -> None:
+ if not app.settings.get_account_setting(self._account,
'autojoin_sync'):
+ kwargs.pop('autojoin', None)
bookmark = self._bookmarks.get(jid)
if bookmark is not None:
self.modify(jid, **kwargs)
=====================================
gajim/common/setting_values.py
=====================================
@@ -291,6 +291,7 @@ class _ACCOUNTDEFAULT:
'answer_receipts',
'autoauth',
'autoconnect',
+ 'autojoin_sync',
'client_cert_encrypted',
'confirm_unencrypted_connection',
'enable_gssapi',
@@ -420,6 +421,7 @@ class _ACCOUNTDEFAULT:
'attached_gpg_keys': '',
'autoauth': False,
'autoconnect': True,
+ 'autojoin_sync': True,
'autopriority_away': 40,
'autopriority_chat': 50,
'autopriority_dnd': 20,
=====================================
gajim/gtk/accounts.py
=====================================
@@ -1050,7 +1050,13 @@ def __init__(self, account: str) -> None:
SettingType.ACCOUNT_CONFIG,
'enable_security_labels',
desc=_('Show labels describing confidentiality of '
- 'messages, if the server supports XEP-0258'))
+ 'messages, if the server supports XEP-0258')),
+ Setting(SettingKind.SWITCH,
+ _('Synchronise joined group chats'),
+ SettingType.ACCOUNT_CONFIG,
+ 'autojoin_sync',
+ desc=_(
+ 'Synchronize joined group chats with other devices.')),
]
GenericSettingPage.__init__(self, account, settings)
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/72340e4303d33926205e34f8f052d8097032608f
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/72340e4303d33926205e34f8f052d8097032608f
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]