1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-10 12:37:19 +00:00

pass seconds again, can not emit datetime from backend

This commit is contained in:
silverwind
2024-04-29 22:46:14 +02:00
parent cfee93d481
commit 5079641d1a
3 changed files with 12 additions and 27 deletions

View File

@ -17,9 +17,9 @@ 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.
const datetime = stopwatchEls[0]?.getAttribute('data-datetime');
if (datetime) {
updateStopwatchTime(datetime);
const seconds = stopwatchEls[0]?.getAttribute('data-seconds');
if (seconds) {
updateStopwatchTime(seconds);
}
for (const stopwatchEl of stopwatchEls) {
@ -137,17 +137,14 @@ function updateStopwatchData(data) {
document.querySelector('.stopwatch-cancel')?.setAttribute('action', `${issueUrl}/times/stopwatch/cancel`);
const stopwatchIssue = document.querySelector('.stopwatch-issue');
if (stopwatchIssue) stopwatchIssue.textContent = `${repo_owner_name}/${repo_name}#${issue_index}`;
updateStopwatchTime(secondsToDatetime(seconds));
updateStopwatchTime(seconds);
showElem(btnEl);
}
return Boolean(data.length);
}
function secondsToDatetime(seconds) {
return (new Date(Date.now() - seconds * 1000)).toISOString();
}
function updateStopwatchTime(datetime) {
function updateStopwatchTime(seconds) {
const datetime = (new Date(Date.now() - seconds * 1000)).toISOString();
for (const parent of document.querySelectorAll('.header-stopwatch-dot')) {
const existing = parent.querySelector(':scope > relative-time');
if (existing) {