Unbreak Unread and JSON Navigation

This commit is contained in:
Zixaphir 2015-01-13 11:46:46 -07:00
parent 7e6720ee4d
commit f6ac531b16
5 changed files with 14 additions and 21 deletions

View File

@ -14932,7 +14932,7 @@
Unread = { Unread = {
init: function() { init: function() {
if (!(g.VIEW === 'thread' && Conf['Unread Count'] || Conf['Unread Favicon'] || Conf['Unread Line'] || Conf['Scroll to Last Read Post'] || Conf['Thread Watcher'] || Conf['Desktop Notifications'] || Conf['Quote Threading'])) { if (!(g.VIEW === 'thread' && (Conf['Unread Count'] || Conf['Unread Favicon'] || Conf['Unread Line'] || Conf['Scroll to Last Read Post'] || Conf['Thread Watcher'] || Conf['Desktop Notifications'] || Conf['Quote Threading']))) {
return; return;
} }
this.db = new DataBoard('lastReadPosts', this.sync); this.db = new DataBoard('lastReadPosts', this.sync);
@ -14954,7 +14954,7 @@
}, },
disconnect: function() { disconnect: function() {
var hr, name, _i, _len, _ref; var hr, name, _i, _len, _ref;
if (!(g.VIEW === 'thread' && Conf['Unread Count'] || Conf['Unread Favicon'] || Conf['Unread Line'] || Conf['Scroll to Last Read Post'] || Conf['Thread Watcher'] || Conf['Desktop Notifications'] || Conf['Quote Threading'])) { if (!(g.VIEW === 'thread' && (Conf['Unread Count'] || Conf['Unread Favicon'] || Conf['Unread Line'] || Conf['Scroll to Last Read Post'] || Conf['Thread Watcher'] || Conf['Desktop Notifications'] || Conf['Quote Threading']))) {
return; return;
} }
Unread.db.disconnect(); Unread.db.disconnect();
@ -14968,13 +14968,13 @@
delete this[name]; delete this[name];
} }
this.lastReadPost = 0; this.lastReadPost = 0;
$.off(d, '4chanXInitFinished', this.ready);
$.off(d, 'ThreadUpdate', this.onUpdate); $.off(d, 'ThreadUpdate', this.onUpdate);
$.off(d, 'scroll visibilitychange', this.read); $.off(d, 'scroll visibilitychange', this.read);
if (Conf['Unread Line']) { if (Conf['Unread Line']) {
$.off(d, 'visibilitychange', this.setLine); $.off(d, 'visibilitychange', this.setLine);
} }
return Thread.callbacks.disconnect('Unread'); Thread.callbacks.disconnect('Unread');
return Post.callbacks.disconnect('Unread');
}, },
node: function() { node: function() {
var ID, _i, _len, _ref; var ID, _i, _len, _ref;
@ -18868,9 +18868,6 @@
board = $('.board'); board = $('.board');
$.rmAll(board); $.rmAll(board);
$.add(board, [threadRoot, $.el('hr')]); $.add(board, [threadRoot, $.el('hr')]);
if (Conf['Unread Count']) {
Unread.ready();
}
QR.generatePostableThreadsList(); QR.generatePostableThreadsList();
Header.hashScroll.call(window); Header.hashScroll.call(window);
if (errors) { if (errors) {

View File

@ -14948,7 +14948,7 @@
Unread = { Unread = {
init: function() { init: function() {
if (!(g.VIEW === 'thread' && Conf['Unread Count'] || Conf['Unread Favicon'] || Conf['Unread Line'] || Conf['Scroll to Last Read Post'] || Conf['Thread Watcher'] || Conf['Desktop Notifications'] || Conf['Quote Threading'])) { if (!(g.VIEW === 'thread' && (Conf['Unread Count'] || Conf['Unread Favicon'] || Conf['Unread Line'] || Conf['Scroll to Last Read Post'] || Conf['Thread Watcher'] || Conf['Desktop Notifications'] || Conf['Quote Threading']))) {
return; return;
} }
this.db = new DataBoard('lastReadPosts', this.sync); this.db = new DataBoard('lastReadPosts', this.sync);
@ -14970,7 +14970,7 @@
}, },
disconnect: function() { disconnect: function() {
var hr, name, _i, _len, _ref; var hr, name, _i, _len, _ref;
if (!(g.VIEW === 'thread' && Conf['Unread Count'] || Conf['Unread Favicon'] || Conf['Unread Line'] || Conf['Scroll to Last Read Post'] || Conf['Thread Watcher'] || Conf['Desktop Notifications'] || Conf['Quote Threading'])) { if (!(g.VIEW === 'thread' && (Conf['Unread Count'] || Conf['Unread Favicon'] || Conf['Unread Line'] || Conf['Scroll to Last Read Post'] || Conf['Thread Watcher'] || Conf['Desktop Notifications'] || Conf['Quote Threading']))) {
return; return;
} }
Unread.db.disconnect(); Unread.db.disconnect();
@ -14984,13 +14984,13 @@
delete this[name]; delete this[name];
} }
this.lastReadPost = 0; this.lastReadPost = 0;
$.off(d, '4chanXInitFinished', this.ready);
$.off(d, 'ThreadUpdate', this.onUpdate); $.off(d, 'ThreadUpdate', this.onUpdate);
$.off(d, 'scroll visibilitychange', this.read); $.off(d, 'scroll visibilitychange', this.read);
if (Conf['Unread Line']) { if (Conf['Unread Line']) {
$.off(d, 'visibilitychange', this.setLine); $.off(d, 'visibilitychange', this.setLine);
} }
return Thread.callbacks.disconnect('Unread'); Thread.callbacks.disconnect('Unread');
return Post.callbacks.disconnect('Unread');
}, },
node: function() { node: function() {
var ID, _i, _len, _ref; var ID, _i, _len, _ref;
@ -18894,9 +18894,6 @@
board = $('.board'); board = $('.board');
$.rmAll(board); $.rmAll(board);
$.add(board, [threadRoot, $.el('hr')]); $.add(board, [threadRoot, $.el('hr')]);
if (Conf['Unread Count']) {
Unread.ready();
}
QR.generatePostableThreadsList(); QR.generatePostableThreadsList();
Header.hashScroll.call(window); Header.hashScroll.call(window);
if (errors) { if (errors) {

View File

@ -360,8 +360,6 @@ Navigate =
$.rmAll board $.rmAll board
$.add board, [threadRoot, $.el 'hr'] $.add board, [threadRoot, $.el 'hr']
Unread.ready() if Conf['Unread Count']
QR.generatePostableThreadsList() QR.generatePostableThreadsList()
Header.hashScroll.call window Header.hashScroll.call window

View File

@ -1,6 +1,6 @@
Unread = Unread =
init: -> init: ->
return unless g.VIEW is 'thread' and return unless g.VIEW is 'thread' and (
Conf['Unread Count'] or Conf['Unread Count'] or
Conf['Unread Favicon'] or Conf['Unread Favicon'] or
Conf['Unread Line'] or Conf['Unread Line'] or
@ -8,6 +8,7 @@ Unread =
Conf['Thread Watcher'] or Conf['Thread Watcher'] or
Conf['Desktop Notifications'] or Conf['Desktop Notifications'] or
Conf['Quote Threading'] Conf['Quote Threading']
)
@db = new DataBoard 'lastReadPosts', @sync @db = new DataBoard 'lastReadPosts', @sync
@hr = $.el 'hr', @hr = $.el 'hr',
@ -46,9 +47,8 @@ Unread =
el: testLink el: testLink
<% } %> <% } %>
disconnect: -> disconnect: ->
return unless g.VIEW is 'thread' and return unless g.VIEW is 'thread' and (
Conf['Unread Count'] or Conf['Unread Count'] or
Conf['Unread Favicon'] or Conf['Unread Favicon'] or
Conf['Unread Line'] or Conf['Unread Line'] or
@ -56,6 +56,7 @@ Unread =
Conf['Thread Watcher'] or Conf['Thread Watcher'] or
Conf['Desktop Notifications'] or Conf['Desktop Notifications'] or
Conf['Quote Threading'] Conf['Quote Threading']
)
Unread.db.disconnect() Unread.db.disconnect()
{hr} = Unread {hr} = Unread
@ -64,12 +65,12 @@ Unread =
delete @[name] for name in ['db', 'hr', 'posts', 'postsQuotingYou', 'thread', 'title'] delete @[name] for name in ['db', 'hr', 'posts', 'postsQuotingYou', 'thread', 'title']
@lastReadPost = 0 @lastReadPost = 0
$.off d, '4chanXInitFinished', @ready
$.off d, 'ThreadUpdate', @onUpdate $.off d, 'ThreadUpdate', @onUpdate
$.off d, 'scroll visibilitychange', @read $.off d, 'scroll visibilitychange', @read
$.off d, 'visibilitychange', @setLine if Conf['Unread Line'] $.off d, 'visibilitychange', @setLine if Conf['Unread Line']
Thread.callbacks.disconnect 'Unread' Thread.callbacks.disconnect 'Unread'
Post.callbacks.disconnect 'Unread'
node: -> node: ->
Unread.thread = @ Unread.thread = @