зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1891108 - Home and newtab followup wallpaper fixes r=home-newtab-reviewers,nbarrett
Differential Revision: https://phabricator.services.mozilla.com/D207308
This commit is contained in:
Родитель
5da22a369a
Коммит
2e339d10ff
|
@ -42,7 +42,7 @@ export class _WallpapersSection extends React.PureComponent {
|
|||
}
|
||||
|
||||
handleReset() {
|
||||
this.props.setPref("newtabWallpapers.wallpaper", "i");
|
||||
this.props.setPref("newtabWallpapers.wallpaper", "");
|
||||
}
|
||||
|
||||
render() {
|
||||
|
|
|
@ -8881,7 +8881,7 @@ class _WallpapersSection extends (external_React_default()).PureComponent {
|
|||
this.props.setPref("newtabWallpapers.wallpaper", id);
|
||||
}
|
||||
handleReset() {
|
||||
this.props.setPref("newtabWallpapers.wallpaper", "i");
|
||||
this.props.setPref("newtabWallpapers.wallpaper", "");
|
||||
}
|
||||
render() {
|
||||
const {
|
||||
|
|
|
@ -40,7 +40,7 @@ export class WallpaperFeed {
|
|||
return lazy.RemoteSettings(...args);
|
||||
}
|
||||
|
||||
async wallpaperSetup() {
|
||||
async wallpaperSetup(isStartup = false) {
|
||||
const wallpapersEnabled = Services.prefs.getBoolPref(
|
||||
PREF_WALLPAPERS_ENABLED
|
||||
);
|
||||
|
@ -52,7 +52,7 @@ export class WallpaperFeed {
|
|||
|
||||
await this.getBaseAttachment();
|
||||
this.wallpaperClient.on("sync", () => this.updateWallpapers());
|
||||
this.updateWallpapers();
|
||||
this.updateWallpapers(isStartup);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ export class WallpaperFeed {
|
|||
}
|
||||
}
|
||||
|
||||
async updateWallpapers() {
|
||||
async updateWallpapers(isStartup = false) {
|
||||
const records = await this.wallpaperClient.get();
|
||||
if (!records?.length) {
|
||||
return;
|
||||
|
@ -89,6 +89,9 @@ export class WallpaperFeed {
|
|||
ac.BroadcastToContent({
|
||||
type: at.WALLPAPERS_SET,
|
||||
data: wallpapers,
|
||||
meta: {
|
||||
isStartup,
|
||||
},
|
||||
})
|
||||
);
|
||||
}
|
||||
|
@ -96,7 +99,7 @@ export class WallpaperFeed {
|
|||
async onAction(action) {
|
||||
switch (action.type) {
|
||||
case at.INIT:
|
||||
await this.wallpaperSetup();
|
||||
await this.wallpaperSetup(true /* isStartup */);
|
||||
break;
|
||||
case at.UNINIT:
|
||||
break;
|
||||
|
@ -104,7 +107,7 @@ export class WallpaperFeed {
|
|||
break;
|
||||
case at.PREF_CHANGED:
|
||||
if (action.data.name === "newtabWallpapers.enabled") {
|
||||
await this.wallpaperSetup();
|
||||
await this.wallpaperSetup(false /* isStartup */);
|
||||
}
|
||||
break;
|
||||
case at.WALLPAPERS_SET:
|
||||
|
|
|
@ -84,6 +84,9 @@ add_task(async function test_onAction_INIT() {
|
|||
wallpaperUrl: "http://localhost:8888/base_url/attachment",
|
||||
},
|
||||
],
|
||||
meta: {
|
||||
isStartup: true,
|
||||
},
|
||||
})
|
||||
)
|
||||
);
|
||||
|
@ -105,6 +108,7 @@ add_task(async function test_onAction_PREF_CHANGED() {
|
|||
});
|
||||
|
||||
Assert.ok(feed.wallpaperSetup.calledOnce);
|
||||
Assert.ok(feed.wallpaperSetup.calledWith(false));
|
||||
|
||||
Services.prefs.clearUserPref(PREF_WALLPAPERS_ENABLED);
|
||||
sandbox.restore();
|
||||
|
|
Загрузка…
Ссылка в новой задаче