diff --git a/src/common/application-update/discovered-update-version/discovered-update-version.injectable.ts b/src/common/application-update/discovered-update-version/discovered-update-version.injectable.ts index ade09c8960..ad08af6331 100644 --- a/src/common/application-update/discovered-update-version/discovered-update-version.injectable.ts +++ b/src/common/application-update/discovered-update-version/discovered-update-version.injectable.ts @@ -13,9 +13,13 @@ const discoveredUpdateVersionInjectable = getInjectable({ instantiate: (di) => { const createSyncBox = di.inject(createSyncBoxInjectable); - return createSyncBox<{ version: string; updateChannel: UpdateChannel } | null>( - "discovered-update-version", - ); + return createSyncBox< + | { version: string; updateChannel: UpdateChannel } + | null + >( + "discovered-update-version", + null, + ); }, injectionToken: syncBoxInjectionToken, diff --git a/src/common/application-update/progress-of-update-download/progress-of-update-download.injectable.ts b/src/common/application-update/progress-of-update-download/progress-of-update-download.injectable.ts index c615a08a0d..7c21031f49 100644 --- a/src/common/application-update/progress-of-update-download/progress-of-update-download.injectable.ts +++ b/src/common/application-update/progress-of-update-download/progress-of-update-download.injectable.ts @@ -12,7 +12,7 @@ const progressOfUpdateDownloadInjectable = getInjectable({ instantiate: (di) => { const createSyncBox = di.inject(createSyncBoxInjectable); - return createSyncBox("progress-of-update-download"); + return createSyncBox("progress-of-update-download", 0); }, injectionToken: syncBoxInjectionToken, diff --git a/src/common/application-update/update-is-being-downloaded/update-is-being-downloaded.injectable.ts b/src/common/application-update/update-is-being-downloaded/update-is-being-downloaded.injectable.ts index 1cc2c18f64..e80a77bdd3 100644 --- a/src/common/application-update/update-is-being-downloaded/update-is-being-downloaded.injectable.ts +++ b/src/common/application-update/update-is-being-downloaded/update-is-being-downloaded.injectable.ts @@ -12,7 +12,7 @@ const updateIsBeingDownloadedInjectable = getInjectable({ instantiate: (di) => { const createSyncBox = di.inject(createSyncBoxInjectable); - return createSyncBox("update-is-being-downloaded"); + return createSyncBox("update-is-being-downloaded", false); }, injectionToken: syncBoxInjectionToken, diff --git a/src/common/application-update/updates-are-being-discovered/updates-are-being-discovered.injectable.ts b/src/common/application-update/updates-are-being-discovered/updates-are-being-discovered.injectable.ts index 8e18d105b6..54bc58e44a 100644 --- a/src/common/application-update/updates-are-being-discovered/updates-are-being-discovered.injectable.ts +++ b/src/common/application-update/updates-are-being-discovered/updates-are-being-discovered.injectable.ts @@ -12,7 +12,7 @@ const updatesAreBeingDiscoveredInjectable = getInjectable({ instantiate: (di) => { const createSyncBox = di.inject(createSyncBoxInjectable); - return createSyncBox("updates-are-being-discovered"); + return createSyncBox("updates-are-being-discovered", false); }, injectionToken: syncBoxInjectionToken, diff --git a/src/common/sync-box/create-sync-box.injectable.ts b/src/common/sync-box/create-sync-box.injectable.ts index bd92858969..5ac9c8dd04 100644 --- a/src/common/sync-box/create-sync-box.injectable.ts +++ b/src/common/sync-box/create-sync-box.injectable.ts @@ -17,9 +17,11 @@ const createSyncBoxInjectable = getInjectable({ const sendToChannel = di.inject(sendToChannelInjectionToken); const getSyncBoxState = (id: string) => di.inject(syncBoxStateInjectable, id); - return (id: string): SyncBox => { + return (id: string, initialValue: TData): SyncBox => { const state = getSyncBoxState(id); + state.set(initialValue); + return { id, diff --git a/src/common/sync-box/sync-box.test.ts b/src/common/sync-box/sync-box.test.ts index 458f4b6f3c..5141db40a5 100644 --- a/src/common/sync-box/sync-box.test.ts +++ b/src/common/sync-box/sync-box.test.ts @@ -126,12 +126,12 @@ describe("sync-box", () => { }, true); }); - it("does not know initial value in main", () => { - expect(valueInMain).toBeUndefined(); + it("knows initial value in main", () => { + expect(valueInMain).toBe("some-initial-value"); }); - it("does not know initial value in renderer", () => { - expect(valueInRenderer).toBeUndefined(); + it("knows initial value in renderer", () => { + expect(valueInRenderer).toBe("some-initial-value"); }); describe("when value is set from main", () => { @@ -174,6 +174,6 @@ const someInjectable = getInjectable({ instantiate: (di) => { const createSyncBox = di.inject(createSyncBoxInjectable); - return createSyncBox("some-state"); + return createSyncBox("some-sync-box", "some-initial-value"); }, });