refactor: Update ZenSidebarManager to use updated default mobile user agent

This commit is contained in:
Mauro Balades 2024-08-16 22:23:40 +02:00
parent 1f01cdac79
commit c05abd76b2
3 changed files with 11 additions and 30 deletions

View file

@ -73,7 +73,7 @@ var gZenBrowserManagerSidebar = {
const parent = sidebar.parentElement; const parent = sidebar.parentElement;
// relative to avoid the top margin // relative to avoid the top margin
// 20px is the padding // 20px is the padding
let parentRelativeHeight = parent.getBoundingClientRect().height - parent.getBoundingClientRect().top + 20; let parentRelativeHeight = parent.getBoundingClientRect().height - parent.getBoundingClientRect().top + 30;
let minHeight = parseInt(computedStyle.getPropertyValue("min-height").replace("px", "")); let minHeight = parseInt(computedStyle.getPropertyValue("min-height").replace("px", ""));
if (!this._isDragging) { // Prevent multiple resizes if (!this._isDragging) { // Prevent multiple resizes
this._isDragging = true; this._isDragging = true;

View file

@ -1,5 +1,4 @@
const kZenThemesPreference = "zen.themes.data";
export class ZenThemeMarketplaceChild extends JSWindowActorChild { export class ZenThemeMarketplaceChild extends JSWindowActorChild {
constructor() { constructor() {
super(); super();
@ -17,41 +16,23 @@ export class ZenThemeMarketplaceChild extends JSWindowActorChild {
initiateThemeMarketplace() { initiateThemeMarketplace() {
this.contentWindow.setTimeout(() => { this.contentWindow.setTimeout(() => {
this.addIntallButtons(); this.addIntallButtons();
}, 1000); }, 0);
} }
async addIntallButtons() { async addIntallButtons() {
const actionButtons = this.contentWindow.document.querySelectorAll(".install-theme"); const actionButton = this.contentWindow.document.getElementById("install-theme");
const errorMessages = this.contentWindow.document.querySelectorAll(".install-theme-error"); const errorMessage = this.contentWindow.document.getElementById("install-theme-error");
if (actionButtons.length !== 0) { if (actionButton) {
console.info("ZenThemeMarketplaceChild: Initiating theme marketplace"); console.info("ZenThemeMarketplaceChild: Initiating theme marketplace");
} }
for (let error of errorMessages) { errorMessage.classList.add("hidden");
error.remove(); actionButton.classList.remove("hidden");
} actionButton.addEventListener("click", this.installTheme.bind(this));
for (let button of actionButtons) {
button.classList.remove("hidden");
button.addEventListener("click", this.installTheme.bind(this));
}
}
get themes() {
if (!this._themes) {
this._themes = JSON.parse(Services.prefs.getStringPref(kZenThemesPreference, "{}"));
}
return this._themes;
}
set themes(themes) {
this._themes = themes;
this.sendAsyncMessage("ZenThemeMarketplace:UpdateThemes", { themes });
} }
addTheme(theme) { addTheme(theme) {
this.themes[theme.id] = theme; this.sendAsyncMessage("ZenThemeMarketplace:InstallTheme", { theme });
this.themes = this.themes;
} }
async getThemeInfo(themeId) { async getThemeInfo(themeId) {