From: Alexander Ebert Date: Thu, 22 Sep 2016 10:41:15 +0000 (+0200) Subject: Fixed autosave recognizing empty values X-Git-Tag: 3.0.0_Beta_1~33 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=fc0211a3a17e99e7544150fbb071137e30609f2e;p=GitHub%2FWoltLab%2FWCF.git Fixed autosave recognizing empty values --- diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Autosave.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Autosave.js index 92194d42a5..a2ded726b5 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Autosave.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/Autosave.js @@ -72,18 +72,15 @@ define(['Language', 'Dom/Traverse'], function(Language, DomTraverse) { } // check if storage is outdated - if (value !== null && typeof value === 'object') { + if (value !== null && typeof value === 'object' && value.content) { var lastEditTime = ~~elData(this._element, 'autosave-last-edit-time'); - if (lastEditTime * 1000 > value.timestamp) { + if (lastEditTime * 1000 <= value.timestamp) { //noinspection JSUnresolvedVariable - return this._element.value; + this._originalMessage = this._element.value; + this._restored = true; + + return value.content; } - - //noinspection JSUnresolvedVariable - this._originalMessage = this._element.value; - this._restored = true; - - return value.content; } //noinspection JSUnresolvedVariable @@ -225,6 +222,10 @@ define(['Language', 'Dom/Traverse'], function(Language, DomTraverse) { return; } + if (content === '') { + return this.clear(); + } + try { window.localStorage.setItem(this._key, JSON.stringify({ content: content,