mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-13 14:32:03 +00:00
fix(backup): fold a pre-0343 Coach availability key on instance restore
Migration 0343 moved the operator's Coach answer from module availability into the Coach switch and folded every live row. Restoring the instance settings from an older file wrote the dead coach key back into module availability and left the Coach switch on, so a Coach the operator had off came back. The restore now applies the same fold: coach false in the file's module availability switches the Coach off, and the key is dropped either way.
This commit is contained in:
1 parent
2c1e0f5bca
commit
091e4b84cb
4 files changed
+124
-2
No files matched your search
@@ -71,6 +71,7 @@ import { restoreAwardsData } from "@/lib/export/awards-backup";
|
||||
import { restoreEnvironmentData } from "@/lib/export/environment-backup";
|
||||
import { restoreEcgData } from "@/lib/export/ecg-backup";
|
||||
import { invalidateUserData } from "@/lib/cache/invalidate";
|
||||
import { foldLegacyCoachAvailability } from "@/lib/modules/operator-availability";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
@@ -483,6 +484,12 @@ const handler = apiHandler(
|
||||
// the account restore assumes.
|
||||
if (payload.appSettings && restoreInstanceSettings) {
|
||||
const settings = payload.appSettings;
|
||||
// A file from before 0343 carries the Coach's operator answer in
|
||||
// module availability; carry it into the Coach switch.
|
||||
const coachFold = foldLegacyCoachAvailability(
|
||||
settings.moduleAvailabilityJson,
|
||||
settings.assistantCoachEnabled,
|
||||
);
|
||||
const settingsData = {
|
||||
registrationEnabled: settings.registrationEnabled,
|
||||
mfaRequired: settings.mfaRequired,
|
||||
@@ -523,13 +530,13 @@ const handler = apiHandler(
|
||||
settings.adminAiInsightsFeedbackSummary as never,
|
||||
defaultUserTimezone: settings.defaultUserTimezone,
|
||||
assistantEnabled: settings.assistantEnabled,
|
||||
assistantCoachEnabled: settings.assistantCoachEnabled,
|
||||
assistantCoachEnabled: coachFold.assistantCoachEnabled,
|
||||
assistantBriefingEnabled: settings.assistantBriefingEnabled,
|
||||
assistantInsightStatusEnabled:
|
||||
settings.assistantInsightStatusEnabled,
|
||||
assistantDocumentAiEnabled:
|
||||
settings.assistantDocumentAiEnabled ?? true,
|
||||
moduleAvailabilityJson: settings.moduleAvailabilityJson as never,
|
||||
moduleAvailabilityJson: coachFold.moduleAvailabilityJson as never,
|
||||
documentMaxFileBytes: settings.documentMaxFileBytes,
|
||||
documentQuotaBytes: BigInt(settings.documentQuotaBytes),
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user