diff --git a/static/js/08-settings.js b/static/js/08-settings.js index b743d4b..002db65 100644 --- a/static/js/08-settings.js +++ b/static/js/08-settings.js @@ -53,15 +53,7 @@ Glow.cloneSettingsState = source => { String(value.presence_mode || "").toLowerCase() ) ? String(value.presence_mode).toLowerCase() - : "online", - dm_layout_mode: - value.dm_layout_mode === "compact" - ? "compact" - : "cards", - show_presence_badge: - typeof value.show_presence_badge === "boolean" - ? value.show_presence_badge - : Glow.state.profilePresenceBadgeVisible !== false + : "online" }; }; @@ -70,7 +62,7 @@ Glow.initializeSettingsDraft = settings => { Glow.state.settings = saved; Glow.state.settingsSaved = saved; Glow.state.settingsDraft = Glow.cloneSettingsState(saved); - Glow.clearSettingsDirty(); + Glow.clearSettingsDirty?.(); }; Glow.previewSettingsDraft = () => { @@ -78,8 +70,6 @@ Glow.previewSettingsDraft = () => { Glow.applyAccentColor(draft.accent_color); Glow.applyThemeMode(draft.theme_mode); Glow.applyCustomCss(draft.custom_css || ""); - Glow.saveDmLayoutPreference(draft.dm_layout_mode || "cards"); - Glow.state.profilePresenceBadgeVisible = draft.show_presence_badge !== false; }; Glow.updateSettingsDraft = patch => { @@ -89,7 +79,7 @@ Glow.updateSettingsDraft = patch => { ...patch }; Glow.previewSettingsDraft(); - Glow.markSettingsDirty(); + Glow.markSettingsDirty?.(); }; Glow.syncSettingsSavePanel = () => { @@ -98,7 +88,7 @@ Glow.syncSettingsSavePanel = () => { const shouldShow = Glow.state.activeView === "settings" && - Glow.isSettingsDirty(); + Glow.isSettingsDirty?.(); panel.classList.toggle("hidden", !shouldShow); @@ -135,10 +125,7 @@ Glow.saveSettingsDraft = async () => { presence_mode: ["online", "silent", "focus", "dnd"].includes(draft.presence_mode) ? draft.presence_mode - : "online", - dm_layout_mode: - draft.dm_layout_mode === "compact" ? "compact" : "cards", - show_presence_badge: draft.show_presence_badge !== false + : "online" }; const data = await Glow.apiUpdateMySettings(payload); @@ -151,7 +138,7 @@ Glow.saveSettingsDraft = async () => { Glow.state.settingsSaved = Glow.cloneSettingsState(merged); Glow.state.settingsDraft = Glow.cloneSettingsState(merged); Glow.previewSettingsDraft(); - Glow.clearSettingsDirty(); + Glow.clearSettingsDirty?.(); if (Glow.state.currentUser) { Glow.state.currentUser.presence_mode = @@ -166,59 +153,22 @@ Glow.discardSettingsDraft = () => { const saved = Glow.state.settingsSaved || Glow.cloneSettingsState({}); Glow.state.settingsDraft = Glow.cloneSettingsState(saved); Glow.previewSettingsDraft(); - Glow.clearSettingsDirty(); + Glow.clearSettingsDirty?.(); if (Glow.state.activeView === "settings") { Glow.renderSettingsView(); } }; -Glow.closeSettingsViewRequested = async () => { - if (!Glow.isSettingsDirty()) { - await Glow.openFeed?.(); - return true; - } - - const values = await Glow.openDialog({ - title: "Unsaved settings changes", - body: "You have unsaved settings changes. Save them before leaving?", - confirmText: "Save and leave", - cancelText: "Stay" - }); - - if (values === null) { - return false; - } - - try { - await Glow.saveSettingsDraft(); - await Glow.openFeed?.(); - return true; - } catch (error) { - Glow.showToast(error.message || "Could not save settings.", "error"); - return false; - } -}; - Glow.loadMySettings = async () => { try { const data = await Glow.apiGetMySettings(); - const base = Glow.cloneSettingsState({ - ...(data.settings || {}), - dm_layout_mode: - data.settings?.dm_layout_mode || Glow.loadDmLayoutPreference(), - show_presence_badge: - typeof data.settings?.show_presence_badge === "boolean" - ? data.settings.show_presence_badge - : Glow.state.profilePresenceBadgeVisible !== false - }); + const base = Glow.cloneSettingsState(data.settings || {}); Glow.initializeSettingsDraft(base); Glow.previewSettingsDraft(); } catch (_) { const fallback = Glow.cloneSettingsState({ theme_mode: localStorage.getItem("glow_theme_mode") || "dark", accent_color: Glow.state.accentColor, - dm_layout_mode: Glow.loadDmLayoutPreference(), - show_presence_badge: Glow.state.profilePresenceBadgeVisible !== false, profile_visibility: "public", last_active_visibility: "everyone", presence_mode: "online" @@ -359,6 +309,7 @@ Glow.toggleHeaderMenu = () => { Glow.openSettings = async () => { Glow.state.activeView = "settings"; Glow.updateViewUI(); + if (!Glow.state.settingsSaved && Glow.state.currentUser) { await Glow.loadMySettings(); } else if (!Glow.state.settingsDraft) { @@ -367,6 +318,7 @@ Glow.openSettings = async () => { ); Glow.previewSettingsDraft(); } + Glow.renderSettingsView(); Glow.syncSettingsSavePanel(); }; @@ -501,35 +453,6 @@ Glow.renderSettingsView = () => { resetNameColor ); - const dmLayout = Glow.renderChoicePills({ - label: "DM layout", - value: draft.dm_layout_mode || "cards", - options: [ - { value: "cards", label: "Cards" }, - { value: "compact", label: "Compact" } - ], - onChange: value => { - Glow.updateSettingsDraft({ dm_layout_mode: value }); - Glow.loadDms?.().catch(() => {}); - Glow.renderSettingsView(); - } - }); - - const presenceBadge = Glow.renderChoicePills({ - label: "Profile presence badge", - value: draft.show_presence_badge === false ? "hidden" : "shown", - options: [ - { value: "shown", label: "Shown" }, - { value: "hidden", label: "Hidden" } - ], - onChange: value => { - Glow.updateSettingsDraft({ - show_presence_badge: value !== "hidden" - }); - Glow.renderSettingsView(); - } - }); - const profileVisibility = Glow.renderChoicePills({ label: "Profile visibility", value: draft.profile_visibility || "public", @@ -583,8 +506,6 @@ Glow.renderSettingsView = () => { iTitle, iText, nameColorWrap, - dmLayout, - presenceBadge, profileVisibility, lastActiveVisibility, presenceMode @@ -701,7 +622,8 @@ Glow.renderSettingsView = () => { bannerLabel.append(bannerInput); bannerWrap.append(bannerLabel); - profileVisuals.append(pvTitle, pvText, backgroundWrap, bannerLabel); + + profileVisuals.append(pvTitle, pvText, backgroundWrap, bannerWrap); const cssSection = document.createElement("section"); cssSection.className = "settings-section"; @@ -781,7 +703,7 @@ Glow.els.settingsSaveButton?.addEventListener("click", async () => { }); Glow.els.settingsCloseButton?.addEventListener("click", async () => { - if (!Glow.isSettingsDirty()) { + if (!Glow.isSettingsDirty?.()) { await Glow.openFeed?.(); return; }