diff --git a/src/cutecoin/core/account.py b/src/cutecoin/core/account.py index 1cfa5fb2543de7e8aff1cc1d8484245a1ec415fc..4efdaf9ac5d7371e65a97daa6a010ccfef36d419 100644 --- a/src/cutecoin/core/account.py +++ b/src/cutecoin/core/account.py @@ -597,6 +597,10 @@ class Account(QObject): return self.broadcast_error.emit(r.error(), strdata) + def start_coroutines(self): + for c in self.communities: + c.start_coroutines() + def stop_coroutines(self): for c in self.communities: c.stop_coroutines() diff --git a/src/cutecoin/core/app.py b/src/cutecoin/core/app.py index 6e8344f102bb586984da4660503e22429ab42f34..4cb7c3cae5df9794282da3b226e8daebc81e63da 100644 --- a/src/cutecoin/core/app.py +++ b/src/cutecoin/core/app.py @@ -178,6 +178,7 @@ class Application(QObject): self.stop_current_account() self.current_account = account + self.current_account.start_coroutines() def stop_current_account(self): """ diff --git a/src/cutecoin/core/community.py b/src/cutecoin/core/community.py index 6d4eb5dc167dcd75f26c0bc4170cd99f4621900f..c0a6903f29c8a5d0406e1b80af62bc472b532f44 100644 --- a/src/cutecoin/core/community.py +++ b/src/cutecoin/core/community.py @@ -292,6 +292,9 @@ class Community(QObject): memberships = self.bma_access.get(self, qtbma.wot.Members) return [m['pubkey'] for m in memberships["results"]] + def start_coroutines(self): + self.network.start_coroutines() + def stop_coroutines(self): self.network.stop_coroutines() diff --git a/src/cutecoin/core/net/network.py b/src/cutecoin/core/net/network.py index f0c9a7e7786b1e9c6b268b5d1569bf8be64ab5ac..ffac7223e416559da8f25a1429391727d21ee16f 100644 --- a/src/cutecoin/core/net/network.py +++ b/src/cutecoin/core/net/network.py @@ -112,6 +112,13 @@ class Network(QObject): ratio_synced = synced / total return ratio_synced + def start_coroutines(self): + """ + Start network nodes crawling + :return: + """ + asyncio.async(self.discover_network()) + def stop_coroutines(self): """ Stop network nodes crawling. diff --git a/src/cutecoin/gui/currency_tab.py b/src/cutecoin/gui/currency_tab.py index 9073c101f9e5db66535f4dc3d94f5da1cea8e57b..5d4883073187ae4ca1f8350eaa4e3f164e95f223 100644 --- a/src/cutecoin/gui/currency_tab.py +++ b/src/cutecoin/gui/currency_tab.py @@ -184,7 +184,6 @@ class CurrencyTabWidget(QWidget, Ui_CurrencyTabWidget): self.status_label.setText(label_text) def showEvent(self, event): - asyncio.async(self.community.network.discover_network()) self.refresh_status() def referential_changed(self): diff --git a/src/cutecoin/gui/wallets_tab.py b/src/cutecoin/gui/wallets_tab.py index 0010e49ecdadd48116f93c4aa338b1df21458c04..881c18ee94a1afa94d5b5844856e5cf1b7ed7a54 100644 --- a/src/cutecoin/gui/wallets_tab.py +++ b/src/cutecoin/gui/wallets_tab.py @@ -82,23 +82,43 @@ class WalletsTabWidget(QWidget, Ui_WalletsTab): QLocale(), QDateTime.fromTime_t(expiration).date(), QLocale.dateFormat(QLocale(), QLocale.LongFormat) ) - # set infos in label - self.label_general.setText( - self.tr(""" - <table cellpadding="5"> - <tr><td align="right"><b>{:}</b></td><td>{:}</td></tr> - <tr><td align="right"><b>{:}</b></td><td>{:}</td></tr> - <tr><td align="right"><b>{:}</b></td><td>{:}</td></tr> - </table> - """).format( - self.account.name, self.account.pubkey, - self.tr("Membership"), - self.tr("Last renewal on {:}, expiration on {:}").format(date_renewal, date_expiration), - self.tr("Your web of trust"), - self.tr("Certified by {:} members; Certifier of {:} members").format(len(certifiers), - len(certified)) + + if self.account.pubkey in self.community.members_pubkeys(): + # set infos in label + self.label_general.setText( + self.tr(""" + <table cellpadding="5"> + <tr><td align="right"><b>{:}</b></td><td>{:}</td></tr> + <tr><td align="right"><b>{:}</b></td><td>{:}</td></tr> + <tr><td align="right"><b>{:}</b></td><td>{:}</td></tr> + </table> + """).format( + self.account.name, self.account.pubkey, + self.tr("Membership"), + self.tr("Last renewal on {:}, expiration on {:}").format(date_renewal, date_expiration), + self.tr("Your web of trust"), + self.tr("Certified by {:} members; Certifier of {:} members").format(len(certifiers), + len(certified)) + ) + ) + else: + # set infos in label + self.label_general.setText( + self.tr(""" + <table cellpadding="5"> + <tr><td align="right"><b>{:}</b></td><td>{:}</td></tr> + <tr><td align="right"><b>{:}</b></td><td>{:}</td></tr> + <tr><td align="right"><b>{:}</b></td><td>{:}</td></tr> + </table> + """).format( + self.account.name, self.account.pubkey, + self.tr("Not a member"), + self.tr("Last renewal on {:}, expiration on {:}").format(date_renewal, date_expiration), + self.tr("Your web of trust"), + self.tr("Certified by {:} members; Certifier of {:} members").format(len(certifiers), + len(certified)) + ) ) - ) else: # set infos in label self.label_general.setText(