You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When autosave delay is low (few seconds - but it depends on server speed), autosave can kick in after submit event listener was processed and value was removed from local storage. So, the item will be inserted to local storage again. Clearing the timeout in listener fixes this issue for me:
SimpleMDE.prototype.autosave=function(){//...if(this.options.autosave.binded!==true){if(simplemde.element.form!=null&&simplemde.element.form!=undefined){simplemde.element.form.addEventListener("submit",function(){clearTimeout(simplemde.autosaveTimeoutId);simplemde.autosaveTimeoutId=undefined;localStorage.removeItem("smde_"+simplemde.options.autosave.uniqueId);//restart autosaving in case the submit will be cancelled down the linesetTimeout(function(){simplemde.autosave();},30000);});}this.options.autosave.binded=true;}//...};
Should I create a pull request?
The text was updated successfully, but these errors were encountered:
By the way, this submit event listener is added for every call to autosave, so with short delay and long document it won't be nice... There should be some this.options.autosave.binded options to guard against it like with this.options.autosave.loaded. I've updated the original post.
When autosave delay is low (few seconds - but it depends on server speed), autosave can kick in after
submit
event listener was processed and value was removed from local storage. So, the item will be inserted to local storage again. Clearing the timeout in listener fixes this issue for me:Should I create a pull request?
The text was updated successfully, but these errors were encountered: