mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Extract responsibility to injectable
Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com> Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
parent
678043e34e
commit
96b5771b08
@ -42,10 +42,14 @@ autoUpdater.logger = {
|
|||||||
debug: message => logger.debug(`[AUTO-UPDATE]: electron-updater: %s`, message),
|
debug: message => logger.debug(`[AUTO-UPDATE]: electron-updater: %s`, message),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
interface Dependencies {
|
||||||
|
isAutoUpdateEnabled: () => boolean;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* starts the automatic update checking
|
* starts the automatic update checking
|
||||||
*/
|
*/
|
||||||
export const startUpdateChecking = (isAutoUpdateEnabled : () => boolean) => once(function (interval = 1000 * 60 * 60 * 24): void {
|
export const startUpdateChecking = ({ isAutoUpdateEnabled } : Dependencies) => once(function (interval = 1000 * 60 * 60 * 24): void {
|
||||||
if (!isAutoUpdateEnabled() || isTestEnv) {
|
if (!isAutoUpdateEnabled() || isTestEnv) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,24 +4,21 @@
|
|||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { afterRootFrameIsReadyInjectionToken } from "../../start-main-application/runnable-tokens/after-root-frame-is-ready-injection-token";
|
import { afterRootFrameIsReadyInjectionToken } from "../../start-main-application/runnable-tokens/after-root-frame-is-ready-injection-token";
|
||||||
import { startUpdateChecking } from "../../app-updater";
|
import startUpdateCheckingInjectable from "../../start-update-checking.injectable";
|
||||||
import isAutoUpdateEnabledInjectable from "../../is-auto-update-enabled.injectable";
|
|
||||||
|
|
||||||
const setupUpdateCheckingInjectable = getInjectable({
|
const setupUpdateCheckingInjectable = getInjectable({
|
||||||
id: "setup-update-checking",
|
id: "setup-update-checking",
|
||||||
|
|
||||||
instantiate: (di) => {
|
instantiate: (di) => {
|
||||||
const isAutoUpdateEnabled = di.inject(isAutoUpdateEnabledInjectable);
|
const startUpdateChecking = di.inject(startUpdateCheckingInjectable);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
run: () => {
|
run: () => {
|
||||||
startUpdateChecking(isAutoUpdateEnabled)();
|
startUpdateChecking();
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
causesSideEffects: true,
|
|
||||||
|
|
||||||
injectionToken: afterRootFrameIsReadyInjectionToken,
|
injectionToken: afterRootFrameIsReadyInjectionToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
19
src/main/start-update-checking.injectable.ts
Normal file
19
src/main/start-update-checking.injectable.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
|
import { startUpdateChecking } from "./app-updater";
|
||||||
|
import isAutoUpdateEnabledInjectable from "./is-auto-update-enabled.injectable";
|
||||||
|
|
||||||
|
const startUpdateCheckingInjectable = getInjectable({
|
||||||
|
id: "start-update-checking",
|
||||||
|
|
||||||
|
instantiate: (di) => startUpdateChecking({
|
||||||
|
isAutoUpdateEnabled: di.inject(isAutoUpdateEnabledInjectable),
|
||||||
|
}),
|
||||||
|
|
||||||
|
causesSideEffects: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
export default startUpdateCheckingInjectable;
|
||||||
Loading…
Reference in New Issue
Block a user