mirror of
https://github.com/root-fr/jmap-webmail.git
synced 2026-09-23 16:01:15 +00:00
- showPreview: Conditionally render email preview in list based on setting - externalContentPolicy: Control external content (ask/block/allow modes) - deleteAction: Move to trash or permanently delete based on preference - debugMode: Add conditional logging via new lib/debug.ts utility Also includes: - Add moveToTrash method to JMAP client for trash-based deletion - Update TODO.md with verified implementation status - Migrate middleware.ts to proxy.ts (Next.js deprecation)
78 lines
1.7 KiB
TypeScript
78 lines
1.7 KiB
TypeScript
import { useSettingsStore } from '@/stores/settings-store';
|
|
|
|
/**
|
|
* Debug logger that respects the debugMode setting.
|
|
* Use this instead of console.log for conditional debug output.
|
|
*/
|
|
export const debug = {
|
|
/**
|
|
* Log a debug message (only when debugMode is enabled)
|
|
*/
|
|
log: (...args: unknown[]) => {
|
|
if (useSettingsStore.getState().debugMode) {
|
|
console.log('[DEBUG]', ...args);
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Log a warning message (only when debugMode is enabled)
|
|
*/
|
|
warn: (...args: unknown[]) => {
|
|
if (useSettingsStore.getState().debugMode) {
|
|
console.warn('[DEBUG]', ...args);
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Log an error message (always logs, regardless of debugMode)
|
|
*/
|
|
error: (...args: unknown[]) => {
|
|
console.error('[ERROR]', ...args);
|
|
},
|
|
|
|
/**
|
|
* Start a collapsed console group (only when debugMode is enabled)
|
|
*/
|
|
group: (label: string) => {
|
|
if (useSettingsStore.getState().debugMode) {
|
|
console.group(`[DEBUG] ${label}`);
|
|
}
|
|
},
|
|
|
|
/**
|
|
* End a console group (only when debugMode is enabled)
|
|
*/
|
|
groupEnd: () => {
|
|
if (useSettingsStore.getState().debugMode) {
|
|
console.groupEnd();
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Start a performance timer (only when debugMode is enabled)
|
|
*/
|
|
time: (label: string) => {
|
|
if (useSettingsStore.getState().debugMode) {
|
|
console.time(`[DEBUG] ${label}`);
|
|
}
|
|
},
|
|
|
|
/**
|
|
* End a performance timer (only when debugMode is enabled)
|
|
*/
|
|
timeEnd: (label: string) => {
|
|
if (useSettingsStore.getState().debugMode) {
|
|
console.timeEnd(`[DEBUG] ${label}`);
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Log a table (only when debugMode is enabled)
|
|
*/
|
|
table: (data: unknown) => {
|
|
if (useSettingsStore.getState().debugMode) {
|
|
console.table(data);
|
|
}
|
|
}
|
|
};
|