Skip to content

Commit 6787a25

Browse files
committed
fix(sync-button): prevent time-ago casing flicker
1 parent 1d7393b commit 6787a25

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

apps/desktop/src/components/SyncButton.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@
4949
}
5050
}}
5151
>
52-
<span class="capitalize">
52+
<span>
5353
{#if loading}
5454
Fetching...
5555
{:else if lastFetched}
56-
<TimeAgo date={lastFetched} addSuffix={true} />
56+
<TimeAgo date={lastFetched} addSuffix={true} capitalize={true} />
5757
{:else}
5858
Refetch
5959
{/if}

packages/ui/src/lib/components/TimeAgo.svelte

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,26 @@
66
date?: Date;
77
addSuffix?: boolean;
88
showTooltip?: boolean;
9+
capitalize?: boolean;
910
}
1011
11-
const { date, addSuffix, showTooltip = true }: Props = $props();
12+
const { date, addSuffix, showTooltip = true, capitalize = false }: Props = $props();
1213
const store = $derived(createTimeAgoStore(date, addSuffix));
1314
const absoluteTime = $derived(date ? getAbsoluteTimestamp(date) : '');
15+
16+
function formatText(value: string | undefined): string {
17+
if (!value) return '';
18+
if (!capitalize) return value;
19+
return `${value[0].toUpperCase()}${value.slice(1)}`;
20+
}
1421
</script>
1522

1623
{#if store}
1724
{#if showTooltip && date}
1825
<Tooltip text={absoluteTime}>
19-
<span>{$store}</span>
26+
<span>{formatText($store)}</span>
2027
</Tooltip>
2128
{:else}
22-
{$store}
29+
{formatText($store)}
2330
{/if}
2431
{/if}

0 commit comments

Comments
 (0)