mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-06-10 03:13:32 -07:00
8111deac44
- New toggleNotificationHistory (Ctrl+N) session-scoped history panel; slides in from same edge as notification stack - Overlay error/recovery toast follows notifications.overlayPosition; stack and history side seeded at startup - Cold managed background startup initializes tray and visible overlay shell before tokenization warmups finish - Add Update button to overlay update-available notifications - Fix Ctrl+S sentence-card flow: only Anki progress notification, no duplicate status toast - Fix overlay notification close/actions clickability above subtitle bars on Linux - Increase pause-until-ready default timeout from 15s to 30s
47 lines
1.7 KiB
TypeScript
47 lines
1.7 KiB
TypeScript
import type { UpdateNotificationType } from '../../../types/config';
|
|
import type { OverlayNotificationPayload } from '../../../types/notification';
|
|
|
|
export const UPDATE_AVAILABLE_NOTIFICATION_ID = 'subminer-update-available';
|
|
export const INSTALL_UPDATE_ACTION_ID = 'install-update';
|
|
|
|
export interface UpdateNotificationDeps {
|
|
showSystemNotification: (title: string, body: string) => void;
|
|
showOverlayNotification: (payload: OverlayNotificationPayload) => void;
|
|
showOsdNotification: (message: string) => void | Promise<void>;
|
|
log: (message: string) => void;
|
|
}
|
|
|
|
export async function notifyUpdateAvailable(
|
|
options: { notificationType: UpdateNotificationType; version: string },
|
|
deps: UpdateNotificationDeps,
|
|
): Promise<void> {
|
|
if (options.notificationType === 'none') return;
|
|
|
|
const message = `SubMiner v${options.version} is available`;
|
|
if (options.notificationType === 'overlay' || options.notificationType === 'both') {
|
|
deps.showOverlayNotification({
|
|
id: UPDATE_AVAILABLE_NOTIFICATION_ID,
|
|
title: 'SubMiner update available',
|
|
body: message,
|
|
variant: 'info',
|
|
persistent: true,
|
|
actions: [{ id: INSTALL_UPDATE_ACTION_ID, label: 'Update' }],
|
|
});
|
|
}
|
|
if (options.notificationType === 'osd' || options.notificationType === 'osd-system') {
|
|
try {
|
|
await deps.showOsdNotification(message);
|
|
} catch (error) {
|
|
const reason = error instanceof Error ? error.message : String(error);
|
|
deps.log(`Update OSD notification failed: ${reason}`);
|
|
}
|
|
}
|
|
if (
|
|
options.notificationType === 'system' ||
|
|
options.notificationType === 'both' ||
|
|
options.notificationType === 'osd-system'
|
|
) {
|
|
deps.showSystemNotification('SubMiner update available', message);
|
|
}
|
|
}
|