From e1ed62f9e519d781e155a61c73735b1906365dde Mon Sep 17 00:00:00 2001 From: Simon Grim Date: Sun, 28 Oct 2018 23:25:36 +0500 Subject: [PATCH] fix various edge cases of the appending of twists in an automatic ubiquitous appearing of a sent reply in replies of a twist --- js/interface_common.js | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/js/interface_common.js b/js/interface_common.js index c0e0579..01b0049 100644 --- a/js/interface_common.js +++ b/js/interface_common.js @@ -2481,7 +2481,7 @@ function postSubmit(e, oldLastPostId) { var reply_k = parseInt(postDataElem.attr('data-id')); var part_id = postDataElem.attr('data-reply-part-id'); var cbFunc = function (req, ret) { - var postDataElem = $('.expanded-post .post-data' + var postDataElem = getElem('.expanded-post .post-data' + '[data-screen-name=\'' + req.reply_n + '\']' + '[data-id=\'' + req.reply_k + '\']'); @@ -2491,15 +2491,34 @@ function postSubmit(e, oldLastPostId) { return; } - formerPostElem = postDataElem.closest('li.post'); - if (!formerPostElem.next().is('.post-replies')) - formerPostElem.after($('
    1. ')); // FIXME replace with template as like as a reqRepAfterCB()'s similar thing + for (var k = 0, twistElem = undefined; k < postDataElem.length; k++) { + var formerPostElem = postDataElem.eq(k).closest('li.post'); + if (!formerPostElem.next().hasClass('post-replies')) + var containerElem = $('
      1. ') // FIXME replace with template as like as a reqRepAfterCB()'s similar thing + .insertAfter(formerPostElem) + .children('.sub-replies') + ; + else { + var containerElem = formerPostElem.next().children('.sub-replies'); + + if (containerElem.find('.post-data' + + '[data-screen-name=\'' + ret.userpost.n + '\']' + + '[data-id=\'' + ret.userpost.k + '\']').length) + continue; + } - postToElem(ret, 'related').hide() - .addClass('new') - .appendTo(formerPostElem.next().children('.sub-replies')) - .slideDown('fast') - ; + if (typeof twistElem !== 'undefined') + twistElem.clone(true) + .appendTo(containerElem) + .slideDown('fast') + ; + else + twistElem = postToElem(ret, 'related').hide() + .addClass('new') + .appendTo(containerElem) + .slideDown('fast') + ; + } }; newPostMsg(postText, reply_n, reply_k,