mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-05-26 00:55:16 -07:00
28 lines
1.0 KiB
TypeScript
28 lines
1.0 KiB
TypeScript
import type { UpdateNotificationType } from '../../../types/config';
|
|
|
|
export interface UpdateNotificationDeps {
|
|
showSystemNotification: (title: string, body: string) => 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 === 'system' || options.notificationType === 'both') {
|
|
deps.showSystemNotification('SubMiner update available', message);
|
|
}
|
|
if (options.notificationType === 'osd' || options.notificationType === 'both') {
|
|
try {
|
|
await deps.showOsdNotification(message);
|
|
} catch (error) {
|
|
const reason = error instanceof Error ? error.message : String(error);
|
|
deps.log(`Update OSD notification failed: ${reason}`);
|
|
}
|
|
}
|
|
}
|