[gnome-calculator/wip/rstrode/no-network-plz: 2/5] currency-provider: Don't ever download rates if refresh interval is 0




commit 669f2d9f69746384cdf4bd5104ae7a9df7ea4b4f
Author: Ray Strode <rstrode redhat com>
Date:   Thu May 13 10:44:33 2021 -0400

    currency-provider: Don't ever download rates if refresh interval is 0
    
    If an admin has set the currency refresh interval to 0 they probably
    don't ever want the data refreshed from the network.
    
    This commit treats a refresh interval of 0 specially to mean
    "don't go on the network at all"

 data/org.gnome.calculator.gschema.xml | 2 +-
 lib/currency-provider.vala            | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/data/org.gnome.calculator.gschema.xml b/data/org.gnome.calculator.gschema.xml
index a3af435f..fbde9b53 100644
--- a/data/org.gnome.calculator.gschema.xml
+++ b/data/org.gnome.calculator.gschema.xml
@@ -60,7 +60,7 @@
     <key name="refresh-interval" type="i">
       <default>604800</default>
       <summary>Currency update interval</summary>
-      <description>How often the currency exchange rates should be updated</description>
+      <description>How often the currency exchange rates should be updated. A value of 0 means the currency 
exchange rates won't be fetched from the network at all.</description>
     </key>
     <key name="button-mode" enum="org.gnome.calculator.ButtonMode">
       <default>'basic'</default>
diff --git a/lib/currency-provider.vala b/lib/currency-provider.vala
index 9c9fd5c8..1690536e 100644
--- a/lib/currency-provider.vala
+++ b/lib/currency-provider.vala
@@ -45,6 +45,8 @@ public abstract class AbstractCurrencyProvider : Object, CurrencyProvider {
 
         if (loading || loaded) return;
 
+        if (refresh_interval == 0) return;
+
         debug ("Checking %s rates ".printf(source_name));
 
         if (!file_needs_update (rate_filepath, refresh_interval )) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]