feat: redesign notifications settings with per-category in-app/push table
- Add notify_new_chapters_push field to AppUser, PATCH /api/profile, and profile loader - Fix bell panel to reload notifications on every open (not just once on mount) - Replace flat in-app + push toggles with structured category table (Category | In-app | Push) - Add browser push master subscribe/unsubscribe row above the table - Push column toggle disabled until browser is subscribed; shows — when unsupported/denied - Update Notifications row hint to summarise active channels (In-app · Push / Off)
This commit is contained in:
@@ -7,7 +7,7 @@ import { log } from '$lib/server/logger';
|
||||
* PATCH /api/profile
|
||||
*
|
||||
* Update mutable profile preferences (currently: notification preferences).
|
||||
* Body: { notify_new_chapters?: boolean }
|
||||
* Body: { notify_new_chapters?: boolean, notify_new_chapters_push?: boolean }
|
||||
*/
|
||||
export const PATCH: RequestHandler = async ({ locals, request }) => {
|
||||
if (!locals.user) error(401, 'Not authenticated');
|
||||
@@ -19,10 +19,13 @@ export const PATCH: RequestHandler = async ({ locals, request }) => {
|
||||
error(400, 'Invalid JSON');
|
||||
}
|
||||
|
||||
const prefs: { notify_new_chapters?: boolean } = {};
|
||||
const prefs: { notify_new_chapters?: boolean; notify_new_chapters_push?: boolean } = {};
|
||||
if (typeof body.notify_new_chapters === 'boolean') {
|
||||
prefs.notify_new_chapters = body.notify_new_chapters;
|
||||
}
|
||||
if (typeof body.notify_new_chapters_push === 'boolean') {
|
||||
prefs.notify_new_chapters_push = body.notify_new_chapters_push;
|
||||
}
|
||||
|
||||
if (Object.keys(prefs).length === 0) {
|
||||
error(400, 'No valid preferences provided');
|
||||
|
||||
Reference in New Issue
Block a user