mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
31 lines
1.0 KiB
TypeScript
31 lines
1.0 KiB
TypeScript
/**
|
|
* 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 assert from "assert";
|
|
import { computed } from "mobx";
|
|
import moment from "moment";
|
|
import updateDownloadedDateTimeInjectable from "../../../common/application-update/update-downloaded-date-time/update-downloaded-date-time.injectable";
|
|
import { reactiveNow } from "../../../common/utils/reactive-now/reactive-now";
|
|
|
|
const timeSinceUpdateWasDownloadedInjectable = getInjectable({
|
|
id: "time-since-update-was-downloaded",
|
|
|
|
instantiate: (di) => {
|
|
const updateDownloadedDateTime = di.inject(updateDownloadedDateTimeInjectable);
|
|
|
|
return computed(() => {
|
|
const currentTimestamp = reactiveNow();
|
|
|
|
const downloadedAt = updateDownloadedDateTime.value.get();
|
|
|
|
assert(downloadedAt);
|
|
|
|
return currentTimestamp - (moment(downloadedAt).unix() * 1000);
|
|
});
|
|
},
|
|
});
|
|
|
|
export default timeSinceUpdateWasDownloadedInjectable;
|