Simpler Unread code concerning your posts.

This commit is contained in:
Nicolas Stepien 2013-02-23 18:55:09 +01:00
parent e3765121b0
commit e7164099c9
2 changed files with 8 additions and 13 deletions

View File

@ -4981,7 +4981,6 @@
Unread.lastReadPost = $.get("lastReadPosts." + this.board, {
threads: {}
}).threads[this] || 0;
Unread.yourPosts = [];
Unread.posts = [];
Unread.title = d.title;
posts = [];
@ -4994,15 +4993,17 @@
}
Unread.addPosts(posts);
$.on(d, 'ThreadUpdate', Unread.onUpdate);
$.on(d, 'QRPostSuccessful', Unread.post);
return $.on(d, 'scroll visibilitychange', Unread.read);
},
addPosts: function(newPosts) {
var ID, post, _i, _len;
var ID, post, yourPosts, _i, _len;
if (Conf['Quick Reply']) {
yourPosts = QR.yourPosts.threads[Unread.thread];
}
for (_i = 0, _len = newPosts.length; _i < _len; _i++) {
post = newPosts[_i];
ID = post.ID;
if (!(ID <= Unread.lastReadPost || post.isHidden || __indexOf.call(Unread.yourPosts, ID) >= 0)) {
if (!(ID <= Unread.lastReadPost || post.isHidden || yourPosts && __indexOf.call(yourPosts, ID) >= 0)) {
Unread.posts.push(post);
}
}
@ -5016,9 +5017,6 @@
return Unread.addPosts(e.detail.newPosts);
}
},
post: function(e) {
return Unread.yourPosts.push(e.detail.postID);
},
read: function(e) {
var bottom, height, i, post, _i, _len, _ref;
if (d.hidden || !Unread.posts.length) {

View File

@ -3310,7 +3310,6 @@ Unread =
node: ->
Unread.thread = @
Unread.lastReadPost = $.get("lastReadPosts.#{@board}", threads: {}).threads[@] or 0
Unread.yourPosts = []
Unread.posts = []
Unread.title = d.title
posts = []
@ -3318,13 +3317,14 @@ Unread =
posts.push post if post.isReply
Unread.addPosts posts
$.on d, 'ThreadUpdate', Unread.onUpdate
$.on d, 'QRPostSuccessful', Unread.post
$.on d, 'scroll visibilitychange', Unread.read
addPosts: (newPosts) ->
if Conf['Quick Reply']
yourPosts = QR.yourPosts.threads[Unread.thread]
for post in newPosts
{ID} = post
unless ID <= Unread.lastReadPost or post.isHidden or ID in Unread.yourPosts
unless ID <= Unread.lastReadPost or post.isHidden or yourPosts and ID in yourPosts
Unread.posts.push post
Unread.read()
Unread.update()
@ -3335,9 +3335,6 @@ Unread =
else
Unread.addPosts e.detail.newPosts
post: (e) ->
Unread.yourPosts.push e.detail.postID
read: (e) ->
return if d.hidden or !Unread.posts.length
height = doc.clientHeight