mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-05-04 12:33:04 +02:00
Fix time rendering unit issue
This commit is contained in:
4
frontend/package-lock.json
generated
4
frontend/package-lock.json
generated
@@ -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",
|
||||
|
||||
@@ -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)}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user