mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-06 12:52:26 +00:00
refactor: migrate console usage to shared loggers
This commit is contained in:
1 parent
52af2082d5
commit
7ae07b1369
54 files changed
+940
-1197
No files matched your search
@@ -6,6 +6,7 @@ import {
|
||||
MAX_WALLET_DEFAULT_ZAP as CONFIG_MAX_WALLET_DEFAULT_ZAP,
|
||||
} from "../config.js";
|
||||
import { normalizeDesignSystemContext } from "../designSystem.js";
|
||||
import { devLogger, userLogger } from "../utils/logger.js";
|
||||
|
||||
const noop = () => {};
|
||||
|
||||
@@ -940,7 +941,7 @@ export class ProfileModalController {
|
||||
try {
|
||||
this.profileHistoryRenderer = this.createWatchHistoryRenderer(config);
|
||||
} catch (error) {
|
||||
console.error(
|
||||
userLogger.error(
|
||||
"[profileModal] Failed to create watch history renderer:",
|
||||
error,
|
||||
);
|
||||
@@ -1372,7 +1373,7 @@ export class ProfileModalController {
|
||||
try {
|
||||
await this.switchProfile(entry.pubkey, { entry });
|
||||
} catch (error) {
|
||||
console.error("Failed to switch profile:", error);
|
||||
userLogger.error("Failed to switch profile:", error);
|
||||
} finally {
|
||||
button.dataset.loading = "false";
|
||||
button.setAttribute("aria-busy", "false");
|
||||
@@ -1427,7 +1428,7 @@ export class ProfileModalController {
|
||||
try {
|
||||
this.profileHistoryRenderer?.pause();
|
||||
} catch (error) {
|
||||
console.warn("[profileModal] Failed to pause history renderer:", error);
|
||||
userLogger.warn("[profileModal] Failed to pause history renderer:", error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1990,7 +1991,7 @@ export class ProfileModalController {
|
||||
}
|
||||
this.populateBlockedList();
|
||||
} catch (error) {
|
||||
console.error("Failed to add creator to personal block list:", error);
|
||||
userLogger.error("Failed to add creator to personal block list:", error);
|
||||
context.error = error;
|
||||
context.reason = error?.code || "service-error";
|
||||
const message =
|
||||
@@ -2026,7 +2027,7 @@ export class ProfileModalController {
|
||||
}
|
||||
|
||||
if (!targetHex) {
|
||||
console.warn("No valid pubkey to remove from block list:", candidate);
|
||||
userLogger.warn("No valid pubkey to remove from block list:", candidate);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2055,7 +2056,7 @@ export class ProfileModalController {
|
||||
|
||||
this.populateBlockedList();
|
||||
} catch (error) {
|
||||
console.error(
|
||||
userLogger.error(
|
||||
"Failed to remove creator from personal block list:",
|
||||
error,
|
||||
);
|
||||
@@ -2111,7 +2112,7 @@ export class ProfileModalController {
|
||||
renderer.resume();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(
|
||||
userLogger.error(
|
||||
"[profileModal] Failed to populate watch history pane:",
|
||||
error,
|
||||
);
|
||||
@@ -2769,11 +2770,11 @@ export class ProfileModalController {
|
||||
|
||||
if (loadError) {
|
||||
if (loadError?.code === "nostr-unavailable") {
|
||||
console.info("Moderation lists are still syncing with relays.");
|
||||
devLogger.info("Moderation lists are still syncing with relays.");
|
||||
return;
|
||||
}
|
||||
|
||||
console.error("Failed to load admin lists:", loadError);
|
||||
userLogger.error("Failed to load admin lists:", loadError);
|
||||
this.showStatus(null);
|
||||
this.showError("Unable to load moderation lists. Please try again.");
|
||||
this.clearAdminLists();
|
||||
@@ -2866,7 +2867,7 @@ export class ProfileModalController {
|
||||
}
|
||||
} catch (error) {
|
||||
preloadError = error;
|
||||
console.error("Failed to load admin lists before adding moderator:", error);
|
||||
userLogger.error("Failed to load admin lists before adding moderator:", error);
|
||||
}
|
||||
|
||||
if (preloadError) {
|
||||
@@ -2970,7 +2971,7 @@ export class ProfileModalController {
|
||||
}
|
||||
} catch (error) {
|
||||
preloadError = error;
|
||||
console.error("Failed to load admin lists before removing moderator:", error);
|
||||
userLogger.error("Failed to load admin lists before removing moderator:", error);
|
||||
}
|
||||
|
||||
if (preloadError) {
|
||||
@@ -3077,7 +3078,7 @@ export class ProfileModalController {
|
||||
}
|
||||
} catch (error) {
|
||||
preloadError = error;
|
||||
console.error("Failed to load admin lists before updating entries:", error);
|
||||
userLogger.error("Failed to load admin lists before updating entries:", error);
|
||||
}
|
||||
|
||||
if (preloadError) {
|
||||
@@ -3162,7 +3163,7 @@ export class ProfileModalController {
|
||||
this.showError(errorMessage);
|
||||
}
|
||||
if (isDevMode && notifyResult?.error) {
|
||||
console.warn(
|
||||
userLogger.warn(
|
||||
"[admin] Failed to send list notification DM:",
|
||||
notifyResult,
|
||||
);
|
||||
@@ -3178,13 +3179,11 @@ export class ProfileModalController {
|
||||
}
|
||||
} catch (error) {
|
||||
context.notificationError = error;
|
||||
console.error("Failed to send list notification DM:", error);
|
||||
if (isDevMode) {
|
||||
console.warn(
|
||||
"List update succeeded, but DM notification threw an unexpected error.",
|
||||
error,
|
||||
);
|
||||
}
|
||||
userLogger.error("Failed to send list notification DM:", error);
|
||||
devLogger.warn(
|
||||
"List update succeeded, but DM notification threw an unexpected error.",
|
||||
error,
|
||||
);
|
||||
this.notifyAdminError({
|
||||
listType,
|
||||
action,
|
||||
@@ -3468,7 +3467,7 @@ export class ProfileModalController {
|
||||
targetHex,
|
||||
});
|
||||
} catch (refreshError) {
|
||||
console.warn(
|
||||
userLogger.warn(
|
||||
"[ProfileModalController] Failed to refresh videos after blocklist mutation:",
|
||||
refreshError,
|
||||
);
|
||||
@@ -3776,7 +3775,7 @@ export class ProfileModalController {
|
||||
try {
|
||||
await this.refreshAdminPaneState();
|
||||
} catch (error) {
|
||||
console.error(
|
||||
userLogger.error(
|
||||
"Failed to refresh admin pane while opening profile modal:",
|
||||
error,
|
||||
);
|
||||
@@ -3793,7 +3792,7 @@ export class ProfileModalController {
|
||||
const activeHex = this.normalizeHexPubkey(this.getActivePubkey());
|
||||
await this.services.userBlocks.ensureLoaded(activeHex);
|
||||
} catch (error) {
|
||||
console.warn(
|
||||
userLogger.warn(
|
||||
"Failed to refresh user block list while opening profile modal:",
|
||||
error,
|
||||
);
|
||||
@@ -3886,7 +3885,7 @@ export class ProfileModalController {
|
||||
this.profileHistoryRenderer.destroy();
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn(
|
||||
userLogger.warn(
|
||||
"[profileModal] Failed to reset watch history renderer on close:",
|
||||
error,
|
||||
);
|
||||
@@ -3913,7 +3912,7 @@ export class ProfileModalController {
|
||||
try {
|
||||
previous.focus();
|
||||
} catch (error) {
|
||||
console.warn(
|
||||
userLogger.warn(
|
||||
"[profileModal] Failed to restore focus after closing modal:",
|
||||
error,
|
||||
);
|
||||
@@ -3926,7 +3925,7 @@ export class ProfileModalController {
|
||||
try {
|
||||
this.callbacks.onClose(this);
|
||||
} catch (error) {
|
||||
console.warn(
|
||||
userLogger.warn(
|
||||
"[profileModal] onClose callback threw while hiding modal:",
|
||||
error,
|
||||
);
|
||||
@@ -3950,7 +3949,7 @@ export class ProfileModalController {
|
||||
persistActive: false,
|
||||
});
|
||||
} catch (error) {
|
||||
console.warn(
|
||||
userLogger.warn(
|
||||
"[profileModal] Failed to sync saved profiles during login:",
|
||||
error,
|
||||
);
|
||||
@@ -3970,7 +3969,7 @@ export class ProfileModalController {
|
||||
try {
|
||||
await this.refreshAdminPaneState();
|
||||
} catch (error) {
|
||||
console.warn("Failed to refresh admin pane after login:", error);
|
||||
userLogger.warn("Failed to refresh admin pane after login:", error);
|
||||
}
|
||||
|
||||
this.populateBlockedList();
|
||||
@@ -3984,7 +3983,7 @@ export class ProfileModalController {
|
||||
this.refreshWalletPaneState();
|
||||
})
|
||||
.catch((error) => {
|
||||
console.warn(
|
||||
userLogger.warn(
|
||||
"[profileModal] Failed to hydrate deferred login data:",
|
||||
error,
|
||||
);
|
||||
@@ -4004,7 +4003,7 @@ export class ProfileModalController {
|
||||
persistActive: false,
|
||||
});
|
||||
} catch (error) {
|
||||
console.warn(
|
||||
userLogger.warn(
|
||||
"[profileModal] Failed to sync saved profiles during logout:",
|
||||
error,
|
||||
);
|
||||
@@ -4023,7 +4022,7 @@ export class ProfileModalController {
|
||||
try {
|
||||
await this.refreshAdminPaneState();
|
||||
} catch (error) {
|
||||
console.warn("Failed to refresh admin pane after logout:", error);
|
||||
userLogger.warn("Failed to refresh admin pane after logout:", error);
|
||||
}
|
||||
|
||||
this.populateBlockedList();
|
||||
@@ -4041,7 +4040,7 @@ export class ProfileModalController {
|
||||
persistActive: false,
|
||||
});
|
||||
} catch (error) {
|
||||
console.warn(
|
||||
userLogger.warn(
|
||||
"[profileModal] Failed to sync saved profiles after profile update:",
|
||||
error,
|
||||
);
|
||||
@@ -4066,7 +4065,7 @@ export class ProfileModalController {
|
||||
try {
|
||||
result = this.services.removeSavedProfile(pubkey) || { removed: false };
|
||||
} catch (error) {
|
||||
console.error("Failed to remove saved profile:", error);
|
||||
userLogger.error("Failed to remove saved profile:", error);
|
||||
result = { removed: false, error };
|
||||
}
|
||||
|
||||
@@ -4099,7 +4098,7 @@ export class ProfileModalController {
|
||||
try {
|
||||
return await hydrate(normalized);
|
||||
} catch (error) {
|
||||
console.warn(
|
||||
userLogger.warn(
|
||||
`[ProfileModalController] Failed to hydrate wallet settings for ${normalized}:`,
|
||||
error,
|
||||
);
|
||||
@@ -4155,7 +4154,7 @@ export class ProfileModalController {
|
||||
try {
|
||||
return this.services.persistSavedProfiles(...args);
|
||||
} catch (error) {
|
||||
console.warn(
|
||||
userLogger.warn(
|
||||
"[ProfileModalController] Persist saved profiles service threw:",
|
||||
error,
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user