Remove remaining traces of localStorage

Add window.storage to the background page, which loads all data from the
'items' store in indexeddb, caching them in memory for synchronous
access, then override textsecure storage to use that in memory store.
This commit is contained in:
lilia 2015-05-12 15:14:20 -07:00
parent a3c5b0959f
commit 3f37cd21a9
7 changed files with 177 additions and 140 deletions

View file

@ -83,42 +83,6 @@
var IdentityKey = Model.extend({ storeName: 'identityKeys' });
var Group = Model.extend({ storeName: 'groups' });
var Item = Model.extend({ storeName: 'items' });
var ItemCollection = Backbone.Collection.extend({
model: Item,
storeName: 'items',
database: Whisper.Database,
});
var items = new ItemCollection();
window.textsecure = window.textsecure || {};
window.textsecure.storage = window.textsecure.storage || {};
window.textsecure.storage.impl = {
/*****************************
*** Base Storage Routines ***
*****************************/
put: function(key, value) {
if (value === undefined)
throw new Error("Tried to store undefined");
var item = items.add({id: key, value: value});
item.save();
},
get: function(key, defaultValue) {
var item = items.get("" + key);
if (!item)
return defaultValue;
return item.get('value');
},
remove: function(key) {
var item = items.get("" + key);
if (item) {
items.remove(item);
item.destroy();
}
}
};
items.fetch();
function AxolotlStore() {}