Add (Dead) to quotelinks and backlinks when we find deleted posts.
Note sure if I can simplify this code. It performs well at least. Close #739.
This commit is contained in:
parent
101f593e18
commit
df6bff1b12
@ -757,16 +757,46 @@
|
||||
}
|
||||
|
||||
Post.prototype.kill = function(img) {
|
||||
var ID, num, post, quote, quotelink, quotelinks, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2, _ref3;
|
||||
if (this.file && !this.file.isDead) {
|
||||
this.file.isDead = true;
|
||||
$.log('kill image', this.ID);
|
||||
}
|
||||
if (img) {
|
||||
return;
|
||||
}
|
||||
$.log('kill post', this.ID);
|
||||
this.isDead = true;
|
||||
return $.addClass(this.nodes.root, 'dead');
|
||||
$.addClass(this.nodes.root, 'dead');
|
||||
quotelinks = [];
|
||||
num = "" + this.board + "." + this;
|
||||
_ref = g.posts;
|
||||
for (ID in _ref) {
|
||||
post = _ref[ID];
|
||||
if (-1 < post.quotes.indexOf(num)) {
|
||||
_ref1 = [post].concat(post.clones);
|
||||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
||||
post = _ref1[_i];
|
||||
quotelinks.push.apply(quotelinks, post.nodes.quotelinks);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Conf['Quote Backlinks']) {
|
||||
_ref2 = this.quotes;
|
||||
for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {
|
||||
quote = _ref2[_j];
|
||||
post = g.posts[quote];
|
||||
_ref3 = [post].concat(post.clones);
|
||||
for (_k = 0, _len2 = _ref3.length; _k < _len2; _k++) {
|
||||
post = _ref3[_k];
|
||||
quotelinks.push.apply(quotelinks, Array.prototype.slice.call(post.nodes.backlinks));
|
||||
}
|
||||
}
|
||||
}
|
||||
for (_l = 0, _len3 = quotelinks.length; _l < _len3; _l++) {
|
||||
quotelink = quotelinks[_l];
|
||||
if (+quotelink.hash.slice(2) === this.ID) {
|
||||
$.add(quotelink, $.tn('\u00A0(Dead)'));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Post.prototype.addClone = function(context) {
|
||||
|
||||
@ -609,7 +609,36 @@ class Post
|
||||
@isDead = true
|
||||
$.addClass @nodes.root, 'dead'
|
||||
# XXX style dead posts.
|
||||
# XXX update quotelinks/backlinks to this post.
|
||||
|
||||
# Get quote/backlinks to this post,
|
||||
# and paint them (Dead).
|
||||
# First:
|
||||
# In every posts,
|
||||
# if it did quote this post,
|
||||
# get all their backlinks.
|
||||
# Second:
|
||||
# If we have quote backlinks,
|
||||
# in all posts this post quoted,
|
||||
# and their clones,
|
||||
# get all of their backlinks.
|
||||
# Third:
|
||||
# In all collected links,
|
||||
# apply (Dead) if relevant.
|
||||
quotelinks = []
|
||||
num = "#{@board}.#{@}"
|
||||
for ID, post of g.posts
|
||||
if -1 < post.quotes.indexOf num
|
||||
for post in [post].concat post.clones
|
||||
quotelinks.push.apply quotelinks, post.nodes.quotelinks
|
||||
if Conf['Quote Backlinks']
|
||||
for quote in @quotes
|
||||
post = g.posts[quote]
|
||||
for post in [post].concat post.clones
|
||||
quotelinks.push.apply quotelinks, Array::slice.call post.nodes.backlinks
|
||||
for quotelink in quotelinks
|
||||
if +quotelink.hash[2..] is @ID
|
||||
$.add quotelink, $.tn '\u00A0(Dead)'
|
||||
return
|
||||
addClone: (context) ->
|
||||
new Clone @, context
|
||||
rmClone: (index) ->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user