From 1f44a283b37af7f090737a5b6126e350ed217ab6 Mon Sep 17 00:00:00 2001 From: Marc-Andre Ferland Date: Mon, 12 Dec 2022 02:47:42 -0500 Subject: [PATCH] Update 'release-notes' to use loadScript --- ui/plugins/ui/release-notes.plugin.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ui/plugins/ui/release-notes.plugin.js b/ui/plugins/ui/release-notes.plugin.js index cfe2b338..5212c085 100644 --- a/ui/plugins/ui/release-notes.plugin.js +++ b/ui/plugins/ui/release-notes.plugin.js @@ -43,22 +43,22 @@ `) - const markedScript = document.createElement('script') - markedScript.src = '/media/js/marked.min.js' - - markedScript.onload = async function() { + loadScript('/media/js/marked.min.js').then(async function() { let appConfig = await fetch('/get/app_config') + if (!appConfig.ok) { + console.error('[release-notes] Failed to get app_config.') + return + } appConfig = await appConfig.json() - let updateBranch = appConfig.update_branch || 'main' + const updateBranch = appConfig.update_branch || 'main' let releaseNotes = await fetch(`https://raw.githubusercontent.com/cmdr2/stable-diffusion-ui/${updateBranch}/CHANGES.md`) - if (releaseNotes.status != 200) { + if (!releaseNotes.ok) { + console.error('[release-notes] Failed to get CHANGES.md.') return } releaseNotes = await releaseNotes.text() news.innerHTML = marked.parse(releaseNotes) - } - - document.querySelector('body').appendChild(markedScript) + }) })() \ No newline at end of file