1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Fix getting initial value of sync box

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne Savolainen 2022-07-29 09:28:34 +03:00
parent 326c8a950c
commit 55b27de10a
No known key found for this signature in database
GPG Key ID: 8C6CFB2FFFE8F68A
2 changed files with 22 additions and 3 deletions

View File

@ -105,6 +105,11 @@ describe("encourage user to update when sufficient time passed since update was
expect(button).toHaveAttribute("data-warning-level", "light"); expect(button).toHaveAttribute("data-warning-level", "light");
}); });
// TODO: Implement after starting main and renderer is separated in ApplicationBuilder
xit("given closing the application window, when starting the application window again, still shows the button", () => {
expect(button).toBeInTheDocument();
});
describe("given some time passes, when checking for updates again", () => { describe("given some time passes, when checking for updates again", () => {
beforeEach(() => { beforeEach(() => {
advanceFakeTime(daysToMilliseconds(2)); advanceFakeTime(daysToMilliseconds(2));

View File

@ -7,6 +7,10 @@ import { beforeFrameStartsInjectionToken } from "../../before-frame-starts/befor
import syncBoxInitialValueChannelInjectable from "../../../common/utils/sync-box/sync-box-initial-value-channel.injectable"; import syncBoxInitialValueChannelInjectable from "../../../common/utils/sync-box/sync-box-initial-value-channel.injectable";
import createSyncBoxStateInjectable from "../../../common/utils/sync-box/sync-box-state.injectable"; import createSyncBoxStateInjectable from "../../../common/utils/sync-box/sync-box-state.injectable";
import { requestFromChannelInjectionToken } from "../../../common/utils/channel/request-from-channel-injection-token"; import { requestFromChannelInjectionToken } from "../../../common/utils/channel/request-from-channel-injection-token";
import { runInAction } from "mobx";
import type { SyncBox } from "../../../common/utils/sync-box/sync-box-injection-token";
import { syncBoxInjectionToken } from "../../../common/utils/sync-box/sync-box-injection-token";
import assert from "assert";
const provideInitialValuesForSyncBoxesInjectable = getInjectable({ const provideInitialValuesForSyncBoxesInjectable = getInjectable({
id: "provide-initial-values-for-sync-boxes", id: "provide-initial-values-for-sync-boxes",
@ -14,14 +18,24 @@ const provideInitialValuesForSyncBoxesInjectable = getInjectable({
instantiate: (di) => { instantiate: (di) => {
const requestFromChannel = di.inject(requestFromChannelInjectionToken); const requestFromChannel = di.inject(requestFromChannelInjectionToken);
const syncBoxInitialValueChannel = di.inject(syncBoxInitialValueChannelInjectable); const syncBoxInitialValueChannel = di.inject(syncBoxInitialValueChannelInjectable);
const setSyncBoxState = (id: string, state: any) => di.inject(createSyncBoxStateInjectable, id).set(state);
const syncBoxes = di.injectMany(syncBoxInjectionToken);
const setSyncBoxState = (syncBox: SyncBox<any>, state: any) =>
di.inject(createSyncBoxStateInjectable, syncBox.id).set(state);
return { return {
run: async () => { run: async () => {
const initialValues = await requestFromChannel(syncBoxInitialValueChannel); const initialValues = await requestFromChannel(syncBoxInitialValueChannel);
initialValues.forEach(({ id, value }) => { runInAction(() => {
setSyncBoxState(id, value); initialValues.forEach(({ id, value }) => {
const syncBox = syncBoxes.find((box) => box.id === id);
assert(syncBox);
setSyncBoxState(syncBox, value);
});
}); });
}, },
}; };