Compare commits
1 Commits
be38ce081e
...
feat/issue
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d6a6e24c4e |
@@ -1,18 +1,19 @@
|
|||||||
// AutistMask popup entry point.
|
// AutistMask popup entry point.
|
||||||
// Loads state, initializes views, triggers first render.
|
// Loads state, initializes views, triggers first render.
|
||||||
|
|
||||||
const { DEBUG } = require("../shared/constants");
|
|
||||||
const {
|
const {
|
||||||
state,
|
state,
|
||||||
saveState,
|
saveState,
|
||||||
loadState,
|
loadState,
|
||||||
currentNetwork,
|
currentNetwork,
|
||||||
} = require("../shared/state");
|
} = require("../shared/state");
|
||||||
|
const { isDebug, setRuntimeDebug } = require("../shared/log");
|
||||||
const { refreshPrices } = require("../shared/prices");
|
const { refreshPrices } = require("../shared/prices");
|
||||||
const { refreshBalances } = require("../shared/balances");
|
const { refreshBalances } = require("../shared/balances");
|
||||||
const {
|
const {
|
||||||
$,
|
$,
|
||||||
showView,
|
showView,
|
||||||
|
updateDebugBanner,
|
||||||
setRenderMain,
|
setRenderMain,
|
||||||
pushCurrentView,
|
pushCurrentView,
|
||||||
goBack,
|
goBack,
|
||||||
@@ -209,21 +210,11 @@ async function init() {
|
|||||||
await loadState();
|
await loadState();
|
||||||
applyTheme(state.theme);
|
applyTheme(state.theme);
|
||||||
|
|
||||||
const net = currentNetwork();
|
// Sync runtime debug flag from persisted state before first render
|
||||||
if (DEBUG || net.isTestnet) {
|
setRuntimeDebug(state.debugMode);
|
||||||
const banner = document.createElement("div");
|
|
||||||
banner.id = "debug-banner";
|
// Create the debug/testnet banner if needed (uses runtime debug state)
|
||||||
if (DEBUG && net.isTestnet) {
|
updateDebugBanner();
|
||||||
banner.textContent = "DEBUG / INSECURE [TESTNET]";
|
|
||||||
} else if (net.isTestnet) {
|
|
||||||
banner.textContent = "[TESTNET]";
|
|
||||||
} else {
|
|
||||||
banner.textContent = "DEBUG / INSECURE";
|
|
||||||
}
|
|
||||||
banner.style.cssText =
|
|
||||||
"background:#c00;color:#fff;text-align:center;font-size:10px;padding:1px 0;font-family:monospace;position:sticky;top:0;z-index:9999;";
|
|
||||||
document.body.prepend(banner);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Auto-default active address
|
// Auto-default active address
|
||||||
if (
|
if (
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// Shared DOM helpers used by all views.
|
// Shared DOM helpers used by all views.
|
||||||
|
|
||||||
const { DEBUG } = require("../../shared/constants");
|
const { DEBUG } = require("../../shared/constants");
|
||||||
|
const { isDebug } = require("../../shared/log");
|
||||||
const {
|
const {
|
||||||
formatUsd,
|
formatUsd,
|
||||||
getPrice,
|
getPrice,
|
||||||
@@ -59,19 +60,37 @@ function showView(name) {
|
|||||||
clearFlash();
|
clearFlash();
|
||||||
state.currentView = name;
|
state.currentView = name;
|
||||||
saveState();
|
saveState();
|
||||||
|
updateDebugBanner(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create or update the debug/insecure warning banner.
|
||||||
|
// Called on every view switch and after the settings debug toggle changes.
|
||||||
|
// The banner is shown when the compile-time DEBUG constant is true OR when
|
||||||
|
// the user has enabled runtime debug mode via the settings easter egg, OR
|
||||||
|
// when the active network is a testnet.
|
||||||
|
function updateDebugBanner(viewName) {
|
||||||
|
const debug = isDebug();
|
||||||
const net = currentNetwork();
|
const net = currentNetwork();
|
||||||
if (DEBUG || net.isTestnet) {
|
const show = debug || net.isTestnet;
|
||||||
const banner = document.getElementById("debug-banner");
|
let banner = document.getElementById("debug-banner");
|
||||||
if (banner) {
|
if (show) {
|
||||||
if (DEBUG && net.isTestnet) {
|
if (!banner) {
|
||||||
banner.textContent =
|
banner = document.createElement("div");
|
||||||
"DEBUG / INSECURE [TESTNET] (" + name + ")";
|
banner.id = "debug-banner";
|
||||||
} else if (net.isTestnet) {
|
banner.style.cssText =
|
||||||
banner.textContent = "[TESTNET]";
|
"background:#c00;color:#fff;text-align:center;font-size:10px;padding:1px 0;font-family:monospace;position:sticky;top:0;z-index:9999;";
|
||||||
} else {
|
document.body.prepend(banner);
|
||||||
banner.textContent = "DEBUG / INSECURE (" + name + ")";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
const suffix = viewName ? " (" + viewName + ")" : "";
|
||||||
|
if (debug && net.isTestnet) {
|
||||||
|
banner.textContent = "DEBUG / INSECURE [TESTNET]" + suffix;
|
||||||
|
} else if (net.isTestnet) {
|
||||||
|
banner.textContent = "[TESTNET]" + suffix;
|
||||||
|
} else {
|
||||||
|
banner.textContent = "DEBUG / INSECURE" + suffix;
|
||||||
|
}
|
||||||
|
} else if (banner) {
|
||||||
|
banner.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -417,6 +436,7 @@ module.exports = {
|
|||||||
showError,
|
showError,
|
||||||
hideError,
|
hideError,
|
||||||
showView,
|
showView,
|
||||||
|
updateDebugBanner,
|
||||||
setRenderMain,
|
setRenderMain,
|
||||||
pushCurrentView,
|
pushCurrentView,
|
||||||
goBack,
|
goBack,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
const {
|
const {
|
||||||
$,
|
$,
|
||||||
showView,
|
showView,
|
||||||
|
updateDebugBanner,
|
||||||
showFlash,
|
showFlash,
|
||||||
escapeHtml,
|
escapeHtml,
|
||||||
flashCopyFeedback,
|
flashCopyFeedback,
|
||||||
@@ -372,11 +373,12 @@ function init(ctx) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Debug mode toggle
|
// Debug mode toggle — update runtime flag, persist, and re-render banner
|
||||||
$("settings-debug-mode").addEventListener("change", async () => {
|
$("settings-debug-mode").addEventListener("change", async () => {
|
||||||
state.debugMode = $("settings-debug-mode").checked;
|
state.debugMode = $("settings-debug-mode").checked;
|
||||||
setRuntimeDebug(state.debugMode);
|
setRuntimeDebug(state.debugMode);
|
||||||
await saveState();
|
await saveState();
|
||||||
|
updateDebugBanner(state.currentView);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Sync runtime debug flag on init
|
// Sync runtime debug flag on init
|
||||||
|
|||||||
Reference in New Issue
Block a user