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: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() {
|
function fetch() {
|
||||||
window.inbox.fetch({
|
window.inbox.fetch({
|
||||||
|
|
|
@ -23,7 +23,5 @@
|
||||||
window.location = '/options.html';
|
window.location = '/options.html';
|
||||||
} else {
|
} else {
|
||||||
new bg.Whisper.InboxView().$el.prependTo(bg.$('body',document));
|
new bg.Whisper.InboxView().$el.prependTo(bg.$('body',document));
|
||||||
bg.textsecure.storage.putUnencrypted("unreadCount", 0);
|
|
||||||
extension.navigator.setBadgeText("");
|
|
||||||
}
|
}
|
||||||
}());
|
}());
|
||||||
|
|
Loading…
Reference in a new issue