Make badge count accurate
Previously it would reset when refreshing the inbox. Now it tracks changes to conversation unreadCounts. Fixes #200
This commit is contained in:
parent
c4ae7a21d8
commit
6509561795
2 changed files with 13 additions and 2 deletions
|
@ -30,6 +30,19 @@
|
|||
});
|
||||
|
||||
inbox.on('change:active_at', inbox.sort);
|
||||
inbox.on('change:unreadCount', function(model, count) {
|
||||
var prev = model.previous('unreadCount');
|
||||
if (count < prev) { // decreased
|
||||
var newUnreadCount = textsecure.storage.getUnencrypted("unreadCount") - (prev - count);
|
||||
if (newUnreadCount <= 0) {
|
||||
newUnreadCount = 0;
|
||||
extension.navigator.setBadgeText("");
|
||||
} else {
|
||||
extension.navigator.setBadgeText(newUnreadCount);
|
||||
}
|
||||
textsecure.storage.putUnencrypted("unreadCount", newUnreadCount);
|
||||
}
|
||||
});
|
||||
|
||||
function fetch() {
|
||||
window.inbox.fetch({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue