mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-15 15:02:04 +00:00
fix(notifications): show the mood reminder's real default in the matrix
The /notifications matrix read the constant default table, where the mood reminder is off, while delivery derives it from the reminder card. An account receiving the reminder saw every one of its channel switches off. The no-row default now lives in one resolver that delivery and the preferences read both use. GET /api/notifications/preferences publishes it as `eventDefaults`, the matrix renders a switch without a stored row from that map, and the reminder card refreshes the matrix when it flips.
This commit is contained in:
1 parent
421aacf457
commit
dc704b5e63
10 files changed
+487
-27
No files matched your search
@@ -12,6 +12,7 @@ import { notificationPreferenceSchema } from "@/lib/validations/notifications";
|
||||
import { EVENT_TYPES, CHANNEL_TYPE_LABELS } from "@/lib/notifications/types";
|
||||
import type { ChannelType } from "@/lib/notifications/types";
|
||||
import { decrypt, encrypt } from "@/lib/crypto";
|
||||
import { resolveEventDefaults } from "@/lib/notifications/event-defaults";
|
||||
|
||||
export const GET = apiHandler(async () => {
|
||||
const { user } = await requireAuth();
|
||||
@@ -92,6 +93,12 @@ export const GET = apiHandler(async () => {
|
||||
channels: channelData,
|
||||
preferences,
|
||||
eventTypes: EVENT_TYPES as unknown as string[],
|
||||
// What an event does on a channel with no stored row, resolved for this
|
||||
// account by the same function the dispatcher asks. A client renders a
|
||||
// switch without a row from this map, never from its own copy of the
|
||||
// defaults: the mood reminder's follows the reminder card, which a
|
||||
// constant table cannot know.
|
||||
eventDefaults: await resolveEventDefaults(user.id),
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user