Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | 2209x 2209x 3x 3x 3x 2209x 3x 3x 3x 2209x 3x 3x | import type { Inbox } from "@/objects/Notification";
import { Dictionary } from "@/types/ext";
import { AxiosRequestConfig } from "axios";
import { APIRouter } from "../ApiRouter";
/**
* The inbox (svc-core `/app/notifications`): a person's notifications across
* every workspace they belong to — budget alerts, statements ready.
*/
export class NotificationRouter extends APIRouter {
constructor(
host: string,
token: string | null = null,
default_config: AxiosRequestConfig | null = null,
headers: Dictionary<string> = {},
) {
super("notifications", host, token, default_config, headers);
}
/** The newest notifications, and how many are unread. */
list = async (): Promise<Inbox | null> => {
const res = await this.api.get<Inbox>(super.endpoint(""));
Eif (super.validRes(res)) {
return res.data;
}
return null;
};
/** Mark one read. Resolves the unread count, or null on failure. */
markRead = async (id: string): Promise<number | null> => {
const res = await this.api.post<{ unread: number }>(
super.endpoint(`${id}/read`),
{},
);
Eif (super.validRes(res)) {
return res.data.unread;
}
return null;
};
/** Mark every one read. */
markAllRead = async (): Promise<boolean> => {
const res = await this.api.post<{ unread: number }>(
super.endpoint("read-all"),
{},
);
return super.validRes(res);
};
}
|