mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Open application only if new update is available when using tray to check for updates (#5948)
* Prevent opening of application if no new updates were downloaded when checking for updates using tray when application window is closed Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Fix getting initial value of sync box Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Tweak naming of variable Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
1 parent
a68ce2b2be
commit
af4b74d9bd
8 files changed
+110
-52
No files matched your search
@@ -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 createSyncBoxStateInjectable from "../../../common/utils/sync-box/sync-box-state.injectable";
|
||||
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({
|
||||
id: "provide-initial-values-for-sync-boxes",
|
||||
@@ -14,14 +18,24 @@ const provideInitialValuesForSyncBoxesInjectable = getInjectable({
|
||||
instantiate: (di) => {
|
||||
const requestFromChannel = di.inject(requestFromChannelInjectionToken);
|
||||
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 {
|
||||
run: async () => {
|
||||
const initialValues = await requestFromChannel(syncBoxInitialValueChannel);
|
||||
|
||||
initialValues.forEach(({ id, value }) => {
|
||||
setSyncBoxState(id, value);
|
||||
runInAction(() => {
|
||||
initialValues.forEach(({ id, value }) => {
|
||||
const syncBox = syncBoxes.find((box) => box.id === id);
|
||||
|
||||
assert(syncBox);
|
||||
|
||||
setSyncBoxState(syncBox, value);
|
||||
});
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user