Remove storage if empty data
This commit is contained in:
parent
223bacc6e6
commit
bd2d6f52c2
1 changed files with 16 additions and 1 deletions
17
lib/popup.js
17
lib/popup.js
|
@ -96,6 +96,21 @@
|
||||||
|
|
||||||
var str = JSON.stringify(this.data || {});
|
var str = JSON.stringify(this.data || {});
|
||||||
localStorage.setItem(this.key, str);
|
localStorage.setItem(this.key, str);
|
||||||
|
},
|
||||||
|
remove: function(key) {
|
||||||
|
if( key ) {
|
||||||
|
delete this.data[key];
|
||||||
|
if( $.isEmptyObject(this.data) ) {
|
||||||
|
this.remove();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var str = JSON.stringify(this.data || {});
|
||||||
|
localStorage.setItem(this.key, str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
localStorage.removeItem(this.key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
apiclb: {
|
apiclb: {
|
||||||
|
@ -218,7 +233,7 @@
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
removeDraft: function() {
|
removeDraft: function() {
|
||||||
popup.storage.set('draft', null);
|
popup.storage.remove('draft', null);
|
||||||
popup.applyData();
|
popup.applyData();
|
||||||
popup.el.draftRemoveLink.addClass('is-hidden');
|
popup.el.draftRemoveLink.addClass('is-hidden');
|
||||||
},
|
},
|
||||||
|
|
Reference in a new issue