bugfix: Execution dialog duration no longer has issues displaying actions that were never started. (#394)

This commit is contained in:
James Read 2024-08-30 21:28:27 +01:00 committed by GitHub
parent dc9653307b
commit 2671983c43
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 11 deletions

View File

@ -115,7 +115,7 @@ export class ExecutionDialog {
executionTick () { executionTick () {
this.executionSeconds++ this.executionSeconds++
this.updateDuration(this.executionSeconds + ' seconds', '') this.updateDuration(null)
} }
hideEverythingApartFromOutput () { hideEverythingApartFromOutput () {
@ -151,20 +151,24 @@ export class ExecutionDialog {
}) })
} }
updateDuration (started, finished) { updateDuration (logEntry) {
if (finished === '') { if (logEntry == null) {
this.domDuration.innerHTML = started this.domDuration.innerHTML = this.executionSeconds + ' seconds'
} else if (!logEntry.executionStarted) {
this.domDuration.innerHTML = logEntry.datetimeStarted + ' (request time). Not executed.'
} else if (logEntry.executionStarted && !logEntry.executionFinished) {
this.domDuration.innerHTML = logEntry.datetimeStarted
} else { } else {
let delta = '' let delta = ''
try { try {
delta = (new Date(finished) - new Date(started)) / 1000 delta = (new Date(logEntry.datetimeStarted) - new Date(logEntry.datetimeStarted)) / 1000
delta = new Intl.RelativeTimeFormat().format(delta, 'seconds').replace('in ', '').replace('ago', '') delta = new Intl.RelativeTimeFormat().format(delta, 'seconds').replace('in ', '').replace('ago', '')
} catch (e) { } catch (e) {
console.warn('Failed to calculate delta', e) console.warn('Failed to calculate delta', e)
} }
this.domDuration.innerHTML = started + ' → ' + finished this.domDuration.innerHTML = logEntry.datetimeStarted + ' → ' + logEntry.datetimeFinished
if (delta !== '') { if (delta !== '') {
this.domDuration.innerHTML += ' (' + delta + ')' this.domDuration.innerHTML += ' (' + delta + ')'
@ -192,11 +196,7 @@ export class ExecutionDialog {
this.domIcon.innerHTML = res.logEntry.actionIcon this.domIcon.innerHTML = res.logEntry.actionIcon
this.domTitle.innerText = res.logEntry.actionTitle this.domTitle.innerText = res.logEntry.actionTitle
if (res.logEntry.executionFinished) { this.updateDuration(res.logEntry)
this.updateDuration(res.logEntry.datetimeStarted, res.logEntry.datetimeFinished)
} else {
this.updateDuration(res.logEntry.datetimeStarted, 'Still running...')
}
window.terminal.reset() window.terminal.reset()
window.terminal.write(res.logEntry.output, () => { window.terminal.write(res.logEntry.output, () => {