mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Replace all usages of "now" from mobx-utils with our own kludge to get rid of shared global state between unit tests
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
parent
9e5f0b468b
commit
0c4e3dcc1a
@ -4,9 +4,9 @@
|
||||
*/
|
||||
|
||||
import { observer } from "mobx-react";
|
||||
import { now } from "mobx-utils";
|
||||
import React from "react";
|
||||
import { formatDuration } from "../../utils";
|
||||
import { reactiveNow } from "../../../common/utils/reactive-now/reactive-now";
|
||||
|
||||
export interface ReactiveDurationProps {
|
||||
timestamp: string | undefined;
|
||||
@ -42,7 +42,7 @@ export const ReactiveDuration = observer(({ timestamp, compact = true }: Reactiv
|
||||
|
||||
return (
|
||||
<>
|
||||
{formatDuration(now(computeUpdateInterval(timestampSeconds)) - timestampSeconds, compact)}
|
||||
{formatDuration(reactiveNow(computeUpdateInterval(timestampSeconds)) - timestampSeconds, compact)}
|
||||
</>
|
||||
);
|
||||
});
|
||||
|
||||
@ -15,7 +15,7 @@ import type { UpdateIsBeingDownloaded } from "../../../common/application-update
|
||||
import updateIsBeingDownloadedInjectable from "../../../common/application-update/update-is-being-downloaded/update-is-being-downloaded.injectable";
|
||||
import type { UpdatesAreBeingDiscovered } from "../../../common/application-update/updates-are-being-discovered/updates-are-being-discovered.injectable";
|
||||
import updatesAreBeingDiscoveredInjectable from "../../../common/application-update/updates-are-being-discovered/updates-are-being-discovered.injectable";
|
||||
import { now as reactiveDateNow } from "mobx-utils";
|
||||
import { reactiveNow } from "../../../common/utils/reactive-now/reactive-now";
|
||||
|
||||
interface Dependencies {
|
||||
progressOfUpdateDownload: ProgressOfUpdateDownload;
|
||||
@ -32,10 +32,10 @@ interface EndNoteProps {
|
||||
const EndNote = observer(({ version, note }: EndNoteProps) => {
|
||||
const [start] = useState(Date.now());
|
||||
|
||||
if (start + 5000 <= reactiveDateNow()) {
|
||||
if (start + 5000 <= reactiveNow()) {
|
||||
return idle();
|
||||
}
|
||||
|
||||
|
||||
return note(version ?? "");
|
||||
});
|
||||
|
||||
|
||||
@ -4,8 +4,8 @@
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { computed } from "mobx";
|
||||
import { now as reactiveDateNow } from "mobx-utils";
|
||||
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 updateWarningLevelInjectable = getInjectable({
|
||||
id: "update-warning-level",
|
||||
@ -23,7 +23,7 @@ const updateWarningLevelInjectable = getInjectable({
|
||||
const ONE_DAY = 1000 * 60 * 60 * 24;
|
||||
|
||||
const downloadedAtTimestamp = new Date(downloadedAt).getTime();
|
||||
const currentDateTimeTimestamp = reactiveDateNow(ONE_DAY);
|
||||
const currentDateTimeTimestamp = reactiveNow(ONE_DAY);
|
||||
|
||||
const elapsedTime = currentDateTimeTimestamp - downloadedAtTimestamp;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user