Move feed, channels, sync, playlists, tags, notifications, saved-views and quota out of the lib/api.ts god object into per-domain slice modules, each owning its own types + method slice and spread into the façade. The `api` object shape and all 54 call sites are unchanged; account/auth/setup/admin stay inline until S2. Reunites the interleaved tags read/CRUD that motivated the epic.
29 lines
1.2 KiB
TypeScript
29 lines
1.2 KiB
TypeScript
// The durable, server-backed notification inbox (distinct from the client-side transient
|
|
// toast/bell, which lives only in localStorage). Only touches core's req.
|
|
import { req } from "./core";
|
|
|
|
// A durable, server-backed notification (the inbox center). Distinct from the client-side
|
|
// transient toast/bell, which lives only in localStorage.
|
|
export interface AppNotification {
|
|
id: number;
|
|
type: string;
|
|
title: string;
|
|
body: string | null;
|
|
data: Record<string, unknown> | null;
|
|
read: boolean;
|
|
dismissed: boolean;
|
|
created_at: string | null;
|
|
}
|
|
|
|
export const notificationsApi = {
|
|
notifications: (includeDismissed = false): Promise<{ items: AppNotification[]; total: number }> =>
|
|
req(`/api/me/notifications?include_dismissed=${includeDismissed}`),
|
|
notificationUnreadCount: (): Promise<{ count: number }> =>
|
|
req("/api/me/notifications/unread_count"),
|
|
markNotificationRead: (id: number) => req(`/api/me/notifications/${id}/read`, { method: "POST" }),
|
|
markAllNotificationsRead: () => req("/api/me/notifications/read_all", { method: "POST" }),
|
|
dismissNotification: (id: number) =>
|
|
req(`/api/me/notifications/${id}/dismiss`, { method: "POST" }),
|
|
clearNotifications: () => req("/api/me/notifications/clear", { method: "POST" }),
|
|
};
|