Skip to content
Snippets Groups Projects
Commit 950489cf authored by Vincent Texier's avatar Vincent Texier
Browse files

Membership expiration alert on opening currency tab, not at each block refresh

parent 371493c8
No related branches found
No related tags found
No related merge requests found
......@@ -92,6 +92,25 @@ class CurrencyTabWidget(QWidget, Ui_CurrencyTabWidget):
self.watcher_thread.start()
person = Person.lookup(self.app.current_account.pubkey, self.community)
join_block = person.membership(self.community).block_number
join_date = self.community.get_block(join_block).mediantime
parameters = self.community.get_parameters()
expiration_date = join_date + parameters['sigValidity']
current_time = time.time()
sig_validity = self.community.get_parameters()['sigValidity']
warning_expiration_time = int(sig_validity / 3)
will_expire_soon = (current_time > expiration_date - warning_expiration_time)
if will_expire_soon:
days = QDateTime().currentDateTime().daysTo(QDateTime.fromTime_t(expiration_date))
QMessageBox.warning(
self,
"Membership expiration",
"Warning : Membership expiration in {0} days".format(days),
QMessageBox.Ok
)
def refresh(self):
if self.app.current_account is None:
self.tabs_account.setEnabled(False)
......@@ -171,27 +190,9 @@ class CurrencyTabWidget(QWidget, Ui_CurrencyTabWidget):
QModelIndex(),
[])
person = Person.lookup(self.app.current_account.pubkey, self.community)
join_block = person.membership(self.community).block_number
join_date = self.community.get_block(join_block).mediantime
parameters = self.community.get_parameters()
expiration_date = join_date + parameters['sigValidity']
current_time = time.time()
sig_validity = self.community.get_parameters()['sigValidity']
warning_expiration_time = int(sig_validity / 3)
will_expire_soon = (current_time > expiration_date - warning_expiration_time)
text = "Connected : Block {0}".format(block_number)
self.status_label.setText(text)
if will_expire_soon:
days = QDateTime().currentDateTime().daysTo(QDateTime.fromTime_t(expiration_date))
QMessageBox.warning(
self,
"Membership expiration",
"Warning : Membership expiration in {0} days".format(days),
QMessageBox.Ok
)
def refresh_wallets(self):
if self.app.current_account:
wallets_list_model = WalletsListModel(self.app.current_account,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment