From 414e5cb3c02f17bd6fb647c907b0db36a9b69927 Mon Sep 17 00:00:00 2001 From: erqan Date: Mon, 27 Jul 2015 14:50:11 +0300 Subject: [PATCH] show replied promoted post and don't show the sent indicator with promoted posts --- js/twister_actions.js | 43 +++++++++++++++++++++++++++++----------- js/twister_formatpost.js | 4 +++- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/js/twister_actions.js b/js/twister_actions.js index ce51cae..d127e26 100644 --- a/js/twister_actions.js +++ b/js/twister_actions.js @@ -29,18 +29,37 @@ function requestRepliedBefore(postLi) var reply_k = originalPost.attr('data-replied-to-id'); if( reply_n != undefined && reply_k != undefined ) { - dhtget( reply_n, "post" + reply_k, "s", - function(postLi, postFromJson) { - if (postFromJson) { - postLi.find('textarea').textcomplete('destroy'); // FIXME maybe we need to reset position instead (but curently it's cheaper) - var newStreamPost = postToElem(postFromJson, "related"); - newStreamPost.hide(); - postLi.before(newStreamPost); - newStreamPost.slideDown("fast"); - $.MAL.relatedPostLoaded(); - requestRepliedBefore(newStreamPost); - } - }, postLi); + if (reply_n[0] !== '!') { + dhtget(reply_n, "post" + reply_k, "s", + function (postLi, postFromJson) { + console.log(postFromJson); + if (postFromJson) { + postLi.find('textarea').textcomplete('destroy'); // FIXME maybe we need to reset position instead (but curently it's cheaper) + var newStreamPost = postToElem(postFromJson, "related"); + newStreamPost.hide(); + postLi.before(newStreamPost); + newStreamPost.slideDown("fast"); + $.MAL.relatedPostLoaded(); + requestRepliedBefore(newStreamPost); + } + }, postLi); + } else { + //replied to a promoted post... try to get it.. + var params = [1, parseInt(reply_k)]; + twisterRpc("getspamposts", params, + function (postLi, postFromJson) { + console.log(postFromJson[0]); + if (postFromJson) { + postLi.find('textarea').textcomplete('destroy'); // FIXME maybe we need to reset position instead (but curently it's cheaper) + var newStreamPost = postToElem(postFromJson[0], "related", 1); + newStreamPost.hide(); + postLi.before(newStreamPost); + newStreamPost.slideDown("fast"); + $.MAL.relatedPostLoaded(); + requestRepliedBefore(newStreamPost); + } + }, postLi, function(arg,ret) {console.log(ret)}); + } } } diff --git a/js/twister_formatpost.js b/js/twister_formatpost.js index 42de19b..6b56813 100644 --- a/js/twister_formatpost.js +++ b/js/twister_formatpost.js @@ -108,7 +108,6 @@ function postToElem( post, kind, promoted ) { postInfoName.text(n).attr('href', $.MAL.userUrl(n)); getFullname( n, postInfoName ); //elem.find('.post-info-tag').text("@" + n); - setPostInfoSent(n,k,elem.find('.post-info-sent')); getAvatar( n, elem.find('.avatar') ); elem.find('.post-info-time').text(timeGmtToText(t)).attr('title', timeSincePost(t)); @@ -143,7 +142,10 @@ function postToElem( post, kind, promoted ) { if (typeof(promoted) !== 'undefined' && promoted) { elem.find('.post-propagate').remove(); + postData.attr('data-promoted', 1); + postData.attr('data-screen-name', '!' + n); } else { + setPostInfoSent(n,k,elem.find('.post-info-sent')); if ($.Options.filterLang.val !== 'disable' && $.Options.filterLangSimulate.val) { // FIXME it's must be stuff from template actually if (typeof(post['langFilter']) !== 'undefined') {