Unread.disconnect()
This commit is contained in:
parent
5fe3f55414
commit
32641549f2
@ -746,6 +746,10 @@
|
|||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
$.desync = function(key) {
|
||||||
|
return delete $.syncing[g.NAMESPACE + key];
|
||||||
|
};
|
||||||
|
|
||||||
$["delete"] = function(keys) {
|
$["delete"] = function(keys) {
|
||||||
var key, _i, _len;
|
var key, _i, _len;
|
||||||
if (!(keys instanceof Array)) {
|
if (!(keys instanceof Array)) {
|
||||||
@ -1458,6 +1462,19 @@
|
|||||||
return typeof this.sync === "function" ? this.sync() : void 0;
|
return typeof this.sync === "function" ? this.sync() : void 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
DataBoard.prototype.disconnect = function() {
|
||||||
|
var key, _i, _len, _results;
|
||||||
|
$.desync(this.key);
|
||||||
|
_results = [];
|
||||||
|
for (_i = 0, _len = this.length; _i < _len; _i++) {
|
||||||
|
key = this[_i];
|
||||||
|
if (this.hasOwnKey(key)) {
|
||||||
|
_results.push(delete this[key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _results;
|
||||||
|
};
|
||||||
|
|
||||||
return DataBoard;
|
return DataBoard;
|
||||||
|
|
||||||
})();
|
})();
|
||||||
@ -9542,6 +9559,9 @@
|
|||||||
if (g.VIEW !== 'thread' || !Conf['Unread Count'] && !Conf['Unread Favicon'] && !Conf['Desktop Notifications']) {
|
if (g.VIEW !== 'thread' || !Conf['Unread Count'] && !Conf['Unread Favicon'] && !Conf['Desktop Notifications']) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
return Unread.connect();
|
||||||
|
},
|
||||||
|
connect: function() {
|
||||||
this.db = new DataBoard('lastReadPosts', this.sync);
|
this.db = new DataBoard('lastReadPosts', this.sync);
|
||||||
this.hr = $.el('hr', {
|
this.hr = $.el('hr', {
|
||||||
id: 'unread-line'
|
id: 'unread-line'
|
||||||
@ -9553,6 +9573,28 @@
|
|||||||
cb: this.node
|
cb: this.node
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
disconnect: function() {
|
||||||
|
var hr, name, parent, _i, _len, _ref;
|
||||||
|
if (!Unread.db) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Unread.db.disconnect();
|
||||||
|
if (parent = (hr = Unread.hr).parentElement) {
|
||||||
|
$.rm(hr, parent);
|
||||||
|
}
|
||||||
|
_ref = ['db', 'hr', 'posts', 'postsQuotingYou', 'thread', 'title', 'lastReadPost'];
|
||||||
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
|
name = _ref[_i];
|
||||||
|
delete Unread[name];
|
||||||
|
}
|
||||||
|
$.off(d, '4chanXInitFinished', Unread.ready);
|
||||||
|
$.off(d, 'ThreadUpdate', Unread.onUpdate);
|
||||||
|
$.off(d, 'scroll visibilitychange', Unread.read);
|
||||||
|
if (Conf['Unread Line']) {
|
||||||
|
$.off(d, 'visibilitychange', Unread.setLine);
|
||||||
|
}
|
||||||
|
return Thread.callbacks.rm('Unread');
|
||||||
|
},
|
||||||
node: function() {
|
node: function() {
|
||||||
Unread.thread = this;
|
Unread.thread = this;
|
||||||
Unread.title = d.title;
|
Unread.title = d.title;
|
||||||
|
|||||||
@ -727,6 +727,10 @@
|
|||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
$.desync = function(key) {
|
||||||
|
return delete $.syncing[key];
|
||||||
|
};
|
||||||
|
|
||||||
$.localKeys = ['name', 'uniqueID', 'tripcode', 'capcode', 'email', 'subject', 'comment', 'flag', 'filename', 'dimensions', 'filesize', 'MD5', 'usercss'];
|
$.localKeys = ['name', 'uniqueID', 'tripcode', 'capcode', 'email', 'subject', 'comment', 'flag', 'filename', 'dimensions', 'filesize', 'MD5', 'usercss'];
|
||||||
|
|
||||||
$["delete"] = function(keys) {
|
$["delete"] = function(keys) {
|
||||||
@ -1464,6 +1468,19 @@
|
|||||||
return typeof this.sync === "function" ? this.sync() : void 0;
|
return typeof this.sync === "function" ? this.sync() : void 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
DataBoard.prototype.disconnect = function() {
|
||||||
|
var key, _i, _len, _results;
|
||||||
|
$.desync(this.key);
|
||||||
|
_results = [];
|
||||||
|
for (_i = 0, _len = this.length; _i < _len; _i++) {
|
||||||
|
key = this[_i];
|
||||||
|
if (this.hasOwnKey(key)) {
|
||||||
|
_results.push(delete this[key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _results;
|
||||||
|
};
|
||||||
|
|
||||||
return DataBoard;
|
return DataBoard;
|
||||||
|
|
||||||
})();
|
})();
|
||||||
@ -9525,6 +9542,9 @@
|
|||||||
if (g.VIEW !== 'thread' || !Conf['Unread Count'] && !Conf['Unread Favicon'] && !Conf['Desktop Notifications']) {
|
if (g.VIEW !== 'thread' || !Conf['Unread Count'] && !Conf['Unread Favicon'] && !Conf['Desktop Notifications']) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
return Unread.connect();
|
||||||
|
},
|
||||||
|
connect: function() {
|
||||||
this.db = new DataBoard('lastReadPosts', this.sync);
|
this.db = new DataBoard('lastReadPosts', this.sync);
|
||||||
this.hr = $.el('hr', {
|
this.hr = $.el('hr', {
|
||||||
id: 'unread-line'
|
id: 'unread-line'
|
||||||
@ -9536,6 +9556,28 @@
|
|||||||
cb: this.node
|
cb: this.node
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
disconnect: function() {
|
||||||
|
var hr, name, parent, _i, _len, _ref;
|
||||||
|
if (!Unread.db) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Unread.db.disconnect();
|
||||||
|
if (parent = (hr = Unread.hr).parentElement) {
|
||||||
|
$.rm(hr, parent);
|
||||||
|
}
|
||||||
|
_ref = ['db', 'hr', 'posts', 'postsQuotingYou', 'thread', 'title', 'lastReadPost'];
|
||||||
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
|
name = _ref[_i];
|
||||||
|
delete Unread[name];
|
||||||
|
}
|
||||||
|
$.off(d, '4chanXInitFinished', Unread.ready);
|
||||||
|
$.off(d, 'ThreadUpdate', Unread.onUpdate);
|
||||||
|
$.off(d, 'scroll visibilitychange', Unread.read);
|
||||||
|
if (Conf['Unread Line']) {
|
||||||
|
$.off(d, 'visibilitychange', Unread.setLine);
|
||||||
|
}
|
||||||
|
return Thread.callbacks.rm('Unread');
|
||||||
|
},
|
||||||
node: function() {
|
node: function() {
|
||||||
Unread.thread = this;
|
Unread.thread = this;
|
||||||
Unread.title = d.title;
|
Unread.title = d.title;
|
||||||
|
|||||||
@ -268,6 +268,7 @@ $.item = (key, val) ->
|
|||||||
item
|
item
|
||||||
|
|
||||||
$.syncing = {}
|
$.syncing = {}
|
||||||
|
|
||||||
<% if (type === 'crx') { %>
|
<% if (type === 'crx') { %>
|
||||||
$.sync = do ->
|
$.sync = do ->
|
||||||
chrome.storage.onChanged.addListener (changes) ->
|
chrome.storage.onChanged.addListener (changes) ->
|
||||||
@ -277,6 +278,8 @@ $.sync = do ->
|
|||||||
return
|
return
|
||||||
(key, cb) -> $.syncing[key] = cb
|
(key, cb) -> $.syncing[key] = cb
|
||||||
|
|
||||||
|
$.desync = (key) -> delete $.syncing[key]
|
||||||
|
|
||||||
$.localKeys = [
|
$.localKeys = [
|
||||||
# filters
|
# filters
|
||||||
'name',
|
'name',
|
||||||
@ -361,6 +364,8 @@ $.sync = do ->
|
|||||||
cb JSON.parse(newValue), key
|
cb JSON.parse(newValue), key
|
||||||
(key, cb) -> $.syncing[g.NAMESPACE + key] = cb
|
(key, cb) -> $.syncing[g.NAMESPACE + key] = cb
|
||||||
|
|
||||||
|
$.desync = (key) -> delete $.syncing[g.NAMESPACE + key]
|
||||||
|
|
||||||
$.delete = (keys) ->
|
$.delete = (keys) ->
|
||||||
unless keys instanceof Array
|
unless keys instanceof Array
|
||||||
keys = [keys]
|
keys = [keys]
|
||||||
|
|||||||
@ -90,3 +90,7 @@ class DataBoard
|
|||||||
onSync: (data) =>
|
onSync: (data) =>
|
||||||
@data = data or boards: {}
|
@data = data or boards: {}
|
||||||
@sync?()
|
@sync?()
|
||||||
|
|
||||||
|
disconnect: ->
|
||||||
|
$.desync @key
|
||||||
|
delete @[key] for key in @ when @hasOwnKey key
|
||||||
@ -2,6 +2,9 @@ Unread =
|
|||||||
init: ->
|
init: ->
|
||||||
return if g.VIEW isnt 'thread' or !Conf['Unread Count'] and !Conf['Unread Favicon'] and !Conf['Desktop Notifications']
|
return if g.VIEW isnt 'thread' or !Conf['Unread Count'] and !Conf['Unread Favicon'] and !Conf['Desktop Notifications']
|
||||||
|
|
||||||
|
Unread.connect()
|
||||||
|
|
||||||
|
connect: ->
|
||||||
@db = new DataBoard 'lastReadPosts', @sync
|
@db = new DataBoard 'lastReadPosts', @sync
|
||||||
@hr = $.el 'hr',
|
@hr = $.el 'hr',
|
||||||
id: 'unread-line'
|
id: 'unread-line'
|
||||||
@ -12,6 +15,21 @@ Unread =
|
|||||||
name: 'Unread'
|
name: 'Unread'
|
||||||
cb: @node
|
cb: @node
|
||||||
|
|
||||||
|
disconnect: ->
|
||||||
|
return unless Unread.db
|
||||||
|
|
||||||
|
Unread.db.disconnect()
|
||||||
|
$.rm hr, parent if parent = (hr = Unread.hr).parentElement
|
||||||
|
|
||||||
|
delete Unread[name] for name in ['db', 'hr', 'posts', 'postsQuotingYou', 'thread', 'title', 'lastReadPost']
|
||||||
|
|
||||||
|
$.off d, '4chanXInitFinished', Unread.ready
|
||||||
|
$.off d, 'ThreadUpdate', Unread.onUpdate
|
||||||
|
$.off d, 'scroll visibilitychange', Unread.read
|
||||||
|
$.off d, 'visibilitychange', Unread.setLine if Conf['Unread Line']
|
||||||
|
|
||||||
|
Thread.callbacks.rm 'Unread'
|
||||||
|
|
||||||
node: ->
|
node: ->
|
||||||
Unread.thread = @
|
Unread.thread = @
|
||||||
Unread.title = d.title
|
Unread.title = d.title
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user