1
1
mirror of https://github.com/go-gitea/gitea synced 2024-06-01 17:05:48 +00:00

ensure number

This commit is contained in:
silverwind 2024-04-29 22:49:32 +02:00
parent 5079641d1a
commit 24c650d3ef
No known key found for this signature in database
GPG Key ID: 2E62B41C93869443

View File

@ -19,7 +19,7 @@ export function initStopwatch() {
// global stop watch (in the head_navbar), it should always work in any case either the EventSource or the PeriodicPoller is used. // global stop watch (in the head_navbar), it should always work in any case either the EventSource or the PeriodicPoller is used.
const seconds = stopwatchEls[0]?.getAttribute('data-seconds'); const seconds = stopwatchEls[0]?.getAttribute('data-seconds');
if (seconds) { if (seconds) {
updateStopwatchTime(seconds); updateStopwatchTime(parseInt(seconds));
} }
for (const stopwatchEl of stopwatchEls) { for (const stopwatchEl of stopwatchEls) {
@ -144,6 +144,7 @@ function updateStopwatchData(data) {
} }
function updateStopwatchTime(seconds) { function updateStopwatchTime(seconds) {
if (!Number.isFinite(seconds)) return;
const datetime = (new Date(Date.now() - seconds * 1000)).toISOString(); const datetime = (new Date(Date.now() - seconds * 1000)).toISOString();
for (const parent of document.querySelectorAll('.header-stopwatch-dot')) { for (const parent of document.querySelectorAll('.header-stopwatch-dot')) {
const existing = parent.querySelector(':scope > relative-time'); const existing = parent.querySelector(':scope > relative-time');