commit 52f8aafb604d05487a0612f65bacb966c0d0f569
parent a1baf860b6fadeb0cf1c0a0083fff1341954b572
Author: SomberNight <somber.night@protonmail.com>
Date: Thu, 16 Jul 2020 01:00:51 +0200
kivy: fix fx history rates defaults.
In kivy, if the user enabled fx rates but did not touch the fx history settings,
the GUI would show that history rates are enabled but in fact they would be disabled:
the GUI called fx.get_history_config(default=True) when displaying the checkbox,
but exchange_rate.py would not fetch history rates.
(it would only get fixed if the user touched the fx history checkbox)
Note: FxThread.run() calls fx.show_history(), which calls fx.get_history_config() without arguments.
Diffstat:
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/electrum/exchange_rate.py b/electrum/exchange_rate.py
@@ -516,8 +516,11 @@ class FxThread(ThreadJob):
self.config.set_key('use_exchange_rate', bool(b))
self.trigger_update()
- def get_history_config(self, *, default=False):
- return bool(self.config.get('history_rates', default))
+ def get_history_config(self, *, allow_none=False):
+ val = self.config.get('history_rates', None)
+ if val is None and allow_none:
+ return None
+ return bool(val)
def set_history_config(self, b):
self.config.set_key('history_rates', bool(b))
diff --git a/electrum/gui/kivy/uix/dialogs/fx_dialog.py b/electrum/gui/kivy/uix/dialogs/fx_dialog.py
@@ -89,7 +89,12 @@ class FxDialog(Factory.Popup):
self.config = config
self.callback = callback
self.fx = self.app.fx
- self.has_history_rates = self.fx.get_history_config(default=True)
+ if self.fx.get_history_config(allow_none=True) is None:
+ # If nothing is set, force-enable it. (Note that as fiat rates itself
+ # are disabled by default, it is enough to set this here. If they
+ # were enabled by default, this would be too late.)
+ self.fx.set_history_config(True)
+ self.has_history_rates = self.fx.get_history_config()
Factory.Popup.__init__(self)
self.add_currencies()