aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2021-12-05 20:13:05 +0300
committereug-vs <eugene@eug-vs.xyz>2021-12-05 20:13:05 +0300
commit3181772393b7c0b44056886ef6cd14e244ba61de (patch)
tree717d28966f67663be13f9241162592d2fa0994f7
parentc9861261ab6cfa17b1744b00e9ed4bc12792c681 (diff)
downloadwhich-ui-master.tar.gz
fix: correctly show timestamps for very old postsHEADmaster
-rw-r--r--src/components/DateString/compactDateString.ts3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/components/DateString/compactDateString.ts b/src/components/DateString/compactDateString.ts
index 8bff4b7..29c3c44 100644
--- a/src/components/DateString/compactDateString.ts
+++ b/src/components/DateString/compactDateString.ts
@@ -15,13 +15,14 @@ const resolve = (value: number, metricIndex = 0): string => {
const nextMetric = metrics[metricIndex + 1];
const newValue = value / metric.ratio;
- if (newValue < nextMetric.ratio * PRECISION) {
+ if (newValue < nextMetric?.ratio * PRECISION || !nextMetric) {
const rounded = Math.round(newValue);
const isPlural = rounded > 1;
const count = isPlural ? rounded : 'a';
const ending = isPlural ? 's' : '';
return `${count} ${metric.name}${ending} ago`;
}
+
return resolve(newValue, metricIndex + 1);
};