mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Make setting of initial state for sync boxes not trigger irrelevant messaging to main
Co-authored-by: Janne Savolainen <janne.savolainen@live.fi> Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>
This commit is contained in:
parent
fc6fc2488c
commit
348b214ca0
@ -4,18 +4,18 @@
|
|||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { beforeFrameStartsInjectionToken } from "../before-frame-starts/before-frame-starts-injection-token";
|
import { beforeFrameStartsInjectionToken } from "../before-frame-starts/before-frame-starts-injection-token";
|
||||||
import { syncBoxInjectionToken } from "../../common/sync-box/sync-box-injection-token";
|
|
||||||
import getValueFromChannelInjectable from "../channel/get-value-from-channel.injectable";
|
import getValueFromChannelInjectable from "../channel/get-value-from-channel.injectable";
|
||||||
import syncBoxInitialValueChannelInjectable from "../../common/sync-box/sync-box-initial-value-channel.injectable";
|
import syncBoxInitialValueChannelInjectable from "../../common/sync-box/sync-box-initial-value-channel.injectable";
|
||||||
import assert from "assert";
|
import assert from "assert";
|
||||||
|
import syncBoxStateInjectable from "../../common/sync-box/sync-box-state.injectable";
|
||||||
|
|
||||||
const provideInitialValuesForSyncBoxesInjectable = getInjectable({
|
const provideInitialValuesForSyncBoxesInjectable = getInjectable({
|
||||||
id: "provide-initial-values-for-sync-boxes",
|
id: "provide-initial-values-for-sync-boxes",
|
||||||
|
|
||||||
instantiate: (di) => {
|
instantiate: (di) => {
|
||||||
const syncBoxes = di.injectMany(syncBoxInjectionToken);
|
|
||||||
const getValueFromChannel = di.inject(getValueFromChannelInjectable);
|
const getValueFromChannel = di.inject(getValueFromChannelInjectable);
|
||||||
const syncBoxInitialValueChannel = di.inject(syncBoxInitialValueChannelInjectable);
|
const syncBoxInitialValueChannel = di.inject(syncBoxInitialValueChannelInjectable);
|
||||||
|
const setSyncBoxState = (id: string, state: any) => di.inject(syncBoxStateInjectable, id).set(state);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
run: async () => {
|
run: async () => {
|
||||||
@ -24,11 +24,7 @@ const provideInitialValuesForSyncBoxesInjectable = getInjectable({
|
|||||||
assert(initialValues);
|
assert(initialValues);
|
||||||
|
|
||||||
initialValues.forEach(({ id, value }) => {
|
initialValues.forEach(({ id, value }) => {
|
||||||
const targetBox = syncBoxes.find(box => box.id === id);
|
setSyncBoxState(id, value);
|
||||||
|
|
||||||
if (targetBox) {
|
|
||||||
targetBox.set(value);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user