Philipp Hörist pushed to branch master at gajim / gajim


Commits:
727beb71 by lovetox at 2022-05-23T19:23:08+02:00
fix: Reset conversation view when switching chat

This may help to work around the issue that sometimes the ConversationView
freezes.

- - - - -
ed6c3ce3 by lovetox at 2022-05-23T19:23:30+02:00
ci: Windows: Rename executable

- - - - -


5 changed files:

- .ci/appveyor.yml
- gajim/gtk/chat_page.py
- gajim/gtk/chat_stack.py
- gajim/gtk/const.py
- gajim/gtk/main.py


Changes:

=====================================
.ci/appveyor.yml
=====================================
@@ -33,7 +33,7 @@ build_script:
 
   - ps: |
         $filename = "Gajim-$($env:GAJIM_VERSION)-$($env:ARCH)"
-        $filename_portable = 
"Gajim-$($env:GAJIM_VERSION)-Portable-$($env:ARCH)"
+        $filename_portable = 
"Gajim-Portable-$($env:GAJIM_VERSION)-$($env:ARCH)"
 
         if ($env:GAJIM_VERSION -eq "Nightly") {
             $time_string=(get-date -UFormat "%Y-%m-%d").ToString()


=====================================
gajim/gtk/chat_page.py
=====================================
@@ -17,7 +17,6 @@
 from typing import Optional
 from typing import Generator
 
-import time
 import logging
 
 from gi.repository import Gdk
@@ -38,7 +37,6 @@
 from .chat_stack import ChatStack
 from .search_view import SearchView
 from .types import ControlT
-from .const import UNLOAD_CHAT_TIME
 
 
 log = logging.getLogger('gajim.gui.chat_page')
@@ -55,8 +53,6 @@ class ChatPage(Gtk.Box):
     def __init__(self):
         Gtk.Box.__init__(self)
 
-        self._chat_idle_time: dict[tuple[str, JID], Optional[float]] = {}
-
         self._ui = get_builder('chat_paned.ui')
         self.add(self._ui.paned)
         self._ui.connect_signals(self)
@@ -146,31 +142,6 @@ def _on_filter_revealer_toggled(self,
     def _on_edit_workspace_clicked(_button: Gtk.Button) -> None:
         app.window.activate_action('edit-workspace', GLib.Variant('s', ''))
 
-    def _reset_chat_idle_time(self, account: str, jid: JID) -> None:
-        # Set the idle time of the current chat to None
-        # and start the timer for the last one
-        for chat, idle_time in self._chat_idle_time.items():
-            if idle_time is None:
-                self._chat_idle_time[chat] = time.time()
-
-        self._chat_idle_time[(account, jid)] = None
-
-    def unload_idle_chats(self) -> bool:
-        log.debug('Unload idle chats')
-        for chat, idle_time in list(self._chat_idle_time.items()):
-            if idle_time is None:
-                continue
-
-            if time.time() - UNLOAD_CHAT_TIME > idle_time:
-                account, jid = chat
-                self._chat_stack.unload_chat(account, jid)
-                self._chat_idle_time.pop(chat)
-                log.debug('Chat %s:%s unloaded', account, jid)
-
-        # Return true because we call this method with
-        # GLib.timeout_add_seconds()
-        return True
-
     def _on_chat_selected(self,
                           _chat_list_stack: ChatListStack,
                           workspace_id: str,
@@ -180,7 +151,6 @@ def _on_chat_selected(self,
         self._chat_stack.show_chat(account, jid)
         self._search_view.set_context(account, jid)
         self.emit('chat-selected', workspace_id, account, jid)
-        self._reset_chat_idle_time(account, jid)
 
     def _on_chat_unselected(self, _chat_list_stack: ChatListStack) -> None:
         self._chat_stack.clear()


=====================================
gajim/gtk/chat_stack.py
=====================================
@@ -118,6 +118,8 @@ def show_chat(self, account: str, jid: JID) -> None:
 
         if self._current_control is not None:
             self._current_control.set_control_active(False)
+            self._current_control.reset_view()
+
         control.set_control_active(True)
         self._current_control = control
 
@@ -130,12 +132,6 @@ def is_chat_loaded(self, account: str, jid: JID) -> bool:
             return False
         return control.is_chat_loaded
 
-    def unload_chat(self, account: str, jid: JID) -> None:
-        control = self.get_control(account, jid)
-        if control is None:
-            return
-        control.reset_view()
-
     def clear(self) -> None:
         self.set_visible_child_name('empty')
         self._current_control = None


=====================================
gajim/gtk/const.py
=====================================
@@ -55,8 +55,6 @@ class Setting(NamedTuple):
 # Drag and drop target type URI list (for dropped files)
 TARGET_TYPE_URI_LIST = 80
 
-UNLOAD_CHAT_TIME = 300  # seconds
-
 
 @unique
 class Theme(IntEnum):


=====================================
gajim/gtk/main.py
=====================================
@@ -57,7 +57,6 @@
 from .util import save_main_window_position
 from .util import open_window
 from .util import set_urgency_hint
-from .const import UNLOAD_CHAT_TIME
 from .structs import AccountJidParam
 from .structs import AddChatActionParams
 from .structs import actionmethod
@@ -145,7 +144,6 @@ def __init__(self) -> None:
         self._add_actions2()
 
         self._prepare_window()
-        self._start_timers()
 
         chat_list_stack = self._chat_page.get_chat_list_stack()
         app.app.systray.connect_unread_widget(chat_list_stack,
@@ -155,10 +153,6 @@ def __init__(self) -> None:
             client.connect_signal('state-changed',
                                   self._on_client_state_changed)
 
-    def _start_timers(self) -> None:
-        GLib.timeout_add_seconds(UNLOAD_CHAT_TIME,
-                                 self._chat_page.unload_idle_chats)
-
     def _prepare_window(self) -> None:
         if app.settings.get('main_window_skip_taskbar'):
             self.set_property('skip-taskbar-hint', True)



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/compare/80112fedddb833fb9559c5fc29b175e21bbcc242...ed6c3ce33d05311fa1dec2032f9516e2976fbc8f

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/compare/80112fedddb833fb9559c5fc29b175e21bbcc242...ed6c3ce33d05311fa1dec2032f9516e2976fbc8f
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

Reply via email to