diff --git a/js/interface_common.js b/js/interface_common.js index 575716e..b86ed69 100644 --- a/js/interface_common.js +++ b/js/interface_common.js @@ -2472,7 +2472,7 @@ function postSubmit(e, oldLastPostId) { } var doSubmitPost = function (postText, postData) { - newPostMsg(postText, postData); + newPostMsg(postText, postData.attr('data-screen-name'), parseInt(postData.attr('data-id'))); } } diff --git a/js/tmobile.js b/js/tmobile.js index 7947829..8a10b91 100644 --- a/js/tmobile.js +++ b/js/tmobile.js @@ -395,7 +395,7 @@ function installSubmitClick() { var $postOrig = $("#newmsg .reply-original-post .post-data"); var s = encode_utf8($replyText.val()); - newPostMsg(s, $postOrig); + newPostMsg(s, $postOrig.attr('data-screen-name'), parseInt($postOrig.attr('data-id'))); $replyText.val(""); $replyText.attr("placeholder", polyglot.t("Your message was sent!")); diff --git a/js/twister_actions.js b/js/twister_actions.js index 5bfe124..78d1bdf 100644 --- a/js/twister_actions.js +++ b/js/twister_actions.js @@ -243,23 +243,44 @@ function requestPostRecursively(containerToAppend,username,resource,count,useGet } } -function newPostMsg(msg, $postOrig) { - if( lastPostId != undefined ) { - if ( typeof _sendedPostIDs !== 'undefined' ) - _sendedPostIDs.push(lastPostId + 1); +function newPostMsg(msg, reply_n, reply_k, cbFunc, cbReq) { + if (typeof lastPostId === 'undefined') { + alertPopup({ + //txtTitle: polyglot.t(''), add some title (not 'error', please) or just KISS + txtMessage: 'Can\'t handle the twisting of a new twist —\n' + + polyglot.t('Internal error: lastPostId unknown (following yourself may fix!)') + }); + return; + } + if (typeof _sendedPostIDs !== 'object') { + alertPopup({ + //txtTitle: polyglot.t(''), add some title (not 'error', please) or just KISS + txtMessage: 'Can\'t handle the twisting of a new twist —\n' + + polyglot.t('this is undefined', {'this': '_sendedPostIDs'}) + }); + return; + } + + _sendedPostIDs.push(lastPostId + 1); + + var req = [defaultScreenName, lastPostId + 1, msg]; + if (reply_n) + req.push(reply_n, reply_k); - var params = [defaultScreenName, lastPostId + 1, msg] - if( $postOrig.length ) { - params.push($postOrig.attr('data-screen-name')); - params.push(parseInt($postOrig.attr('data-id'))); + twisterRpc('newpostmsg', req, + function(req, ret) { + incLastPostId(); + if (typeof req.cbFunc === 'function') + req.cbFunc(req.cbReq, ret); + }, {cbFunc: cbFunc, cbReq: cbReq}, + function(req, ret) { + alertPopup({ + //txtTitle: polyglot.t(''), add some title (not 'error', please) or just KISS + txtMessage: 'Can\'t handle the twisting of a new twist —\n' + + polyglot.t('ajax_error', {error: (ret.message) ? ret.message : ret}) + }); } - twisterRpc("newpostmsg", params, - function(arg, ret) { incLastPostId(); }, null, - function(arg, ret) { var msg = ("message" in ret) ? ret.message : ret; - alert(polyglot.t("ajax_error", { error: msg })); }, null); - } else { - alert(polyglot.t("Internal error: lastPostId unknown (following yourself may fix!)")); - } + ); } function newRtMsg(postData, msg) {