Fix roster caching

This commit is contained in:
Lance Stout 2014-01-27 14:55:26 -08:00
parent f621166f13
commit e290b9a094
4 changed files with 20 additions and 6 deletions

View File

@ -114,11 +114,17 @@ module.exports = function (client, app) {
client.getRoster(function (err, resp) { client.getRoster(function (err, resp) {
resp = resp.toJSON(); resp = resp.toJSON();
me.rosterVer = resp.roster.ver; var resultVer = resp.roster.ver;
if (me.rosterVer && resultVer && me.rosterVer !== resultVer) {
app.storage.roster.clear(function () {
me.contacts.reset();
me.rosterVer = resp.roster.ver;
_.each(resp.roster.items, function (item) { _.each(resp.roster.items, function (item) {
me.setContact(item, true); me.setContact(item, true);
}); });
});
}
var caps = client.updateCaps(); var caps = client.updateCaps();
app.storage.disco.add(caps.ver, caps.discoInfo, function () { app.storage.disco.add(caps.ver, caps.discoInfo, function () {

View File

@ -46,7 +46,7 @@ module.exports = HumanModel.define({
pageTitle: 'string', pageTitle: 'string',
hasActiveCall: ['boolean', false, false], hasActiveCall: ['boolean', false, false],
cacheStatus: 'string', cacheStatus: 'string',
deviceID: 'string' deviceID: ['string', false, '']
}, },
derived: { derived: {
title: { title: {

View File

@ -77,6 +77,14 @@ RosterStorage.prototype = {
cb(false, request.result); cb(false, request.result);
}; };
request.onerror = cb; request.onerror = cb;
},
clear: function (cb) {
cb = cb || function () {};
var request = this.transaction('readwrite').clear();
request.onsuccess = function () {
cb(false, request.result);
};
request.onerror = cb;
} }
}; };

View File

@ -1,6 +1,6 @@
{ {
"name": "otalk.im", "name": "otalk.im",
"version": "0.0.19", "version": "0.0.22",
"description": "Otalk: WebRTC Enabled XMPP Client, in the Browser", "description": "Otalk: WebRTC Enabled XMPP Client, in the Browser",
"repository": { "repository": {
"type": "git", "type": "git",