Skip to content
This repository was archived by the owner on Oct 11, 2020. It is now read-only.

Add prefix for local storage #66

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions frontend/scripts/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,12 @@ angular.module('imgbi.controllers', [])
};
getFullStorage().then(function(storage) {
angular.forEach(storage, function(content, id) {
if (id != 'lang' && id != 'expire') {
if (id.substring(0, 6) == 'imgbi_' && id != 'imgbi_lang' && id != 'imgbi_expire') {
if (typeof content !== 'object') {
content = JSON.parse(content);
}
$rootScope.thumbs.push({
id: id,
id: id.substring(6, id.length),
pass: content.pass,
rmpass: content.rmpass
});
Expand Down
8 changes: 4 additions & 4 deletions frontend/scripts/storage.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
angular.module('imgbi.storage', [])
.factory('rmStorage', [function() {
return function(id) {
localStorage.removeItem(id);
localStorage.removeItem('imgbi_' + id);
};
}])
.factory('setStorage', [function() {
return function(id, value) {
if (typeof value === 'object') {
value = JSON.stringify(value);
}
localStorage.setItem(id, value);
localStorage.setItem('imgbi_' + id, value);
};
}])
.factory('getStorage', ['$q', function($q) {
return function(id) {
var deferred = $q.defer();
if (id != 'lang' && id != 'expire') {
deferred.resolve(JSON.parse(localStorage.getItem(id)));
deferred.resolve(JSON.parse(localStorage.getItem('imgbi_' + id)));
} else {
deferred.resolve(localStorage.getItem(id));
deferred.resolve(localStorage.getItem('imgbi_' + id));
}
return deferred.promise;
};
Expand Down