OneLauncher-Cracked/apps/desktop/src/ui/hooks/useNotifications.ts
2024-07-13 02:24:38 +02:00

29 lines
849 B
TypeScript

import { type Signal, createSignal, onMount } from 'solid-js';
type Notifications = Core.Notification[];
type OnUpdateFn = (event: Core.NotificationEvents) => unknown;
function useNotifications(onUpdate?: OnUpdateFn): Signal<Notifications> {
const [notifications, setNotifications] = createSignal<Notifications>([]);
async function update(event: Core.NotificationEvents) {
const notis: Notifications = []; // await manager.getNotifications();
setNotifications(notis);
if (onUpdate)
onUpdate(event);
}
onMount(() => {
update('init');
// manager.on('added', () => update('added'));
// manager.on('removed', () => update('removed'));
// manager.on('cleared', () => update('cleared'));
// manager.on('modified', () => update('modified'));
});
return [notifications, setNotifications];
}
export default useNotifications;