diff --git a/CHANGELOG.md b/CHANGELOG.md index 7165c02a3..7d516a1bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ +<<<<<<< HEAD seaweedchan: - Fix emoji and favicon previews not updating on change. +======= +- Fix bug where a thread would freeze on load. + +### 3.2.1 - *2013-04-26* +>>>>>>> mayhem/v3 ### 1.1.1 - 2013-04-26 zixaphir: @@ -80,4 +86,4 @@ zixaphir: - Fix unread post count for filtered posts - Fix issues when switching from ihavenoface's fork - Fix backlinks not receiving filtered class -- Fix QR position not saving on refresh \ No newline at end of file +- Fix QR position not saving on refresh diff --git a/builds/4chan-X.js b/builds/4chan-X.js index 9bdc69cdf..2c94676e7 100644 --- a/builds/4chan-X.js +++ b/builds/4chan-X.js @@ -188,7 +188,7 @@ 'Remember Subject': [false, 'Remember the subject field, instead of resetting after posting.'], 'Remember Spoiler': [false, 'Remember the spoiler state, instead of resetting after posting.'], 'Hide Original Post Form': [true, 'Hide the normal post form.'], - 'Cooldown': [true, 'Prevent "flood detected" errors.'], + 'Cooldown': [true, 'Indicate the remaining time before posting again.'], 'Cooldown Prediction': [true, 'Decrease the cooldown time by taking into account upload speed. Disable it if it\'s inaccurate for you.'] }, 'Quote Links': { @@ -4303,7 +4303,7 @@ psa = $.id('globalMessage'); psa.hidden = PSAHiding.btn.hidden = (_ref = PSAHiding.trim(psa), __indexOf.call(hiddenPSAs, _ref) >= 0) ? true : false; - if (hr = $.x('following-sibling::hr', psa)) { + if ((hr = psa.nextElementSibling) && hr.nodeName === 'HR') { return hr.hidden = psa.hidden; } }, @@ -6756,24 +6756,14 @@ }); }, node: function() { - var ID, post, posts, _ref; - Unread.thread = this; Unread.title = d.title; - posts = []; - _ref = this.posts; - for (ID in _ref) { - post = _ref[ID]; - if (post.isReply) { - posts.push(post); - } - } Unread.lastReadPost = Unread.db.get({ boardID: this.board.ID, threadID: this.ID, defaultValue: 0 }); - Unread.addPosts(posts); + $.on(d, '4chanXInitFinished', Unread.ready); $.on(d, 'ThreadUpdate', Unread.onUpdate); $.on(d, 'scroll visibilitychange', Unread.read); if (Conf['Unread Line']) { @@ -6783,15 +6773,35 @@ return $.on(window, 'load', Unread.scroll); } }, + ready: function() { + var ID, post, posts, _ref; + + $.off(d, '4chanXInitFinished', Unread.ready); + posts = []; + _ref = Unread.thread.posts; + for (ID in _ref) { + post = _ref[ID]; + if (post.isReply) { + posts.push(post); + } + } + return Unread.addPosts(posts); + }, scroll: function() { - var hash, posts, root; + var hash, post, posts, prevID, root; if ((hash = location.hash.match(/\d+/)) && hash[0] in Unread.thread.posts) { return; } if (Unread.posts.length) { + prevID = 0; while (root = $.x('preceding-sibling::div[contains(@class,"postContainer")][1]', Unread.posts[0].nodes.root)) { - if (!(Get.postFromRoot(root)).isHidden) { + post = Get.postFromRoot(root); + if (prevID === post.ID) { + break; + } + prevID = post.ID; + if (!post.isHidden) { break; } } diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 98497630b..cf91966ee 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -189,7 +189,7 @@ 'Remember QR Size': [false, 'Remember the size of the Quick reply.'], 'Remember Spoiler': [false, 'Remember the spoiler state, instead of resetting after posting.'], 'Hide Original Post Form': [true, 'Hide the normal post form.'], - 'Cooldown': [true, 'Prevent "flood detected" errors.'], + 'Cooldown': [true, 'Indicate the remaining time before posting again.'], 'Cooldown Prediction': [true, 'Decrease the cooldown time by taking into account upload speed. Disable it if it\'s inaccurate for you.'] }, 'Quote Links': { @@ -4299,7 +4299,7 @@ psa = $.id('globalMessage'); psa.hidden = PSAHiding.btn.hidden = (_ref = PSAHiding.trim(psa), __indexOf.call(hiddenPSAs, _ref) >= 0) ? true : false; - if (hr = $.x('following-sibling::hr', psa)) { + if ((hr = psa.nextElementSibling) && hr.nodeName === 'HR') { return hr.hidden = psa.hidden; } }, @@ -6752,24 +6752,14 @@ }); }, node: function() { - var ID, post, posts, _ref; - Unread.thread = this; Unread.title = d.title; - posts = []; - _ref = this.posts; - for (ID in _ref) { - post = _ref[ID]; - if (post.isReply) { - posts.push(post); - } - } Unread.lastReadPost = Unread.db.get({ boardID: this.board.ID, threadID: this.ID, defaultValue: 0 }); - Unread.addPosts(posts); + $.on(d, '4chanXInitFinished', Unread.ready); $.on(d, 'ThreadUpdate', Unread.onUpdate); $.on(d, 'scroll visibilitychange', Unread.read); if (Conf['Unread Line']) { @@ -6779,15 +6769,35 @@ return $.on(window, 'load', Unread.scroll); } }, + ready: function() { + var ID, post, posts, _ref; + + $.off(d, '4chanXInitFinished', Unread.ready); + posts = []; + _ref = Unread.thread.posts; + for (ID in _ref) { + post = _ref[ID]; + if (post.isReply) { + posts.push(post); + } + } + return Unread.addPosts(posts); + }, scroll: function() { - var hash, posts, root; + var hash, post, posts, prevID, root; if ((hash = location.hash.match(/\d+/)) && hash[0] in Unread.thread.posts) { return; } if (Unread.posts.length) { + prevID = 0; while (root = $.x('preceding-sibling::div[contains(@class,"postContainer")][1]', Unread.posts[0].nodes.root)) { - if (!(Get.postFromRoot(root)).isHidden) { + post = Get.postFromRoot(root); + if (prevID === post.ID) { + break; + } + prevID = post.ID; + if (!post.isHidden) { break; } } diff --git a/builds/crx/script.js b/builds/crx/script.js index 52c4eb803..548aec8cc 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -81,7 +81,7 @@ 'Remember Subject': [false, 'Remember the subject field, instead of resetting after posting.'], 'Remember Spoiler': [false, 'Remember the spoiler state, instead of resetting after posting.'], 'Hide Original Post Form': [true, 'Hide the normal post form.'], - 'Cooldown': [true, 'Prevent "flood detected" errors.'], + 'Cooldown': [true, 'Indicate the remaining time before posting again.'], 'Cooldown Prediction': [true, 'Decrease the cooldown time by taking into account upload speed. Disable it if it\'s inaccurate for you.'] }, 'Quote Links': { @@ -4212,7 +4212,7 @@ psa = $.id('globalMessage'); psa.hidden = PSAHiding.btn.hidden = (_ref = PSAHiding.trim(psa), __indexOf.call(hiddenPSAs, _ref) >= 0) ? true : false; - if (hr = $.x('following-sibling::hr', psa)) { + if ((hr = psa.nextElementSibling) && hr.nodeName === 'HR') { return hr.hidden = psa.hidden; } }, @@ -6665,24 +6665,14 @@ }); }, node: function() { - var ID, post, posts, _ref; - Unread.thread = this; Unread.title = d.title; - posts = []; - _ref = this.posts; - for (ID in _ref) { - post = _ref[ID]; - if (post.isReply) { - posts.push(post); - } - } Unread.lastReadPost = Unread.db.get({ boardID: this.board.ID, threadID: this.ID, defaultValue: 0 }); - Unread.addPosts(posts); + $.on(d, '4chanXInitFinished', Unread.ready); $.on(d, 'ThreadUpdate', Unread.onUpdate); $.on(d, 'scroll visibilitychange', Unread.read); if (Conf['Unread Line']) { @@ -6692,15 +6682,35 @@ return $.on(window, 'load', Unread.scroll); } }, + ready: function() { + var ID, post, posts, _ref; + + $.off(d, '4chanXInitFinished', Unread.ready); + posts = []; + _ref = Unread.thread.posts; + for (ID in _ref) { + post = _ref[ID]; + if (post.isReply) { + posts.push(post); + } + } + return Unread.addPosts(posts); + }, scroll: function() { - var hash, posts, root; + var hash, post, posts, prevID, root; if ((hash = location.hash.match(/\d+/)) && hash[0] in Unread.thread.posts) { return; } if (Unread.posts.length) { + prevID = 0; while (root = $.x('preceding-sibling::div[contains(@class,"postContainer")][1]', Unread.posts[0].nodes.root)) { - if (!(Get.postFromRoot(root)).isHidden) { + post = Get.postFromRoot(root); + if (prevID === post.ID) { + break; + } + prevID = post.ID; + if (!post.isHidden) { break; } } diff --git a/src/config.coffee b/src/config.coffee index e61cedb8a..759a1701d 100644 --- a/src/config.coffee +++ b/src/config.coffee @@ -267,7 +267,7 @@ Config = ] 'Cooldown': [ true - 'Prevent "flood detected" errors.' + 'Indicate the remaining time before posting again.' ] 'Cooldown Prediction': [ true diff --git a/src/features/misc/announcementhiding.coffee b/src/features/misc/announcementhiding.coffee index be60550b5..8462bdcf9 100644 --- a/src/features/misc/announcementhiding.coffee +++ b/src/features/misc/announcementhiding.coffee @@ -61,7 +61,7 @@ PSAHiding = true else false - if hr = $.x 'following-sibling::hr', psa - hr.hidden = psa.hidden + if (hr = psa.nextElementSibling) and hr.nodeName is 'HR' + hr.hidden = psa.hidden trim: (psa) -> - psa.textContent.replace(/\W+/g, '').toLowerCase() \ No newline at end of file + psa.textContent.replace(/\W+/g, '').toLowerCase() diff --git a/src/features/monitoring/unread.coffee b/src/features/monitoring/unread.coffee index 738742ab8..03d01c48f 100644 --- a/src/features/monitoring/unread.coffee +++ b/src/features/monitoring/unread.coffee @@ -15,26 +15,34 @@ Unread = node: -> Unread.thread = @ Unread.title = d.title - posts = [] - for ID, post of @posts - posts.push post if post.isReply Unread.lastReadPost = Unread.db.get boardID: @board.ID threadID: @ID defaultValue: 0 - Unread.addPosts posts + $.on d, '4chanXInitFinished', Unread.ready $.on d, 'ThreadUpdate', Unread.onUpdate $.on d, 'scroll visibilitychange', Unread.read $.on d, 'visibilitychange', Unread.setLine if Conf['Unread Line'] $.on window, 'load', Unread.scroll if Conf['Scroll to Last Read Post'] + ready: -> + $.off d, '4chanXInitFinished', Unread.ready + posts = [] + for ID, post of Unread.thread.posts + posts.push post if post.isReply + Unread.addPosts posts + scroll: -> # Let the header's onload callback handle it. return if (hash = location.hash.match /\d+/) and hash[0] of Unread.thread.posts if Unread.posts.length # Scroll to before the first unread post. + prevID = 0 while root = $.x 'preceding-sibling::div[contains(@class,"postContainer")][1]', Unread.posts[0].nodes.root - break unless (Get.postFromRoot root).isHidden + post = Get.postFromRoot root + break if prevID is post.ID + prevID = post.ID + break unless post.isHidden root.scrollIntoView false return # Scroll to the last read post. @@ -175,4 +183,4 @@ Unread = # `favicon.href = href` isn't enough on Opera. # Opera won't always update the favicon if the href didn't change. $.add d.head, Favicon.el - <% } %> \ No newline at end of file + <% } %>