1
0
Fork 0
forked from forgejo/forgejo

Fix some incorrect async functions, improve frontend document. (#17597)

This commit is contained in:
wxiaoguang 2021-11-12 20:37:45 +08:00 committed by GitHub
parent 0db7a32b92
commit 7f802631c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 106 additions and 43 deletions

View file

@ -82,8 +82,8 @@ export function initStopwatch() {
}
const fn = (timeout) => {
setTimeout(async () => {
await updateStopwatchWithCallback(fn, timeout);
setTimeout(() => {
const _promise = updateStopwatchWithCallback(fn, timeout);
}, timeout);
};
@ -122,7 +122,7 @@ async function updateStopwatch() {
return updateStopwatchData(data);
}
async function updateStopwatchData(data) {
function updateStopwatchData(data) {
const watch = data[0];
const btnEl = $('.active-stopwatch-trigger');
if (!watch) {
@ -135,14 +135,14 @@ async function updateStopwatchData(data) {
$('.stopwatch-cancel').attr('action', `${issueUrl}/times/stopwatch/cancel`);
$('.stopwatch-issue').text(`${repo_owner_name}/${repo_name}#${issue_index}`);
$('.stopwatch-time').text(prettyMilliseconds(seconds * 1000));
await updateStopwatchTime(seconds);
updateStopwatchTime(seconds);
btnEl.removeClass('hidden');
}
return !!data.length;
}
async function updateStopwatchTime(seconds) {
function updateStopwatchTime(seconds) {
const secs = parseInt(seconds);
if (!Number.isFinite(secs)) return;