Kill each clones when we kill a post too.

This commit is contained in:
Nicolas Stepien 2013-02-16 00:02:01 +01:00
parent 9136d7f643
commit 5dd3cc38d0
3 changed files with 55 additions and 45 deletions

View File

@ -20,7 +20,7 @@
// @icon data:image/gif;base64,R0lGODlhEAAQAKECAAAAAGbMM////////yH5BAEKAAIALAAAAAAQABAAAAIxlI+pq+D9DAgUoFkPDlbs7lGiI2bSVnKglnJMOL6omczxVZK3dH/41AG6Lh7i6qUoAAA7
// ==/UserScript==
/* 4chan X Alpha - Version 3.0.0 - 2013-02-15
/* 4chan X Alpha - Version 3.0.0 - 2013-02-16
* http://mayhemydg.github.com/4chan-x/
*
* Copyright (c) 2009-2011 James Campos <james.r.campos@gmail.com>
@ -3364,7 +3364,7 @@
var markStale, setOwnTimeout, update;
setOwnTimeout = function(diff) {
var delay;
delay = diff >= $.DAY ? diff % $.DAY : diff >= $.HOUR ? diff % $.HOUR : diff >= $.MINUTE ? diff % $.MINUTE : diff % $.SECOND;
delay = diff < $.MINUTE ? diff % $.SECOND : diff < $.HOUR ? diff % $.MINUTE : diff < $.DAY ? diff % $.HOUR : diff % $.DAY;
return setTimeout(markStale, delay);
};
update = function(now) {
@ -5285,34 +5285,40 @@
}
}
Post.prototype.kill = function(img) {
var now, quotelink, strong, _i, _len, _ref;
now = new Date();
if (this.file && !this.file.isDead) {
Post.prototype.kill = function(file, now) {
var clone, quotelink, strong, _i, _j, _len, _len1, _ref, _ref1;
now || (now = new Date());
if (file) {
this.file.isDead = true;
this.file.timeOfDeath = now;
$.after($('input', this.nodes.info), $.el('strong', {
className: 'warning',
textContent: '[File deleted]'
}));
}
if (img) {
return;
}
this.isDead = true;
this.timeOfDeath = now;
$.addClass(this.nodes.root, 'dead');
if (strong = $('strong.warning', this.nodes.info)) {
strong.textContent = '[Deleted]';
$.addClass(this.nodes.root, 'deleted-file');
} else {
$.after($('input', this.nodes.info), $.el('strong', {
this.isDead = true;
this.timeOfDeath = now;
$.addClass(this.nodes.root, 'deleted-post');
}
if (!(strong = $('strong.warning', this.nodes.info))) {
strong = $.el('strong', {
className: 'warning',
textContent: '[Deleted]'
}));
});
$.after($('input', this.nodes.info), strong);
}
_ref = Get.allQuotelinksLinkingTo(this);
strong.textContent = file ? '[File deleted]' : '[Deleted]';
if (this.isClone) {
return;
}
_ref = this.clones;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
quotelink = _ref[_i];
clone = _ref[_i];
clone.kill(file, now);
}
if (file) {
return;
}
_ref1 = Get.allQuotelinksLinkingTo(this);
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
quotelink = _ref1[_j];
if ($.hasClass(quotelink, 'deadlink')) {
continue;
}

View File

@ -2079,14 +2079,14 @@ RelativeDates =
# re-add `update()` to the stale list later.
setUpdate: (post) ->
setOwnTimeout = (diff) ->
delay = if diff >= $.DAY
diff % $.DAY
else if diff >= $.HOUR
diff % $.HOUR
else if diff >= $.MINUTE
diff % $.MINUTE
else
delay = if diff < $.MINUTE
diff % $.SECOND
else if diff < $.HOUR
diff % $.MINUTE
else if diff < $.DAY
diff % $.HOUR
else
diff % $.DAY
setTimeout markStale, delay
update = (now) ->

View File

@ -145,25 +145,29 @@ class Post
g.posts["#{board}.#{@}"] = thread.posts[@] = board.posts[@] = @
@kill() if that.isArchived
kill: (img) ->
now = new Date()
if @file and !@file.isDead
kill: (file, now) ->
now or= new Date()
if file
@file.isDead = true
@file.timeOfDeath = now
$.after $('input', @nodes.info), $.el 'strong',
className: 'warning'
textContent: '[File deleted]'
return if img
@isDead = true
@timeOfDeath = now
$.addClass @nodes.root, 'dead'
if strong = $ 'strong.warning', @nodes.info
strong.textContent = '[Deleted]'
$.addClass @nodes.root, 'deleted-file'
else
$.after $('input', @nodes.info), $.el 'strong',
className: 'warning'
textContent: '[Deleted]'
@isDead = true
@timeOfDeath = now
$.addClass @nodes.root, 'deleted-post'
unless strong = $ 'strong.warning', @nodes.info
strong = $.el 'strong',
className: 'warning'
textContent: '[Deleted]'
$.after $('input', @nodes.info), strong
strong.textContent = if file then '[File deleted]' else '[Deleted]'
return if @isClone
for clone in @clones
clone.kill file, now
return if file
# Get quotelinks/backlinks to this post
# and paint them (Dead).
for quotelink in Get.allQuotelinksLinkingTo @