fix(ui): tweak DateFromNow output

This commit is contained in:
Łukasz Mierzwa
2020-06-17 20:24:35 +01:00
committed by Łukasz Mierzwa
parent 6ec85d6ffb
commit f1e5974cdb

View File

@@ -7,8 +7,8 @@ import formatDistanceToNowStrict from "date-fns/formatDistanceToNowStrict";
const formatLabel = (timestamp: string) => {
const ts = parseISO(timestamp);
const diff = differenceInSeconds(new Date(), ts);
if (diff > 0 && diff < 60) return "a few seconds ago";
if (diff < 0 && diff >= -60) return "in a few seconds";
if (diff > 0 && diff < 45) return "a few seconds ago";
if (diff < 0 && diff >= -45) return "in a few seconds";
if (diff === 0) return "just now";
return formatDistanceToNowStrict(ts, {
addSuffix: true,