mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-01-24 05:54:55 +03:00
fix: game session duration calculation
This commit is contained in:
parent
e092d701b4
commit
f019820458
@ -96,7 +96,7 @@ export const watchProcesses = async () => {
|
|||||||
const runningGames = Array.from(gamesPlaytime.entries()).map((entry) => {
|
const runningGames = Array.from(gamesPlaytime.entries()).map((entry) => {
|
||||||
return {
|
return {
|
||||||
id: entry[0],
|
id: entry[0],
|
||||||
sessionDurationInMillis: entry[1].firstTick - performance.now(),
|
sessionDurationInMillis: performance.now() - entry[1].firstTick,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ export function useDate() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
formatDistanceInMillis: (
|
formatDiffInMillis: (
|
||||||
millis: number,
|
millis: number,
|
||||||
baseDate: string | number | Date,
|
baseDate: string | number | Date,
|
||||||
options?: FormatDistanceOptions
|
options?: FormatDistanceOptions
|
||||||
|
@ -42,7 +42,7 @@ export function UserContent({
|
|||||||
});
|
});
|
||||||
}, [i18n.language]);
|
}, [i18n.language]);
|
||||||
|
|
||||||
const { formatDistance, formatDistanceInMillis } = useDate();
|
const { formatDistance, formatDiffInMillis } = useDate();
|
||||||
|
|
||||||
const formatPlayTime = () => {
|
const formatPlayTime = () => {
|
||||||
const seconds = userProfile.libraryGames.reduce(
|
const seconds = userProfile.libraryGames.reduce(
|
||||||
@ -160,9 +160,9 @@ export function UserContent({
|
|||||||
</div>
|
</div>
|
||||||
<small>
|
<small>
|
||||||
{t("playing_for", {
|
{t("playing_for", {
|
||||||
amount: formatDistanceInMillis(
|
amount: formatDiffInMillis(
|
||||||
runningGame.sessionDurationInMillis,
|
runningGame.sessionDurationInMillis,
|
||||||
new Date().getTime()
|
new Date()
|
||||||
),
|
),
|
||||||
})}
|
})}
|
||||||
</small>
|
</small>
|
||||||
|
Loading…
Reference in New Issue
Block a user