diff --git a/static/koboldai.js b/static/koboldai.js index 95fc9ea4..1a8e5882 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -2371,12 +2371,18 @@ function process_log_message(full_data) { //--------------------------------------------UI to Server Functions---------------------------------- async function download_story_to_json() { //document.getElementById('download_iframe').src = 'json'; - try { - let r = await fetch("json"); - let j = await r.json(); - downloadString(JSON.stringify(j), j['story_name']+".json") - } - catch(err) { + downloaded = false; + if (socket.connected) { + try { + let r = await fetch("json"); + let j = await r.json(); + downloadString(JSON.stringify(j), j['story_name']+".json") + downloaded = true; + } + catch(err) { + downloaded = false; + } + } if (downloaded == false) { //first we're going to find all the var_sync_story_ classes used in the document. let allClasses = []; const allElements = document.querySelectorAll('*');