Improve Unread Count performances.
docuemnt.title setter is slow. This is about 10 times faster.
This commit is contained in:
parent
19d0617f4c
commit
3232671980
@ -3509,11 +3509,22 @@
|
|||||||
Unread.replies = Unread.replies.slice(i);
|
Unread.replies = Unread.replies.slice(i);
|
||||||
return Unread.update();
|
return Unread.update();
|
||||||
},
|
},
|
||||||
|
setTitle: function(count) {
|
||||||
|
if (this.scheduled) {
|
||||||
|
clearTimeout(this.scheduled);
|
||||||
|
delete Unread.scheduled;
|
||||||
|
this.setTitle(count);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return this.scheduled = setTimeout((function() {
|
||||||
|
return d.title = "(" + count + ") " + Unread.title;
|
||||||
|
}), 5);
|
||||||
|
},
|
||||||
update: function(forceUpdate) {
|
update: function(forceUpdate) {
|
||||||
var count;
|
var count;
|
||||||
if (!g.REPLY) return;
|
if (!g.REPLY) return;
|
||||||
count = this.replies.length;
|
count = this.replies.length;
|
||||||
if (conf['Unread Count']) d.title = "(" + count + ") " + this.title;
|
if (conf['Unread Count']) this.setTitle(count);
|
||||||
if (!(conf['Unread Favicon'] && (count < 2 || forceUpdate))) return;
|
if (!(conf['Unread Favicon'] && (count < 2 || forceUpdate))) return;
|
||||||
Favicon.el.href = g.dead ? count ? Favicon.unreadDead : Favicon.dead : count ? Favicon.unread : Favicon["default"];
|
Favicon.el.href = g.dead ? count ? Favicon.unreadDead : Favicon.dead : count ? Favicon.unread : Favicon["default"];
|
||||||
return $.add(d.head, Favicon.el);
|
return $.add(d.head, Favicon.el);
|
||||||
|
|||||||
@ -2877,13 +2877,23 @@ Unread =
|
|||||||
Unread.replies = Unread.replies[i..]
|
Unread.replies = Unread.replies[i..]
|
||||||
Unread.update()
|
Unread.update()
|
||||||
|
|
||||||
|
setTitle: (count) ->
|
||||||
|
if @scheduled
|
||||||
|
clearTimeout @scheduled
|
||||||
|
delete Unread.scheduled
|
||||||
|
@setTitle count
|
||||||
|
return
|
||||||
|
@scheduled = setTimeout (->
|
||||||
|
d.title = "(#{count}) #{Unread.title}"
|
||||||
|
), 5
|
||||||
|
|
||||||
update: (forceUpdate) ->
|
update: (forceUpdate) ->
|
||||||
return unless g.REPLY
|
return unless g.REPLY
|
||||||
|
|
||||||
count = @replies.length
|
count = @replies.length
|
||||||
|
|
||||||
if conf['Unread Count']
|
if conf['Unread Count']
|
||||||
d.title = "(#{count}) #{@title}"
|
@setTitle count
|
||||||
|
|
||||||
unless conf['Unread Favicon'] and (count < 2 or forceUpdate)
|
unless conf['Unread Favicon'] and (count < 2 or forceUpdate)
|
||||||
return
|
return
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user