History

Pull uncommitted work: relative time formatting tweaks (worktree 2d307dad)

Theo Browne committed 4 months ago

Commit fab05c31 parent 6f5dd373 files · +6 −5Browse files

Showing the changes to apps (3 of 3 files). Show all

Unified · Split

3 files
  1. apps/mobile/src/features/archive/ArchivedThreadsScreen.tsx +1 −1
  2. apps/mobile/src/features/home/HomeScreen.tsx +1 −1
  3. apps/mobile/src/lib/time.ts +4 −3
apps/mobile/src/features/archive/ArchivedThreadsScreen.tsx+1−1
@@ -272,7 +272,7 @@ function ArchivedThreadRow(props: { · 271 unmodified lines
272272 </Text>
273273 <Text
274274 className="text-xs text-foreground-tertiary"
275− style={{ fontVariant: ["tabular-nums"] }}
275+ style={{ fontVariant: ["tabular-nums"], minWidth: 30, textAlign: "right" }}
276276 >
277277 {timestamp}
278278 </Text>
apps/mobile/src/features/home/HomeScreen.tsx+1−1
@@ -370,7 +370,7 @@ function ThreadRow(props: { · 369 unmodified lines
370370 </View>
371371 <Text
372372 className="text-xs text-foreground-tertiary"
373− style={{ fontVariant: ["tabular-nums"] }}
373+ style={{ fontVariant: ["tabular-nums"], minWidth: 30, textAlign: "right" }}
374374 >
375375 {timestamp}
376376 </Text>
apps/mobile/src/lib/time.ts+4−3
@@ -1,12 +1,13 @@
11 export function relativeTime(input: string): string {
22 const timestamp = Date.parse(input);
33 if (Number.isNaN(timestamp)) {
4− return "now";
4+ return "<1m";
55 }
66
7+ // Anything under a minute renders as "<1m" rather than a live seconds count.
8+ // The seconds ticker changed width every second and reflowed the surrounding row.
79 const deltaSeconds = Math.max(0, Math.floor((Date.now() - timestamp) / 1000));
8− if (deltaSeconds < 10) return "now";
9− if (deltaSeconds < 60) return `${deltaSeconds}s`;
10+ if (deltaSeconds < 60) return "<1m";
1011
1112 const deltaMinutes = Math.floor(deltaSeconds / 60);
1213 if (deltaMinutes < 60) return `${deltaMinutes}m`;