diff --git a/.github/workflows/build-test-publish.yaml b/.github/workflows/build-test-publish.yaml index d2b2c9a5..ae5dc68b 100644 --- a/.github/workflows/build-test-publish.yaml +++ b/.github/workflows/build-test-publish.yaml @@ -48,7 +48,7 @@ jobs: run: yarn build - name: Cache build - uses: actions/cache@v2 + uses: actions/cache@v4 env: cache-name: cache-build id: cache-build @@ -56,7 +56,7 @@ jobs: path: ./* key: ${{ github.sha }} - name: Cache cypress - uses: actions/cache@v2 + uses: actions/cache@v4 env: cache-name: cache-cypress id: cache-cypress @@ -75,7 +75,7 @@ jobs: with: node-version: 14 - - uses: actions/cache@v2 + - uses: actions/cache@v4 id: restore-build with: path: ./* @@ -94,7 +94,7 @@ jobs: uses: actions/setup-node@v2 with: node-version: "14" - - uses: actions/cache@v2 + - uses: actions/cache@v4 id: restore-build with: path: ./* @@ -112,7 +112,7 @@ jobs: uses: actions/setup-node@v2 with: node-version: "14" - - uses: actions/cache@v2 + - uses: actions/cache@v4 id: restore-build with: path: ./* @@ -128,12 +128,12 @@ jobs: containers: [1, 2, 3, 4, 5, 6, 7] needs: ["build", "prepare"] steps: - - uses: actions/cache@v2 + - uses: actions/cache@v4 id: restore-build with: path: ./* key: ${{ github.sha }} - - uses: actions/cache@v2 + - uses: actions/cache@v4 id: restore-cypress with: path: /home/runner/.cache/Cypress/* @@ -168,7 +168,7 @@ jobs: node-version: 14 registry-url: "https://registry.yarnpkg.com/" - - uses: actions/cache@v2 + - uses: actions/cache@v4 id: restore-build with: path: ./* diff --git a/commons/src/store/manifest.ts b/commons/src/store/manifest.ts index 8eaf6827..c2d2a990 100644 --- a/commons/src/store/manifest.ts +++ b/commons/src/store/manifest.ts @@ -36,3 +36,18 @@ function initialize(): Writable { } export const ManifestStore = initialize(); + +/** + * Invalidate a cached manifest entry so the next access triggers a fresh fetch. + * Call after saving a manifest to prevent stale data on re-mount. + */ +export function invalidateManifestCache(componentId: string, accessToken?: string): void { + const key = JSON.stringify({ component_id: componentId, access_token: accessToken }); + ManifestStore.update((store) => { + // The store wraps a Proxy whose underlying target holds cached promises. + // Deleting the key from the store object causes the Proxy get-trap to + // re-fetch on the next access. + delete (store as Record)[key]; + return store; + }); +} diff --git a/components/schedule-editor/src/ScheduleEditor.svelte b/components/schedule-editor/src/ScheduleEditor.svelte index b904fad8..53901aab 100644 --- a/components/schedule-editor/src/ScheduleEditor.svelte +++ b/components/schedule-editor/src/ScheduleEditor.svelte @@ -20,6 +20,7 @@ import { onDestroy, onMount, tick } from "svelte"; import timezones from "timezones-list"; import { ErrorStore, ManifestStore } from "@commons"; + import { invalidateManifestCache } from "@commons/store/manifest"; import { getEventDispatcher } from "@commons/methods/component"; import { saveManifest } from "@commons/connections/manifest"; import "../../availability/src/Availability.svelte"; @@ -201,7 +202,7 @@ } // #endregion mount and prop initialization - function saveProperties() { + async function saveProperties() { const cleanedProps = { ..._this, custom_fields: _this.custom_fields.map((field) => { @@ -210,7 +211,13 @@ }), }; - saveManifest(id, cleanedProps, access_token); + await saveManifest(id, cleanedProps, access_token); + + // Invalidate the ManifestStore cache and update the local manifest so + // that both re-mounts and in-session reads reflect the saved state. + // Fixes CUST-5442: deleted custom fields reappearing after save. + invalidateManifestCache(id, access_token); + manifest = { ...cleanedProps }; } // #region unpersisted variables