Bug 1685729 - Refresh top sites on region change. r=daleharvey
authorDão Gottwald <dao@mozilla.com>
Mon, 18 Jan 2021 13:56:44 +0000
changeset 563561 ccbeb11eca6fdbb3157af26afc10bd20909f20a5
parent 563560 13800697c49aae400f21bafa3f8c7d2ddacadacd
child 563562 c7f363ff3c4fdf8134d24ccc5db0042a4baf949d
push id38116
push usermalexandru@mozilla.com
push dateTue, 19 Jan 2021 03:30:20 +0000
treeherdermozilla-central@a0cde344a949 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdaleharvey
bugs1685729
milestone86.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1685729 - Refresh top sites on region change. r=daleharvey Differential Revision: https://phabricator.services.mozilla.com/D101473
browser/components/newtab/lib/TopSitesFeed.jsm
--- a/browser/components/newtab/lib/TopSitesFeed.jsm
+++ b/browser/components/newtab/lib/TopSitesFeed.jsm
@@ -134,24 +134,26 @@ this.TopSitesFeed = class TopSitesFeed {
     PageThumbs.addExpirationFilter(this);
   }
 
   init() {
     // If the feed was previously disabled PREFS_INITIAL_VALUES was never received
     this._readDefaults({ isStartup: true });
     this._storage = this.store.dbStorage.getDbTable("sectionPrefs");
     Services.obs.addObserver(this, "browser-search-engine-modified");
+    Services.obs.addObserver(this, "region-updated");
     Services.prefs.addObserver(REMOTE_SETTING_DEFAULTS_PREF, this);
     Services.prefs.addObserver(DEFAULT_SITES_POLICY_PREF, this);
     Services.prefs.addObserver(DEFAULT_SITES_EXPERIMENTS_PREF_BRANCH, this);
   }
 
   uninit() {
     PageThumbs.removeExpirationFilter(this);
     Services.obs.removeObserver(this, "browser-search-engine-modified");
+    Services.obs.removeObserver(this, "region-updated");
     Services.prefs.removeObserver(REMOTE_SETTING_DEFAULTS_PREF, this);
     Services.prefs.removeObserver(DEFAULT_SITES_POLICY_PREF, this);
     Services.prefs.removeObserver(DEFAULT_SITES_EXPERIMENTS_PREF_BRANCH, this);
   }
 
   observe(subj, topic, data) {
     switch (topic) {
       case "browser-search-engine-modified":
@@ -161,16 +163,19 @@ this.TopSitesFeed = class TopSitesFeed {
           data === "engine-default" &&
           this.store.getState().Prefs.values[FILTER_DEFAULT_SEARCH_PREF]
         ) {
           delete this._currentSearchHostname;
           this._currentSearchHostname = getShortURLForCurrentSearch();
           this.refresh({ broadcast: true });
         }
         break;
+      case "region-updated":
+        this._readDefaults();
+        break;
       case "nsPref:changed":
         if (
           data === REMOTE_SETTING_DEFAULTS_PREF ||
           data === DEFAULT_SITES_POLICY_PREF ||
           data.startsWith(DEFAULT_SITES_EXPERIMENTS_PREF_BRANCH)
         ) {
           this._readDefaults();
         }