Skip to content

Commit

Permalink
editor: Try to fix editor draft saving bug, second trial
Browse files Browse the repository at this point in the history
  • Loading branch information
doortts committed Jul 6, 2018
1 parent 2122b0c commit 9ae92ee
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions public/javascripts/common/yobi.CommentForm.js
Expand Up @@ -44,6 +44,8 @@ $(function(){
* @returns {boolean}
*/
function onSubmitCommentForm(event){
removeCurrentPageTemprarySavedContent();

event.preventDefault();
var that = this;

Expand All @@ -59,8 +61,6 @@ $(function(){

elements.commentForm.data("onsubmit", true);

removeCurrentPageTemprarySavedContent();

NProgress.start();

setTimeout(function () {
Expand Down
9 changes: 7 additions & 2 deletions public/javascripts/service/yona.temporarySaveHandler.js
Expand Up @@ -36,8 +36,13 @@ function temporarySaveHandler($textarea, contentInitialized) {
});

if (contentInitialized === undefined || contentInitialized === true) { // default: true
if (localStorage.getItem(location.pathname)) {
$textarea.val(localStorage.getItem(location.pathname));
var lastTextAreaText = $("textarea.content[data-editor-mode='update-comment-body']").last().val();
var storedDraftText = localStorage.getItem(location.pathname);
if (storedDraftText && lastTextAreaText
&& storedDraftText.trim() === lastTextAreaText.trim()) {
removeCurrentPageTemprarySavedContent();
} else if (storedDraftText) {
$textarea.val(storedDraftText);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions public/javascripts/yona-lib.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9ae92ee

Please sign in to comment.