From 42b1a6536bb77f8008fa7878201f804e9d4b067d Mon Sep 17 00:00:00 2001 From: Simon Grim Date: Sun, 21 Oct 2018 06:03:23 +0500 Subject: [PATCH] add an automatic ubiquitous appearing of a sent reply in replies of a twist --- js/interface_common.js | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/js/interface_common.js b/js/interface_common.js index b86ed69..e6fbc39 100644 --- a/js/interface_common.js +++ b/js/interface_common.js @@ -2467,13 +2467,47 @@ function postSubmit(e, oldLastPostId) { if (splitedPostsCount > 1) { if (textArea.length < splitedPostsCount) { //current part will be sent as reply to the previous part... - postData = $('
'); + postData = $('
'); } } - var doSubmitPost = function (postText, postData) { - newPostMsg(postText, postData.attr('data-screen-name'), parseInt(postData.attr('data-id'))); - } + if (postData.length) + var doSubmitPost = function (postText, postDataElem) { + var reply_n = postDataElem.attr('data-screen-name'); + 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' + + '[data-screen-name=\'' + req.reply_n + '\']' + + '[data-id=\'' + req.reply_k + '\']'); + + if (!postDataElem.length) { + if (req.part_id && ++req.tries < 5) + setTimeout(req.cbFunc, 2000, req); + 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 + + postToElem(ret, 'related').hide() + .appendTo(formerPostElem.next().children('.sub-replies')) + .slideDown('fast') + ; + }; + + newPostMsg(postText, reply_n, reply_k, + cbFunc, {reply_n: reply_n, reply_k: reply_k, part_id: part_id, + cbFunc: cbFunc, tries: 0} + ); + }; + else + var doSubmitPost = function (postText) { + newPostMsg(postText); + }; } if (textArea.length <= 1) {