mirror of
https://github.com/cpvalente/ontime.git
synced 2026-09-06 06:49:10 +00:00
fix(cuesheet): prevent empty seconds field
This commit is contained in:
committed by
Carlos Valente
parent
977b01a072
commit
bc6a321172
@@ -58,4 +58,16 @@ describe('formatDuration()', () => {
|
|||||||
expect(formatDuration(2 * MILLIS_PER_HOUR + 6 * MILLIS_PER_MINUTE + 45 * MILLIS_PER_SECOND, false)).toBe('2h6m45s');
|
expect(formatDuration(2 * MILLIS_PER_HOUR + 6 * MILLIS_PER_MINUTE + 45 * MILLIS_PER_SECOND, false)).toBe('2h6m45s');
|
||||||
expect(formatDuration(599702, false)).toBe('9m59s');
|
expect(formatDuration(599702, false)).toBe('9m59s');
|
||||||
});
|
});
|
||||||
|
it('formats durations differently with and without seconds', () => {
|
||||||
|
expect(formatDuration(0, false)).toBe('0m');
|
||||||
|
expect(formatDuration(0, true)).toBe('0m');
|
||||||
|
expect(formatDuration(30 * MILLIS_PER_SECOND, false)).toBe('30s');
|
||||||
|
expect(formatDuration(30 * MILLIS_PER_SECOND, true)).toBe('');
|
||||||
|
expect(formatDuration(2 * MILLIS_PER_HOUR + 30 * MILLIS_PER_SECOND, false)).toBe('2h30s');
|
||||||
|
expect(formatDuration(2 * MILLIS_PER_HOUR + 30 * MILLIS_PER_SECOND, true)).toBe('2h');
|
||||||
|
expect(formatDuration(2 * MILLIS_PER_HOUR + 10 * MILLIS_PER_MINUTE + 30 * MILLIS_PER_SECOND, false)).toBe(
|
||||||
|
'2h10m30s',
|
||||||
|
);
|
||||||
|
expect(formatDuration(2 * MILLIS_PER_HOUR + 10 * MILLIS_PER_MINUTE + 30 * MILLIS_PER_SECOND, true)).toBe('2h10m');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
+3
-3
@@ -105,10 +105,10 @@ function MakeDuration({ getValue, row, table, column }: CuesheetCellContext) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { hideTableSeconds } = table.options.meta.options;
|
|
||||||
const event = row.original;
|
const event = row.original;
|
||||||
if (!isOntimeEvent(event)) {
|
if (!isOntimeEvent(event)) {
|
||||||
return <MutedText numeric>{formatDuration(getValue() as number, hideTableSeconds)}</MutedText>;
|
const duration = getValue() as number;
|
||||||
|
return <MutedText numeric>{formatDuration(duration, false)}</MutedText>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { handleUpdateTimer } = table.options.meta;
|
const { handleUpdateTimer } = table.options.meta;
|
||||||
@@ -117,7 +117,7 @@ function MakeDuration({ getValue, row, table, column }: CuesheetCellContext) {
|
|||||||
|
|
||||||
const duration = getValue() as number;
|
const duration = getValue() as number;
|
||||||
const isDurationLocked = event.timeStrategy === TimeStrategy.LockDuration;
|
const isDurationLocked = event.timeStrategy === TimeStrategy.LockDuration;
|
||||||
const formattedDuration = formatDuration(duration, hideTableSeconds);
|
const formattedDuration = formatDuration(duration, false);
|
||||||
|
|
||||||
const canWrite = column.columnDef.meta?.canWrite;
|
const canWrite = column.columnDef.meta?.canWrite;
|
||||||
if (!canWrite) {
|
if (!canWrite) {
|
||||||
|
|||||||
Reference in New Issue
Block a user