Add web push notifications for new inbox items
This commit is contained in:
Vendored
+4
@@ -33,6 +33,9 @@ export async function request(method, path, opts = {}) {
|
||||
init.body = JSON.stringify(opts.body);
|
||||
}
|
||||
const res = await fetch(url, init);
|
||||
if (res.status === 204) {
|
||||
return undefined;
|
||||
}
|
||||
const data = await res.json();
|
||||
if (!res.ok) {
|
||||
throw new ApiError(res.status, data.message);
|
||||
@@ -42,6 +45,7 @@ export async function request(method, path, opts = {}) {
|
||||
export const get = (path, opts) => request("get", path, opts);
|
||||
export const post = (path, opts) => request("post", path, opts);
|
||||
export const put = (path, opts) => request("put", path, opts);
|
||||
export const del = (path, opts) => request("delete", path, opts);
|
||||
export function subscribe(after, onEvent, onState) {
|
||||
const source = new EventSource(`/api/events?after=${after}`);
|
||||
source.onopen = () => onState(true);
|
||||
|
||||
Reference in New Issue
Block a user