mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-10 04:22:09 +10:00
13 lines
377 B
TypeScript
13 lines
377 B
TypeScript
import type { Notification } from "@prisma/client";
|
|
|
|
const ws = new WebSocketHandler("/api/v1/notifications/ws");
|
|
|
|
export const useNotifications = () =>
|
|
useState<Array<Notification>>("notifications", () => []);
|
|
|
|
ws.listen((e) => {
|
|
const notification = JSON.parse(e) as Notification;
|
|
const notifications = useNotifications();
|
|
notifications.value.push(notification);
|
|
});
|