feat(notifications): add overlay notifications with position config (#110)

This commit is contained in:
2026-06-10 22:46:52 -07:00
committed by GitHub
parent c09d009a3e
commit 7be1843c41
177 changed files with 7524 additions and 440 deletions
@@ -1,7 +1,12 @@
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;
}
@@ -13,10 +18,17 @@ export async function notifyUpdateAvailable(
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 === '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 === 'both') {
if (options.notificationType === 'osd' || options.notificationType === 'osd-system') {
try {
await deps.showOsdNotification(message);
} catch (error) {
@@ -24,4 +36,11 @@ export async function notifyUpdateAvailable(
deps.log(`Update OSD notification failed: ${reason}`);
}
}
if (
options.notificationType === 'system' ||
options.notificationType === 'both' ||
options.notificationType === 'osd-system'
) {
deps.showSystemNotification('SubMiner update available', message);
}
}