Fix time rendering unit issue

This commit is contained in:
Jack Kingsman
2026-03-26 21:32:23 -07:00
parent 6f68dfc609
commit 5f0d042252
3 changed files with 16 additions and 5 deletions

View File

@@ -1,12 +1,12 @@
{
"name": "remoteterm-meshcore-frontend",
"version": "3.6.0",
"version": "3.6.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "remoteterm-meshcore-frontend",
"version": "3.6.0",
"version": "3.6.1",
"dependencies": {
"@codemirror/lang-python": "^6.2.1",
"@codemirror/theme-one-dark": "^6.1.3",

View File

@@ -112,7 +112,10 @@ export function RadioSettingsPane({
<NotFetched />
) : (
<div>
<KvRow label="Local Advert" value={formatAdvertInterval(advertData.advert_interval)} />
<KvRow
label="Local Advert"
value={formatAdvertInterval(advertData.advert_interval, 'minutes')}
/>
<KvRow
label="Flood Advert"
value={formatAdvertInterval(advertData.flood_advert_interval)}

View File

@@ -76,11 +76,19 @@ export function formatClockDrift(
return { text: parts.join(''), isLarge: false };
}
export function formatAdvertInterval(val: string | null): string {
export function formatAdvertInterval(
val: string | null,
unit: 'minutes' | 'hours' = 'hours'
): string {
if (val == null) return '—';
const trimmed = val.trim();
if (trimmed === '0') return '<disabled>';
return `${trimmed}h`;
if (unit === 'hours') return `${trimmed}h`;
const mins = parseInt(trimmed, 10);
if (isNaN(mins)) return trimmed;
if (mins >= 60 && mins % 60 === 0) return `${mins / 60}h`;
if (mins >= 60) return `${Math.floor(mins / 60)}h${mins % 60}m`;
return `${mins}m`;
}
function formatFetchedRelative(fetchedAt: number): string {