}
// 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
return;
}
+ if (content === '') {
+ return this.clear();
+ }
+
try {
window.localStorage.setItem(this._key, JSON.stringify({
content: content,