mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-18 07:45:30 +00:00
Bug 1609758 - personalization affinities lastUpdated in devtools and refreshAll tweak and some unrelated test updates r=gvn
Differential Revision: https://phabricator.services.mozilla.com/D60178 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
527b3ff65b
commit
b225185523
@ -717,6 +717,15 @@ this.DiscoveryStreamFeed = class DiscoveryStreamFeed {
|
||||
);
|
||||
|
||||
this.domainAffinitiesLastUpdated = affinities._timestamp;
|
||||
|
||||
this.store.dispatch(
|
||||
ac.BroadcastToContent({
|
||||
type: at.DISCOVERY_STREAM_PERSONALIZATION_LAST_UPDATED,
|
||||
data: {
|
||||
lastUpdated: this.domainAffinitiesLastUpdated,
|
||||
},
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -741,6 +750,15 @@ this.DiscoveryStreamFeed = class DiscoveryStreamFeed {
|
||||
|
||||
const affinities = this.affinityProvider.getAffinities();
|
||||
this.domainAffinitiesLastUpdated = Date.now();
|
||||
|
||||
this.store.dispatch(
|
||||
ac.BroadcastToContent({
|
||||
type: at.DISCOVERY_STREAM_PERSONALIZATION_LAST_UPDATED,
|
||||
data: {
|
||||
lastUpdated: this.domainAffinitiesLastUpdated,
|
||||
},
|
||||
})
|
||||
);
|
||||
affinities._timestamp = this.domainAffinitiesLastUpdated;
|
||||
this.cache.set("affinities", affinities);
|
||||
}
|
||||
@ -1036,7 +1054,7 @@ this.DiscoveryStreamFeed = class DiscoveryStreamFeed {
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {Object} RefreshAllOptions
|
||||
* @typedef {Object} RefreshAll
|
||||
* @property {boolean} updateOpenTabs - Sends updates to open tabs immediately if true,
|
||||
* updates in background if false
|
||||
* @property {boolean} isStartup - When the function is called at browser startup
|
||||
@ -1045,13 +1063,17 @@ this.DiscoveryStreamFeed = class DiscoveryStreamFeed {
|
||||
* @param {RefreshAllOptions} options
|
||||
*/
|
||||
async refreshAll(options = {}) {
|
||||
this.loadAffinityScoresCache();
|
||||
await this.refreshContent(options);
|
||||
}
|
||||
|
||||
async refreshContent(options = {}) {
|
||||
const { updateOpenTabs, isStartup } = options;
|
||||
const storiesEnabled = this.store.getState().Prefs.values[PREF_TOPSTORIES];
|
||||
const dispatch = updateOpenTabs
|
||||
? action => this.store.dispatch(ac.BroadcastToContent(action))
|
||||
: this.store.dispatch;
|
||||
|
||||
this.loadAffinityScoresCache();
|
||||
await this.loadLayout(dispatch, isStartup);
|
||||
if (storiesEnabled) {
|
||||
await Promise.all([
|
||||
@ -1244,6 +1266,7 @@ this.DiscoveryStreamFeed = class DiscoveryStreamFeed {
|
||||
this.store.dispatch(
|
||||
ac.BroadcastToContent({ type: at.DISCOVERY_STREAM_LAYOUT_RESET })
|
||||
);
|
||||
this.domainAffinitiesLastUpdated = null;
|
||||
this.loaded = false;
|
||||
this.layoutRequestTime = undefined;
|
||||
this.spocsRequestTime = undefined;
|
||||
|
@ -2500,6 +2500,11 @@ describe("DiscoveryStreamFeed", () => {
|
||||
});
|
||||
|
||||
describe("#updateDomainAffinityScores", () => {
|
||||
it("should call updateDomainAffinityScores on idle daily", async () => {
|
||||
sandbox.stub(feed, "updateDomainAffinityScores").returns();
|
||||
feed.observe(null, "idle-daily");
|
||||
assert.calledOnce(feed.updateDomainAffinityScores);
|
||||
});
|
||||
it("should update affinity provider on idle daily", async () => {
|
||||
feed._prefCache.config = {
|
||||
personalized: true,
|
||||
@ -2571,6 +2576,8 @@ describe("DiscoveryStreamFeed", () => {
|
||||
value: 0,
|
||||
})
|
||||
);
|
||||
|
||||
assert.calledOnce(feed.store.dispatch);
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user