Files
popa-launcher/src/renderer/utils/notifications.ts
2025-12-14 21:14:59 +05:00

40 lines
1.2 KiB
TypeScript

import type { NotificationPosition } from '../components/Notifications/CustomNotification';
export function isNotificationsEnabled(): boolean {
try {
const s = JSON.parse(localStorage.getItem('launcher_settings') || '{}');
return s.notifications !== false; // по умолчанию true
} catch {
return true;
}
}
export function positionFromSettingValue(
v: string | undefined,
): NotificationPosition {
switch (v) {
case 'top-left':
return { vertical: 'top', horizontal: 'left' };
case 'top-center':
return { vertical: 'top', horizontal: 'center' };
case 'top-right':
return { vertical: 'top', horizontal: 'right' };
case 'bottom-left':
return { vertical: 'bottom', horizontal: 'left' };
case 'bottom-center':
return { vertical: 'bottom', horizontal: 'center' };
case 'bottom-right':
default:
return { vertical: 'bottom', horizontal: 'right' };
}
}
export function getNotifPositionFromSettings(): NotificationPosition {
try {
const s = JSON.parse(localStorage.getItem('launcher_settings') || '{}');
return positionFromSettingValue(s.notificationPosition);
} catch {
return { vertical: 'top', horizontal: 'right' };
}
}