import { authedGet, authedPost, type AppviewContext } from "./appview"; import type { XrpcRequestInit } from "./client"; // mirrors org.tangled.temp.notification.getPreferences#preferences export interface NotificationPreferences { repoStarred: boolean; issueCreated: boolean; issueCommented: boolean; issueClosed: boolean; pullCreated: boolean; pullCommented: boolean; pullMerged: boolean; followed: boolean; userMentioned: boolean; emailNotifications: boolean; } const GET_PREFERENCES = "org.tangled.temp.notification.getPreferences"; const UPDATE_PREFERENCES = "org.tangled.temp.notification.updatePreferences"; export const getNotificationPreferences = ( ctx: AppviewContext, init?: XrpcRequestInit ): Promise => authedGet(ctx, GET_PREFERENCES, undefined, init); // only the provided fields are updated server-side. export const updateNotificationPreferences = ( ctx: AppviewContext, patch: Partial, init?: XrpcRequestInit ): Promise => authedPost(ctx, UPDATE_PREFERENCES, patch, init).then(() => undefined);