Browse Source

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.
bip39-recovery
SomberNight 5 years ago
parent
commit
52f8aafb60
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 7
      electrum/exchange_rate.py
  2. 7
      electrum/gui/kivy/uix/dialogs/fx_dialog.py

7
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))

7
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()

Loading…
Cancel
Save