better toast success notifications

This commit is contained in:
KingKDot
2026-07-11 19:35:56 -05:00
parent fb6c856ad1
commit 9ea63fa6bc
2 changed files with 20 additions and 14 deletions
+19 -14
View File
@@ -165,6 +165,11 @@ function formatDate(timestamp) {
return formatSharedDate(timestamp, "-");
}
function showSettingsSuccess(text, showInline = showMessage) {
showInline(text);
window.showToast?.(text, "success");
}
function canManageClientBans(role) {
return userHas("network:manage-bans");
}
@@ -634,7 +639,7 @@ async function updatePassword(event) {
}
passwordForm.reset();
showMessage("Password updated successfully.");
showSettingsSuccess("Password updated successfully.");
}
function showMfaMessage(text, type = "ok") {
@@ -759,7 +764,7 @@ function savePrefs(event) {
if (perm === "granted") {
setDesktopNotificationsEnabled(true);
if (prefDesktopNotificationsHint) prefDesktopNotificationsHint.classList.add("hidden");
showMessage("Preferences saved. Desktop notifications enabled.");
showSettingsSuccess("Preferences saved. Desktop notifications enabled.");
} else {
setDesktopNotificationsEnabled(false);
if (prefDesktopNotificationsInput) prefDesktopNotificationsInput.checked = false;
@@ -770,7 +775,7 @@ function savePrefs(event) {
} else {
setDesktopNotificationsEnabled(false);
if (prefDesktopNotificationsHint) prefDesktopNotificationsHint.classList.add("hidden");
showMessage("Preferences saved.");
showSettingsSuccess("Preferences saved.");
}
const navHiddenInput = document.getElementById("pref-nav-hidden");
@@ -815,7 +820,7 @@ async function saveSecurityPolicy(event) {
securityConfig = data.security || payload;
applySecurityForm();
showMessage("Security policy updated.");
showSettingsSuccess("Security policy updated.");
}
async function saveTlsSettings(event) {
@@ -850,7 +855,7 @@ async function saveTlsSettings(event) {
tlsConfig = data.tls || payload;
applyTlsForm();
showMessage("TLS settings updated. Restart server to apply.");
showSettingsSuccess("TLS settings updated. Restart server to apply.");
}
async function saveOidcSettings(event) {
@@ -926,7 +931,7 @@ async function saveOidcSettings(event) {
oidcConfig = data.oidc || payload;
applyOidcForm();
showMessage("OIDC settings saved. Environment variables still take priority after restart.");
showSettingsSuccess("OIDC settings saved. Environment variables still take priority after restart.");
}
async function runCertbotAutoSetup() {
@@ -1011,7 +1016,7 @@ async function saveMyTelegram() {
}
myTelegramChatIdInput.value = data.telegramChatId || "";
showMessage(chatId ? "Telegram chat ID saved." : "Telegram notifications disabled.");
showSettingsSuccess(chatId ? "Telegram chat ID saved." : "Telegram notifications disabled.");
} catch {
showMessage("Failed to save Telegram settings.", "error");
}
@@ -1558,7 +1563,7 @@ async function saveAppearanceSettings(event) {
}
applyBrandingForm(data.loginBranding || collectBrandingForm());
showMessage("Branding saved. Reload any open page to apply it everywhere.");
showSettingsSuccess("Branding saved. Reload any open page to apply it everywhere.");
}
const chatSettingsSection = document.getElementById("chat-settings-section");
@@ -1608,7 +1613,7 @@ async function saveInputArchivePreference(event) {
showMessage(data.error || "Failed to save input archive preference.", "error");
return;
}
showMessage("Input archive preference saved.");
showSettingsSuccess("Input archive preference saved.");
}
async function saveInputArchiveAdminSettings(event) {
@@ -1651,7 +1656,7 @@ async function saveInputArchiveAdminSettings(event) {
showMessage(data.error || "Failed to save input archive settings.", "error");
return;
}
showMessage("Input archive settings saved.");
showSettingsSuccess("Input archive settings saved.");
}
async function saveChatSettings(event) {
@@ -1679,7 +1684,7 @@ async function saveChatSettings(event) {
return;
}
showMessage("Chat settings saved.");
showSettingsSuccess("Chat settings saved.");
}
function showExportImportMessage(text, type = "ok") {
@@ -2086,7 +2091,7 @@ async function saveRegistrationSettings(e) {
showRegMsg(data.error || "Failed to save", "error");
return;
}
showRegMsg("Registration settings saved.", "success");
showSettingsSuccess("Registration settings saved.", (text) => showRegMsg(text, "success"));
updateRegSubsections(mode);
if (mode === "key" && userHas("users:manage")) loadRegistrationKeys();
if (mode === "approval" && userHas("users:manage")) loadPendingRegistrations();
@@ -2309,7 +2314,7 @@ async function saveBuildRateLimitSettings(e) {
showBrlMsg(data.error || "Failed to save", "error");
return;
}
showBrlMsg("Build rate limit settings saved.", "success");
showSettingsSuccess("Build rate limit settings saved.", (text) => showBrlMsg(text, "success"));
} catch {
showBrlMsg("Network error.", "error");
}
@@ -2368,7 +2373,7 @@ async function saveThumbnailSettings(e) {
showThumbnailsMsg(data.error || "Failed to save", "error");
return;
}
showThumbnailsMsg("Thumbnail settings saved.", "success");
showSettingsSuccess("Thumbnail settings saved.", (text) => showThumbnailsMsg(text, "success"));
} catch {
showThumbnailsMsg("Network error.", "error");
}