Skip to content
This repository has been archived by the owner on Feb 29, 2020. It is now read-only.

Commit

Permalink
fix(topsites): Refresh TopSitesFeed when TippyTopProvider init is com…
Browse files Browse the repository at this point in the history
…plete (#3088)
  • Loading branch information
rlr authored and Mardak committed Aug 3, 2017
1 parent 3285650 commit 835317a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 5 additions & 2 deletions system-addon/lib/TopSitesFeed.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ this.TopSitesFeed = class TopSitesFeed {
constructor() {
this.lastUpdated = 0;
this._tippyTopProvider = new TippyTopProvider();
this._tippyTopProvider.init();
this.dedupe = new Dedupe(this._dedupeKey);
}
_dedupeKey(site) {
Expand Down Expand Up @@ -137,8 +136,12 @@ this.TopSitesFeed = class TopSitesFeed {
data: this._getPinnedWithData()
}));
}
onAction(action) {
async onAction(action) {
switch (action.type) {
case at.INIT:
await this._tippyTopProvider.init();
this.refresh();
break;
case at.NEW_TAB_LOAD:
if (
// When a new tab is opened, if the last time we refreshed the data
Expand Down
7 changes: 6 additions & 1 deletion system-addon/test/unit/lib/TopSitesFeed.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const FAKE_SCREENSHOT = "data123";

function FakeTippyTopProvider() {}
FakeTippyTopProvider.prototype = {
init() {},
async init() {},
processSite(site) { return site; }
};

Expand Down Expand Up @@ -335,5 +335,10 @@ describe("Top Sites Feed", () => {
assert.calledOnce(feed.store.dispatch);
assert.propertyVal(feed.store.dispatch.firstCall.args[0], "type", at.TOP_SITES_UPDATED);
});
it("should call refresh on INIT action", async () => {
sinon.stub(feed, "refresh");
await feed.onAction({type: at.INIT});
assert.calledOnce(feed.refresh);
});
});
});

0 comments on commit 835317a

Please sign in to comment.