diff options
author | Philipp Hörist <philipp@hoerist.com> | 2022-10-08 14:52:10 +0300 |
---|---|---|
committer | Philipp Hörist <philipp@hoerist.com> | 2022-10-08 14:52:16 +0300 |
commit | 9abfda2a5eb1367e55c0ae6cb68e7b0c36e432ce (patch) | |
tree | cfc8f2fd191e22920046ecd0a2fdeb3efd030cf5 | |
parent | af520cce1f5b7421b703252ca75cd0b50003f8b1 (diff) |
fix: Fix disabling accounts while reconnecting
Fixes #11194
-rw-r--r-- | gajim/common/client.py | 3 | ||||
-rw-r--r-- | gajim/gtk/accounts.py | 23 |
2 files changed, 13 insertions, 13 deletions
diff --git a/gajim/common/client.py b/gajim/common/client.py index 3a96a06ef..dc666a1fe 100644 --- a/gajim/common/client.py +++ b/gajim/common/client.py @@ -568,7 +568,6 @@ class Client(Observable): 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 @@ class Client(Observable): 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) diff --git a/gajim/gtk/accounts.py b/gajim/gtk/accounts.py index 6343bc81d..b9dd69796 100644 --- a/gajim/gtk/accounts.py +++ b/gajim/gtk/accounts.py @@ -28,9 +28,8 @@ from gi.repository import Pango 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 @@ class AccountRow(Gtk.ListBoxRow): 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 @@ class AccountRow(Gtk.ListBoxRow): 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: |