Daniel Brötzmann pushed to branch mainwindow at gajim / gajim
Commits:
dd3f3735 by wurstsalat at 2021-09-13T23:09:26+02:00
StartChat: Add disco timeout and handle disconnected account
- - - - -
f38ad47c by wurstsalat at 2021-09-13T23:14:03+02:00
StartChat: Rename new row to 'Start New Chat'
- - - - -
1 changed file:
- gajim/gtk/start_chat.py
Changes:
=====================================
gajim/gtk/start_chat.py
=====================================
@@ -64,6 +64,7 @@ def __init__(self):
self._search_stopped = False
self._redirected = False
self._source_id = None
+ self._skip_disco = False
self._ui = get_builder('start_chat_dialog.ui')
self.add(self._ui.stack)
@@ -305,6 +306,7 @@ def _start_new_chat(self, row):
return
self._disco_info(row)
+ GLib.timeout_add_seconds(10, self._continue_without_disco, row)
return
if row.groupchat:
@@ -329,12 +331,23 @@ def _start_new_chat(self, row):
self.destroy()
def _disco_info(self, row):
+ if not app.account_is_available(row.account):
+ # Account is disconnected: start a 1:1 chat
+ self._continue_without_disco(row)
+ return
+
+ # Reset self._skip_disco and start a disco info
+ self._skip_disco = False
self._ui.stack.set_visible_child_name('progress')
client = app.get_client(row.account)
client.get_module('Discovery').disco_info(
row.jid, callback=self._disco_info_received, user_data=row)
def _disco_info_received(self, task):
+ if self._skip_disco:
+ # Stop here if disco time limit has been exceeded
+ return
+
row = task.get_user_data()
try:
result = task.finish()
@@ -357,6 +370,18 @@ def _disco_info_received(self, task):
row.update_chat_type()
self._start_new_chat(row)
+ def _continue_without_disco(self, row):
+ current_page = self._ui.stack.get_visible_child_name()
+ if current_page not in ('progress', 'search'):
+ # Stop here if disco info already succeeded
+ return
+
+ # Disco time limit has been exceeded, chat type is unknown:
+ # start a 1:1 chat
+ self._skip_disco = True
+ row.update_chat_type()
+ self._start_new_chat(row)
+
def _disco_muc(self, account, jid, request_vcard):
self._ui.stack.set_visible_child_name('progress')
client = app.get_client(account)
@@ -692,10 +717,7 @@ def __init__(self, account, contact, jid, name,
show_account,
box.set_hexpand(True)
if self.name is None:
- if self.groupchat:
- self.name = _('Join Group Chat')
- else:
- self.name = _('Start Chat')
+ self.name = _('Start New Chat')
self.name_label = Gtk.Label(label=self.name)
self.name_label.set_ellipsize(Pango.EllipsizeMode.END)
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/a84557cd43f9fec52ad60d1b6c46ac979febbbb3...f38ad47cce0da2c2a8841d50e54a1e2904e23b0b
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/a84557cd43f9fec52ad60d1b6c46ac979febbbb3...f38ad47cce0da2c2a8841d50e54a1e2904e23b0b
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits