mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-06-10 03:13:32 -07:00
a15fb39847
- Add openNoteInBrowser to AnkiConnectClient via guiBrowse IPC - Add Open in Anki action button to mined-card overlay notifications and history entries - Fall back to a direct AnkiConnectClient when the live integration is unavailable - Embed notification images as base64 data URIs so history panel shows thumbnails - Update same-id progress notifications in place to avoid spinner flicker - Thread noteId through IPC overlay notification action payload
59 lines
1.7 KiB
TypeScript
59 lines
1.7 KiB
TypeScript
export const SETTINGS_NOTIFICATION_TYPE_VALUES = ['overlay', 'system', 'both', 'none'] as const;
|
|
|
|
export const NOTIFICATION_TYPE_VALUES = [
|
|
...SETTINGS_NOTIFICATION_TYPE_VALUES,
|
|
'osd',
|
|
'osd-system',
|
|
] as const;
|
|
|
|
export const OVERLAY_NOTIFICATION_POSITION_VALUES = ['top-left', 'top', 'top-right'] as const;
|
|
|
|
export type SettingsNotificationType = (typeof SETTINGS_NOTIFICATION_TYPE_VALUES)[number];
|
|
export type NotificationType = (typeof NOTIFICATION_TYPE_VALUES)[number];
|
|
export type OverlayNotificationPosition = (typeof OVERLAY_NOTIFICATION_POSITION_VALUES)[number];
|
|
|
|
export type OverlayNotificationVariant = 'info' | 'success' | 'warning' | 'error' | 'progress';
|
|
|
|
export const OPEN_ANKI_CARD_ACTION_ID = 'open-anki-card';
|
|
|
|
export interface OverlayNotificationAction {
|
|
id: string;
|
|
label: string;
|
|
noteId?: number;
|
|
}
|
|
|
|
export interface OverlayNotificationPayload {
|
|
id?: string;
|
|
historyId?: string;
|
|
title: string;
|
|
body?: string;
|
|
image?: string;
|
|
variant?: OverlayNotificationVariant;
|
|
position?: OverlayNotificationPosition;
|
|
persistent?: boolean;
|
|
timeoutMs?: number;
|
|
actions?: OverlayNotificationAction[];
|
|
}
|
|
|
|
export interface OverlayNotificationDismissPayload {
|
|
id: string;
|
|
dismiss: true;
|
|
}
|
|
|
|
export type OverlayNotificationEventPayload =
|
|
| OverlayNotificationPayload
|
|
| OverlayNotificationDismissPayload;
|
|
|
|
export function isNotificationType(value: unknown): value is NotificationType {
|
|
return typeof value === 'string' && NOTIFICATION_TYPE_VALUES.includes(value as NotificationType);
|
|
}
|
|
|
|
export function isOverlayNotificationPosition(
|
|
value: unknown,
|
|
): value is OverlayNotificationPosition {
|
|
return (
|
|
typeof value === 'string' &&
|
|
OVERLAY_NOTIFICATION_POSITION_VALUES.includes(value as OverlayNotificationPosition)
|
|
);
|
|
}
|