comparison cagou/core/cagou_main.py @ 439:12d188cb1206

core: use of new profileConnected method: bookmarks cache is now retrieved in profileConnected, as getting it in ProfilePlugged could result in an exception is client was not fully connected (if plugins were not all initialised).
author Goffi <goffi@goffi.org>
date Sat, 07 Mar 2020 00:05:49 +0100
parents 58d3ea442f9c
children 9b73a1879989
comparison
equal deleted inserted replaced
438:58d3ea442f9c 439:12d188cb1206
546 self.app.root_window.softinput_mode = "below_target" 546 self.app.root_window.softinput_mode = "below_target"
547 profile_manager = self.app._profile_manager 547 profile_manager = self.app._profile_manager
548 del self.app._profile_manager 548 del self.app._profile_manager
549 super(Cagou, self).postInit(profile_manager) 549 super(Cagou, self).postInit(profile_manager)
550 550
551 def profilePlugged(self, profile):
552 super().profilePlugged(profile)
553 # FIXME: this won't work with multiple profiles
554 self.app.connected = self.profiles[profile].connected
555
551 def _bookmarksListCb(self, bookmarks_dict, profile): 556 def _bookmarksListCb(self, bookmarks_dict, profile):
552 bookmarks = set() 557 bookmarks = set()
553 for data in bookmarks_dict.values(): 558 for data in bookmarks_dict.values():
554 bookmarks.update({jid.JID(k) for k in data.keys()}) 559 bookmarks.update({jid.JID(k) for k in data.keys()})
555 self.profiles[profile]._bookmarks = sorted(bookmarks) 560 self.profiles[profile]._bookmarks = sorted(bookmarks)
556 561
557 def profilePlugged(self, profile): 562 def profileConnected(self, profile):
558 super().profilePlugged(profile)
559 # FIXME: this won't work with multiple profiles
560 self.app.connected = self.profiles[profile].connected
561 self.bridge.bookmarksList( 563 self.bridge.bookmarksList(
562 "muc", "all", profile, 564 "muc", "all", profile,
563 callback=partial(self._bookmarksListCb, profile=profile), 565 callback=partial(self._bookmarksListCb, profile=profile),
564 errback=partial(self.errback, title=_("Bookmark error"))) 566 errback=partial(self.errback, title=_("Bookmark error")))
565 567