# HG changeset patch # User Goffi # Date 1581020181 -3600 # Node ID de066b72f5a8e715108320863f79a4a20af118f1 # Parent d61bbbac416063e77ab31db12fc2bf5fee2488c2 core: cache MUC bookmarks on startup diff -r d61bbbac4160 -r de066b72f5a8 cagou/core/cagou_main.py --- a/cagou/core/cagou_main.py Tue Feb 04 20:47:17 2020 +0100 +++ b/cagou/core/cagou_main.py Thu Feb 06 21:16:21 2020 +0100 @@ -20,6 +20,7 @@ import os.path import glob import sys +from functools import partial from sat.core.i18n import _ from . import kivy_hack kivy_hack.do_hack() @@ -514,10 +515,20 @@ del self.app._profile_manager super(Cagou, self).postInit(profile_manager) + def _bookmarksListCb(self, bookmarks_dict, profile): + bookmarks = set() + for data in bookmarks_dict.values(): + bookmarks.update({jid.JID(k) for k in data.keys()}) + self.profiles[profile]._bookmarks = sorted(bookmarks) + def profilePlugged(self, profile): super().profilePlugged(profile) # FIXME: this won't work with multiple profiles self.app.connected = self.profiles[profile].connected + self.bridge.bookmarksList( + "muc", "all", profile, + callback=partial(self._bookmarksListCb, profile=profile), + errback=partial(self.errback, title=_("Bookmark error"))) def _defaultFactoryMain(self, plugin_info, target, profiles): """default factory used to create main widgets instances