1
0

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.
This commit is contained in:
SomberNight
2020-07-16 01:00:51 +02:00
parent a1baf860b6
commit 52f8aafb60
2 changed files with 11 additions and 3 deletions

View File

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

View File

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