refactor(api): extract 8 content domains into api/*.ts slices (R7.5 S1)
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.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
// Saved "smart views": per-user named snapshots of FeedFilters (see SavedViewsWidget).
|
||||
// Only touches core's req; the FeedFilters shape is owned by feed.ts.
|
||||
import { req } from "./core";
|
||||
import type { FeedFilters } from "./feed";
|
||||
|
||||
// A saved "smart view": a per-user named snapshot of FeedFilters (see SavedViewsWidget).
|
||||
export interface SavedView {
|
||||
id: number;
|
||||
name: string;
|
||||
filters: FeedFilters;
|
||||
position: number;
|
||||
is_default: boolean;
|
||||
}
|
||||
|
||||
export const savedViewsApi = {
|
||||
savedViews: (): Promise<SavedView[]> => req("/api/saved-views"),
|
||||
createView: (name: string, filters: FeedFilters): Promise<SavedView> =>
|
||||
req("/api/saved-views", { method: "POST", body: JSON.stringify({ name, filters }) }),
|
||||
updateView: (
|
||||
id: number,
|
||||
patch: Partial<{ name: string; filters: FeedFilters; is_default: boolean }>,
|
||||
): Promise<SavedView> =>
|
||||
req(`/api/saved-views/${id}`, { method: "PATCH", body: JSON.stringify(patch) }),
|
||||
deleteView: (id: number): Promise<{ deleted: number }> =>
|
||||
req(`/api/saved-views/${id}`, { method: "DELETE" }),
|
||||
reorderViews: (ids: number[]): Promise<{ ok: boolean }> =>
|
||||
req("/api/saved-views/reorder", { method: "POST", body: JSON.stringify({ ids }) }),
|
||||
};
|
||||
Reference in New Issue
Block a user