comparison cagou/core/cagou_main.py @ 388:de066b72f5a8

core: cache MUC bookmarks on startup
author Goffi <goffi@goffi.org>
date Thu, 06 Feb 2020 21:16:21 +0100
parents 6dacaf81339a
children ae6f7fd1cb0e
comparison
equal deleted inserted replaced
387:d61bbbac4160 388:de066b72f5a8
18 18
19 19
20 import os.path 20 import os.path
21 import glob 21 import glob
22 import sys 22 import sys
23 from functools import partial
23 from sat.core.i18n import _ 24 from sat.core.i18n import _
24 from . import kivy_hack 25 from . import kivy_hack
25 kivy_hack.do_hack() 26 kivy_hack.do_hack()
26 from cagou.backport import do_backport 27 from cagou.backport import do_backport
27 do_backport() 28 do_backport()
512 self.app.root_window.softinput_mode = "below_target" 513 self.app.root_window.softinput_mode = "below_target"
513 profile_manager = self.app._profile_manager 514 profile_manager = self.app._profile_manager
514 del self.app._profile_manager 515 del self.app._profile_manager
515 super(Cagou, self).postInit(profile_manager) 516 super(Cagou, self).postInit(profile_manager)
516 517
518 def _bookmarksListCb(self, bookmarks_dict, profile):
519 bookmarks = set()
520 for data in bookmarks_dict.values():
521 bookmarks.update({jid.JID(k) for k in data.keys()})
522 self.profiles[profile]._bookmarks = sorted(bookmarks)
523
517 def profilePlugged(self, profile): 524 def profilePlugged(self, profile):
518 super().profilePlugged(profile) 525 super().profilePlugged(profile)
519 # FIXME: this won't work with multiple profiles 526 # FIXME: this won't work with multiple profiles
520 self.app.connected = self.profiles[profile].connected 527 self.app.connected = self.profiles[profile].connected
528 self.bridge.bookmarksList(
529 "muc", "all", profile,
530 callback=partial(self._bookmarksListCb, profile=profile),
531 errback=partial(self.errback, title=_("Bookmark error")))
521 532
522 def _defaultFactoryMain(self, plugin_info, target, profiles): 533 def _defaultFactoryMain(self, plugin_info, target, profiles):
523 """default factory used to create main widgets instances 534 """default factory used to create main widgets instances
524 535
525 used when PLUGIN_INFO["factory"] is not set 536 used when PLUGIN_INFO["factory"] is not set