style(frontend): Prettier config + one-time repo-wide format pass
Prettier 3 (pinned), printWidth 100, double quotes — chosen to match the existing hand-formatting and minimise reflow. This commit is ONLY the mechanical format pass (`prettier --write`) plus the config/ignore/scripts, isolated so it never pollutes a feature diff. Verified behaviour-neutral: typecheck, eslint (0 errors), and vitest all green before and after. See .git-blame-ignore-revs — `git blame` skips this sha.
This commit is contained in:
@@ -107,7 +107,9 @@ export function configureNotifications(p: Partial<NotifSettings>): void {
|
||||
let audioCtx: AudioContext | null = null;
|
||||
function beep(): void {
|
||||
try {
|
||||
const Ctx = window.AudioContext || (window as unknown as { webkitAudioContext: typeof AudioContext }).webkitAudioContext;
|
||||
const Ctx =
|
||||
window.AudioContext ||
|
||||
(window as unknown as { webkitAudioContext: typeof AudioContext }).webkitAudioContext;
|
||||
audioCtx = audioCtx || new Ctx();
|
||||
if (audioCtx.state === "suspended") void audioCtx.resume();
|
||||
const osc = audioCtx.createOscillator();
|
||||
@@ -143,7 +145,13 @@ function load(): Notification[] {
|
||||
// live `action` callback, which can't survive serialization.
|
||||
return raw.map(
|
||||
(n) =>
|
||||
({ repeat: 1, ...(n as object), action: undefined, dismissed: true, transient: false }) as Notification
|
||||
({
|
||||
repeat: 1,
|
||||
...(n as object),
|
||||
action: undefined,
|
||||
dismissed: true,
|
||||
transient: false,
|
||||
}) as Notification,
|
||||
);
|
||||
} catch {
|
||||
return [];
|
||||
@@ -202,13 +210,14 @@ export function notify(input: NotifyInput): number {
|
||||
// config.durationMs === 0 means "don't auto-dismiss" (toast stays until dismissed).
|
||||
// A transient status stays put until its producer clears it (no auto-dismiss timer),
|
||||
// same as an interaction-awaiting notice.
|
||||
const duration = requiresInteraction || input.transient
|
||||
? undefined
|
||||
: level === "error" || level === "fatal"
|
||||
? ERROR_TTL
|
||||
: config.durationMs > 0
|
||||
? config.durationMs
|
||||
: undefined;
|
||||
const duration =
|
||||
requiresInteraction || input.transient
|
||||
? undefined
|
||||
: level === "error" || level === "fatal"
|
||||
? ERROR_TTL
|
||||
: config.durationMs > 0
|
||||
? config.durationMs
|
||||
: undefined;
|
||||
|
||||
// Coalesce a rapid burst of identical notifications (same level+title+message within the
|
||||
// window) into one entry with a bumped repeat count, instead of appending a fresh copy each
|
||||
@@ -224,14 +233,14 @@ export function notify(input: NotifyInput): number {
|
||||
now - n.ts <= COALESCE_WINDOW_MS &&
|
||||
n.level === level &&
|
||||
(n.title ?? "") === (input.title ?? "") &&
|
||||
n.message === input.message
|
||||
n.message === input.message,
|
||||
);
|
||||
if (prior) {
|
||||
// Re-surface the existing toast (undismiss + unread) and re-arm its auto-dismiss timer.
|
||||
items = items.map((n) =>
|
||||
n.id === prior.id
|
||||
? { ...n, ts: now, repeat: n.repeat + 1, dismissed: false, read: false, duration }
|
||||
: n
|
||||
: n,
|
||||
);
|
||||
emit();
|
||||
if (duration) setTimeout(() => dismiss(prior.id), duration);
|
||||
@@ -260,7 +269,10 @@ export function notify(input: NotifyInput): number {
|
||||
},
|
||||
];
|
||||
emit();
|
||||
if (config.sound && (input.sound || requiresInteraction || level === "error" || level === "fatal")) {
|
||||
if (
|
||||
config.sound &&
|
||||
(input.sound || requiresInteraction || level === "error" || level === "fatal")
|
||||
) {
|
||||
beep();
|
||||
}
|
||||
if (duration) setTimeout(() => dismiss(id), duration);
|
||||
@@ -301,7 +313,7 @@ export function resolveVideo(videoId: string): void {
|
||||
!(
|
||||
(n.meta?.kind === "video-hidden" || n.meta?.kind === "video-watched") &&
|
||||
n.meta.videoId === videoId
|
||||
)
|
||||
),
|
||||
);
|
||||
if (items.length !== before) emit();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user