Reset unreadCounts
Add a migration to reset bad unreadCounts from previously broken unreadCount tracking. This will execute exactly once per installation. // FREEBIE
This commit is contained in:
parent
31b29b67f2
commit
ed32801c3e
1 changed files with 19 additions and 0 deletions
|
@ -49,6 +49,25 @@
|
|||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
version: "3.0",
|
||||
migrate: function(transaction, next) {
|
||||
var conversations = transaction.objectStore("items");
|
||||
|
||||
var all = new Whisper.ConversationCollection();
|
||||
all.fetch().then(function() {
|
||||
var unreadCount = all.reduce(function(total, model) {
|
||||
var count = model.get('unreadCount');
|
||||
if (count === undefined) {
|
||||
count = 0;
|
||||
}
|
||||
return total + count;
|
||||
}, 0);
|
||||
storage.remove('unreadCount');
|
||||
storage.put('unreadCount', unreadCount);
|
||||
});
|
||||
}
|
||||
}
|
||||
];
|
||||
}());
|
||||
|
|
Loading…
Reference in a new issue