Philipp Hörist pushed to branch master at gajim / gajim
Commits: 9abfda2a by Philipp Hörist at 2022-10-08T13:52:16+02:00 fix: Fix disabling accounts while reconnecting
Fixes #11194
- - - - -
2 changed files:
- gajim/common/client.py - gajim/gtk/accounts.py
Changes:
===================================== gajim/common/client.py ===================================== @@ -568,7 +568,6 @@ def _schedule_reconnect(self) -> None: def _abort_reconnect(self) -> None: self._set_state(ClientState.DISCONNECTED) self._disable_reconnect_timer() - self.notify('state-changed', SimpleClientState.DISCONNECTED)
if self._destroy_client: self._client.destroy() @@ -576,6 +575,8 @@ def _abort_reconnect(self) -> None: self._destroy_client = False self._create_client()
+ self.notify('state-changed', SimpleClientState.DISCONNECTED) + def _disable_reconnect_timer(self) -> None: if self._reconnect_timer_source is not None: GLib.source_remove(self._reconnect_timer_source)
===================================== gajim/gtk/accounts.py ===================================== @@ -28,9 +28,8 @@ from gi.repository import GObject
from gajim.common import app -from gajim.common import ged from gajim.common import passwords -from gajim.common.events import AccountDisconnected +from gajim.common.const import ClientState from gajim.common.i18n import _ from gajim.common.i18n import Q_ from gajim.common.settings import AllSettingsT @@ -541,19 +540,10 @@ def _on_enable_switch(self, state: bool, account: str ) -> int: - def _on_disconnect(event: AccountDisconnected) -> None: - if event.account != account: - return - app.ged.remove_event_handler('account-disconnected', - ged.POSTGUI, - _on_disconnect) - app.interface.disable_account(account)
def _disable() -> None: - app.ged.register_event_handler('account-disconnected', - ged.POSTGUI, - _on_disconnect) client = app.get_client(account) + client.connect_signal('state-changed', self._on_state_changed) client.change_status('offline', 'offline') switch.set_state(state) self._set_label(state) @@ -585,6 +575,15 @@ def _disable() -> None:
return Gdk.EVENT_PROPAGATE
+ def _on_state_changed(self, + client: types.Client, + _signal_name: str, + client_state: ClientState + ) -> None: + + if client_state.is_disconnected: + app.interface.disable_account(client.account) +
class AddNewAccountPage(Gtk.Box): def __init__(self) -> None:
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/9abfda2a5eb1367e55c0ae6cb68e7b0c3...