mirror of
https://github.com/zen-browser/desktop.git
synced 2025-09-05 19:08:18 +00:00
Refactor Zen API integration and update match URL patterns for theme marketplace
This commit is contained in:
@@ -94,8 +94,8 @@ pref('zen.view.show-newtab-button-top', false);
|
||||
pref('zen.rice.api.url', 'https://share.zen-browser.app', locked);
|
||||
pref('zen.injections.match-urls', 'https://zen-browser.app/*,https://share.zen-browser.app/*', locked);
|
||||
#else
|
||||
pref('zen.rice.api.url', "http://localhost:3000", locked);
|
||||
pref('zen.injections.match-urls', 'http://localhost:3000/*', locked);
|
||||
pref('zen.rice.api.url', "http://localhost", locked);
|
||||
pref('zen.injections.match-urls', 'http://localhost/*', locked);
|
||||
#endif
|
||||
pref('zen.rice.share.notice.accepted', false);
|
||||
|
||||
|
@@ -381,7 +381,7 @@
|
||||
document.getElementById("zen-rice-share-second-form").setAttribute("fade-out", "true");
|
||||
successBox.removeAttribute("hidden");
|
||||
const link = document.getElementById("zen-rice-share-success-link");
|
||||
link.value = `${ZEN_RICE_API}/${slug}`;
|
||||
link.value = `${ZEN_RICE_API}/rices/${slug}`;
|
||||
this.showConffetti();
|
||||
}, 2000);
|
||||
}
|
||||
|
@@ -313,5 +313,5 @@ gZenActorsManager.addJSWindowActor("ZenThemeMarketplace", {
|
||||
DOMContentLoaded: {},
|
||||
},
|
||||
},
|
||||
matches: [Services.prefs.getStringPref("zen.injections.match-urls").split(","), "about:preferences"],
|
||||
matches: [...Services.prefs.getStringPref("zen.injections.match-urls").split(","), "about:preferences"],
|
||||
});
|
||||
|
@@ -6,13 +6,38 @@ export class ZenThemeMarketplaceChild extends JSWindowActorChild {
|
||||
handleEvent(event) {
|
||||
switch (event.type) {
|
||||
case 'DOMContentLoaded':
|
||||
this.initiateThemeMarketplace();
|
||||
this.contentWindow.document.addEventListener('ZenCheckForThemeUpdates', this.checkForThemeUpdates.bind(this));
|
||||
this.initalizeZenAPI(event);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
initalizeZenAPI(event) {
|
||||
const verifier = this.contentWindow.document.querySelector('meta[name="zen-content-verified"]');
|
||||
if (verifier) {
|
||||
verifier.setAttribute('content', 'verified');
|
||||
}
|
||||
const possibleRicePage = this.collectRiceMetadata();
|
||||
if (possibleRicePage) {
|
||||
this.sendAsyncMessage('ZenThemeMarketplace:RizePage', { data: possibleRicePage });
|
||||
return;
|
||||
}
|
||||
this.initiateThemeMarketplace();
|
||||
this.contentWindow.document.addEventListener('ZenCheckForThemeUpdates', this.checkForThemeUpdates.bind(this));
|
||||
}
|
||||
|
||||
collectRiceMetadata() {
|
||||
const meta = this.contentWindow.document.querySelector('meta[name="rize-metadata"]');
|
||||
if (meta) {
|
||||
return {
|
||||
id: meta.getAttribute('data-id'),
|
||||
name: meta.getAttribute('data-title'),
|
||||
author: meta.getAttribute('data-author'),
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// This function will be caleld from about:preferences
|
||||
checkForThemeUpdates(event) {
|
||||
event.preventDefault();
|
||||
|
@@ -34,6 +34,10 @@ export class ZenThemeMarketplaceParent extends JSWindowActorParent {
|
||||
this.checkForThemeUpdates();
|
||||
break;
|
||||
}
|
||||
case 'ZenThemeMarketplace:RizePage': {
|
||||
// TODO: Implement
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user