mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
fixed blocking API for votes
This commit is contained in:
parent
cf61cb3780
commit
54fd77822d
@ -1204,7 +1204,12 @@ void PostedListWidgetWithModel::voteMsg(RsGxsGrpMsgIdPair msg,bool up_or_down)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
rsPosted->voteForPost(up_or_down,msg.first,msg.second,voter_id);
|
RsGxsVoteType tvote = up_or_down?(RsGxsVoteType::UP):(RsGxsVoteType::DOWN);
|
||||||
|
|
||||||
|
std::string error_str;
|
||||||
|
RsGxsMessageId vote_id;
|
||||||
|
if(!rsPosted->voteForPost(msg.first,msg.second,voter_id,tvote,vote_id,error_str))
|
||||||
|
QMessageBox::critical(nullptr,tr("Could not vote"), tr("Error occured while voting: ")+QString::fromStdString(error_str));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TODO
|
#ifdef TODO
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
|
#include <QMessageBox>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
@ -402,35 +403,27 @@ void GxsCommentTreeWidget::setVoteId(const RsGxsId &voterId)
|
|||||||
void GxsCommentTreeWidget::vote(const RsGxsGroupId &groupId, const RsGxsMessageId &threadId,
|
void GxsCommentTreeWidget::vote(const RsGxsGroupId &groupId, const RsGxsMessageId &threadId,
|
||||||
const RsGxsMessageId &parentId, const RsGxsId &authorId, bool up)
|
const RsGxsMessageId &parentId, const RsGxsId &authorId, bool up)
|
||||||
{
|
{
|
||||||
RsGxsVote vote;
|
RsThread::async([this,groupId,threadId,parentId,authorId,up]()
|
||||||
|
{
|
||||||
|
std::string error_string;
|
||||||
|
RsGxsMessageId vote_id;
|
||||||
|
RsGxsVoteType tvote = up?(RsGxsVoteType::UP):(RsGxsVoteType::DOWN);
|
||||||
|
|
||||||
vote.mMeta.mGroupId = groupId;
|
bool res = mCommentService->voteForComment(groupId, threadId, parentId, authorId,tvote,vote_id, error_string);
|
||||||
vote.mMeta.mThreadId = threadId;
|
|
||||||
vote.mMeta.mParentId = parentId;
|
|
||||||
vote.mMeta.mAuthorId = authorId;
|
|
||||||
|
|
||||||
if (up)
|
RsQThreadUtils::postToObject( [this,res,error_string]()
|
||||||
{
|
{
|
||||||
vote.mVoteType = GXS_VOTE_UP;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
vote.mVoteType = GXS_VOTE_DOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef DEBUG_GXSCOMMENT_TREEWIDGET
|
if(res)
|
||||||
std::cerr << "GxsCommentTreeWidget::vote()";
|
service_requestComments(mGroupId,mMsgVersions);
|
||||||
std::cerr << std::endl;
|
else
|
||||||
|
QMessageBox::critical(nullptr,tr("Cannot vote"),tr("Error while voting: ")+QString::fromStdString(error_string));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
std::cerr << "GroupId : " << vote.mMeta.mGroupId << std::endl;
|
// uint32_t token;
|
||||||
std::cerr << "ThreadId : " << vote.mMeta.mThreadId << std::endl;
|
// mCommentService->createNewVote(token, vote);
|
||||||
std::cerr << "ParentId : " << vote.mMeta.mParentId << std::endl;
|
// mTokenQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_ACK, COMMENT_VOTE_ACK);
|
||||||
std::cerr << "AuthorId : " << vote.mMeta.mAuthorId << std::endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
uint32_t token;
|
|
||||||
mCommentService->createNewVote(token, vote);
|
|
||||||
mTokenQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_ACK, COMMENT_VOTE_ACK);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -558,12 +551,6 @@ void GxsCommentTreeWidget::service_requestComments(const RsGxsGroupId& group_id,
|
|||||||
|
|
||||||
}, this );
|
}, this );
|
||||||
});
|
});
|
||||||
// RsTokReqOptions opts;
|
|
||||||
// opts.mReqType = GXS_REQUEST_TYPE_MSG_RELATED_DATA;
|
|
||||||
// opts.mOptions = RS_TOKREQOPT_MSG_THREAD | RS_TOKREQOPT_MSG_LATEST;
|
|
||||||
|
|
||||||
// uint32_t token;
|
|
||||||
// mTokenQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, ids_to_ask, GXSCOMMENTS_LOADTHREAD);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TODO
|
#ifdef TODO
|
||||||
|
Loading…
Reference in New Issue
Block a user