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

Remove dead code

Co-authored-by: Alex Andreev <alex.andreev.email@gmail.com>

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne Savolainen 2022-06-28 12:11:40 +03:00
parent 2c39b9019f
commit 66bd8d3a17
No known key found for this signature in database
GPG Key ID: 8C6CFB2FFFE8F68A
6 changed files with 0 additions and 194 deletions

View File

@ -1,24 +0,0 @@
/**
* 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 createSyncBoxInjectable from "../../utils/sync-box/create-sync-box.injectable";
import { syncBoxInjectionToken } from "../../utils/sync-box/sync-box-injection-token";
const updateWarningLevelInjectable = getInjectable({
id: "update-warning-level",
instantiate: (di) => {
const createSyncBox = di.inject(createSyncBoxInjectable);
return createSyncBox<"light" | "medium" | "high" | "">(
"update-warning-level",
"",
);
},
injectionToken: syncBoxInjectionToken,
});
export default updateWarningLevelInjectable;

View File

@ -1,33 +0,0 @@
/**
* 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 { getStartableStoppable } from "../../../common/utils/get-startable-stoppable";
import setUpdateWarningLevelInjectable from "./set-update-warning-level.injectable";
const periodicalCheckForUpdateWarningInjectable = getInjectable({
id: "periodical-check-for-update-warning",
instantiate: (di) => {
const processCheckingForUpdateWarning = di.inject(setUpdateWarningLevelInjectable);
return getStartableStoppable("periodical-check-for-update-warning", () => {
const ONCE_A_DAY = 1000 * 60 * 60 * 24;
processCheckingForUpdateWarning();
const intervalId = setInterval(() => {
processCheckingForUpdateWarning();
}, ONCE_A_DAY);
return () => {
clearInterval(intervalId);
};
});
},
causesSideEffects: true,
});
export default periodicalCheckForUpdateWarningInjectable;

View File

@ -1,20 +0,0 @@
/**
* 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 updateDownloadedDateInjectable from "./update-downloaded-date.injectable";
const setUpdateDownloadedDateInjectable = getInjectable({
id: "set-update-downloaded-date",
instantiate: (di) => {
const downloadedDate = di.inject(updateDownloadedDateInjectable);
return (date: Date) => {
downloadedDate.set(date);
};
},
});
export default setUpdateDownloadedDateInjectable;

View File

@ -1,25 +0,0 @@
/**
* 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 updateDownloadedDateInjectable from "./update-downloaded-date.injectable";
import { UpdateWarningLevelCalculator } from "./update-warning-level-calculator";
import updateWarningLevelInjectable from "../../../common/application-update/update-warning-level/update-warning-level.injectable";
const setUpdateWarningLevelInjectable = getInjectable({
id: "set-update-warning",
instantiate: (di) => {
const updateDownloadedDate = di.inject(updateDownloadedDateInjectable);
const updateWarningLevel = di.inject(updateWarningLevelInjectable);
return () => {
const newLevel = new UpdateWarningLevelCalculator(updateDownloadedDate.value.get()).get();
updateWarningLevel.set(newLevel);
};
},
});
export default setUpdateWarningLevelInjectable;

View File

@ -1,39 +0,0 @@
/**
* 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 { afterRootFrameIsReadyInjectionToken } from "../../start-main-application/runnable-tokens/after-root-frame-is-ready-injection-token";
import downloadUpdateInjectable from "../download-update/download-update.injectable";
import periodicalCheckForUpdateWarningInjectable from "./periodical-check-for-update-warning.injectable";
import setUpdateDownloadedDateInjectable from "./set-update-downloaded-date.injectable";
import updateDownloadedDateInjectable from "./update-downloaded-date.injectable";
const startCheckingForUpdateWarningInjectable = getInjectable({
id: "start-checking-for-update-warning",
instantiate: (di) => {
const downloadUpdate = di.inject(downloadUpdateInjectable);
const updateDownloadedDate = di.inject(updateDownloadedDateInjectable);
const setUpdateDownloadedDate = di.inject(setUpdateDownloadedDateInjectable);
const periodicalCheckForUpdateWarning = di.inject(periodicalCheckForUpdateWarningInjectable);
return {
run: async () => {
const { downloadWasSuccessful } = await downloadUpdate();
if (downloadWasSuccessful) {
if (!updateDownloadedDate.value.get()) {
setUpdateDownloadedDate(new Date());
}
await periodicalCheckForUpdateWarning.start();
}
},
};
},
injectionToken: afterRootFrameIsReadyInjectionToken,
});
export default startCheckingForUpdateWarningInjectable;

View File

@ -1,53 +0,0 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
type WarningLevel = "high" | "medium" | "light" | "";
export class UpdateWarningLevelCalculator {
private onceADay = 1000 * 60 * 60 * 24;
private level: WarningLevel = "";
constructor(private updateDownloadedDate: Date | null) {
}
get(): WarningLevel {
const days = this.daysAfterUpdateAvailable;
this.setHighWarningLevel(days);
this.setMediumWarningLevel(days);
this.setLightWarningLevel(days);
return this.level;
}
private get daysAfterUpdateAvailable() {
if (!this.updateDownloadedDate) {
return 0;
}
const today = Date.now();
const elapsedTime = today - this.updateDownloadedDate.getTime();
const elapsedDays = elapsedTime / (this.onceADay);
return elapsedDays;
}
private setHighWarningLevel(elapsedDays: number) {
if (elapsedDays >= 25) {
this.level = "high";
}
}
private setMediumWarningLevel(elapsedDays: number) {
if (elapsedDays >= 20 && elapsedDays < 25) {
this.level = "medium";
}
}
private setLightWarningLevel(elapsedDays: number) {
if (elapsedDays < 20) {
this.level = "light";
}
}
}