Closed Sukhamjot-Singh closed 2 years ago
@Sukhamjot-Singh noticed a few things,
@Sukhamjot-Singh noticed a few things,
- On selecting the channel page it doesn't immediately load the data. I think it's because you have an onupdate hook, but no oninit hook, so data is not fetched until a different tab is selected.
- The summary and posts seem to be loading fine, although now the page is continuously polling the endpoint. I think we should avoid that since it could put a lot of unnecessary load on the client. It's likely happening because of the infinite loop with the onupdate handler: onupdate triggers data fetch > return data causes mithril to rerender > rerender causes onupdate to fire again ...
- Wow. Thanks for pointing out the problem.
- Yeah I fixed the problem for loading. Basically I was storing empty requests in the client and later loading them which was causing some errors.
You might also want to look at the setBackgroundTask
util in rswebui. See how the downloads page uses it.
You might also want to look at the
setBackgroundTask
util in rswebui. See how the downloads page uses it.
Okay, it looks like a useful tool. I can also use it call the load after some intervals. Thanks :)
I wanted to understand how files work.
destPath
, what to provide in this?I think it's optional. Just don't supply this parameter, and RS will download in the configured download directory (~/.retroshare/[location]/Download). While it's downloading, the data goes into the Partials/ directory.
I think it's optional. Just don't supply this parameter, and RS will download in the configured download directory (~/.retroshare/[location]/Download). While it's downloading, the data goes into the Partials/ directory.
Okay thanks a lot
Possible minor bug: The mCommentCount
in getChannelContent
-> posts[] is not updated and always returns 0.
Update : Displayed posts and comments
Fixed minor things, displayed date/size.
The upvote, downvotes, score is not updated in the comments
request.(getChannelContent -> comments[]).
Do I have to calculate using the votes[] or is there a way this can be corrected?
The upvote, downvotes, score is not updated in the
comments
request.(getChannelContent -> comments[]). Do I have to calculate using the votes[] or is there a way this can be corrected?
@csoler @G10h4ck
hi im not sure why it not works here the code on qt source:
void GxsCommentTreeWidget::insertComments(const std::vector<RsGxsComment>& comments)
{
std::list<RsGxsMessageId> new_comments;
for(auto vit = comments.begin(); vit != comments.end(); ++vit)
{
const RsGxsComment &comment = *vit;
if(IS_MSG_NEW(comment.mMeta.mMsgStatus))
new_comments.push_back(comment.mMeta.mMsgId);
/* convert to a QTreeWidgetItem */
std::cerr << "GxsCommentTreeWidget::service_loadThread() Got Comment: " << comment.mMeta.mMsgId;
std::cerr << std::endl;
GxsIdRSTreeWidgetItem *item = new GxsIdRSTreeWidgetItem(NULL,GxsIdDetails::ICON_TYPE_AVATAR) ;
QString text;
{
QDateTime qtime ;
qtime.setTime_t(comment.mMeta.mPublishTs) ;
text = qtime.toString("yyyy-MM-dd hh:mm:ss") ;
item->setText(PCITEM_COLUMN_DATE, text) ;
item->setToolTip(PCITEM_COLUMN_DATE, text) ;
item->setData(PCITEM_COLUMN_DATE, ROLE_SORT, QVariant(qlonglong(comment.mMeta.mPublishTs)));
}
text = QString::fromUtf8(comment.mComment.c_str());
item->setText(PCITEM_COLUMN_COMMENT, text);
item->setToolTip(PCITEM_COLUMN_COMMENT, text);
RsGxsId authorId = comment.mMeta.mAuthorId;
item->setId(authorId, PCITEM_COLUMN_AUTHOR, false);
item->setData(PCITEM_COLUMN_COMMENT,POST_COLOR_ROLE,QVariant(authorId.toByteArray()[1]));
text = QString::number(comment.mScore);
item->setText(PCITEM_COLUMN_SCORE, text);
text = QString::number(comment.mUpVotes);
item->setText(PCITEM_COLUMN_UPVOTES, text);
text = QString::number(comment.mDownVotes);
item->setText(PCITEM_COLUMN_DOWNVOTES, text);
text = QString::number(comment.mOwnVote);
item->setText(PCITEM_COLUMN_OWNVOTE, text);
text = QString::fromUtf8(comment.mMeta.mMsgId.toStdString().c_str());
item->setText(PCITEM_COLUMN_MSGID, text);
text = QString::fromUtf8(comment.mMeta.mParentId.toStdString().c_str());
item->setText(PCITEM_COLUMN_PARENTID, text);
text = QString::fromUtf8(comment.mMeta.mAuthorId.toStdString().c_str());
item->setText(PCITEM_COLUMN_AUTHORID, text);
#ifdef USE_NEW_DELEGATE
// Allows to call createEditor() in the delegate. Without this, createEditor() is never called in
// the styled item delegate.
item->setFlags(Qt::ItemIsEditable | item->flags());
#endif
addItem(comment.mMeta.mMsgId, comment.mMeta.mParentId, item);
}
// now set all loaded comments as not new, since they have been loaded.
for(auto cid:new_comments)
{
uint32_t token=0;
mCommentService->setCommentAsRead(token,mGroupId,cid);
}
}
This is because in the qt interface, comments are displayed in multiple steps: first we get the post, then the comments for this post, then the votes for the comments. This is all done asynchronously. It's possible that the synchronous API that is used for comments is not doing all the job. I'll look into it asap and will keep you posted.
Yes, Here it is the same thing, I receive the posts first and then the comments and votes separately. I compare the msgIds and filter them. I can count the Votes if required as I receive them. It would be just easier if that Info could be provided in the comments API as I saw there was a provision.
I'll try to provide an API that does all the job. Give me a few days.
I'll try to provide an API that does all the job. Give me a few days.
I mean synchronous API would be great, but I can work around with this as well and save the extra work. We can discuss it in the meet tomorrow.
ok. In the mean time, I read the code. It seems to me that the sync API already does the right thing:
For now, in Qt UI, mCommentCount is updated after getting the post data (GxsChannelPostsModel.cpp:177)
To me more specific, after calling getChannelContent() / getChannelAllContent() (depending on getting all posts, or just one),
ok. In the mean time, I read the code. It seems to me that the sync API already does the right thing:
- getChannelContent gets all the data for the requested posts, including comments and votes as lists. You have to use the thread IDs and parentIDs to know which post/comment they correspond to.
For now, in Qt UI, mCommentCount is updated after getting the post data (GxsChannelPostsModel.cpp:177)
To me more specific, after calling getChannelContent() / getChannelAllContent() (depending on getting all posts, or just one),
- in RsGxsComment.mMeta, mThreadId is the ID of the channel post the comment is about, and mParentID is the id of the parent comment. When mParentID is equal to mThreadID, the comment is a top-level comment.
- in RsGxsVote.mMeta, mThreadId is the ID of the channel post, and mParentId is the Id of the comment.
Yes, actually to be honest it took me 2 days to understand this structure. I was confused why everything was not coming together but later I figured out a way to do this efficiently.
I figured out how parentID and threadID works for replies to the comments.
I will use the Votes.mMeta to update the vote count then. It can be done easily. I just have to keep track of the ids properly.
exactly. In C++ we use a map for quickly updating the correct post/comment for each comment/vote.
exactly. In C++ we use a map for quickly updating the correct post/comment for each comment/vote.
Yes, same here. I am using an object with keys as msgId, threadID etc.
Is there a way to delete comments on post in Retroshare qt?
No you cant delete anything, In rs there is no feature for delete comments or posts.
No you cant delete anything, In rs there is no feature for delete comments or posts.
Okay, thank you
I was trying createVoteV2() -> https://github.com/RetroShare/libretroshare/blob/72f8b7e8e240923731a141c6f2a0438588f04f59/src/retroshare/rsgxschannels.h#L281 Retroshare keeps crashing as soon as I call the API. Maybe it is some syntax issue but not sure.
{"channelId":"8a602a04b918d2aadef52a420a6d9dea","postId":"24e244f100b22b19695188fb2d04e7745a2e7583","authorId":"feb1ce7628ea69e1d89ca82e80e18d11","commentId":"95ac4d00914823d12c69da4c443db56daa6e76ec","vote":2}
it crashes because of a bug in the code. I'm currently working on this part, so hopefully it should solve soon.
In the files and thumbnail field, what all exactly do I need to send?
Thumbnail is the image the channel posts appears with in the Qt UI. Files is the list of attached file links, but you need to supply them as structured data: filename, size and hash are the minimum you need to supply.
Thumbnail is the image the channel posts appears with in the Qt UI. Files is the list of attached file links, but you need to supply them as structured data: filename, size and hash are the minimum you need to supply.
I have filename and size, where do I obtain hash from?
it's a SHA1 hash. I suppose that JS has some lib to compute it?
it's a SHA1 hash. I suppose that JS has some lib to compute it?
Okay, I searched about this. There may be some external libraries but nothing inbuilt in JS.
it's a SHA1 hash. I suppose that JS has some lib to compute it?
Okay, I searched about this. There may be some external libraries but nothing inbuilt in JS.
I would have to use node.js for the 'crypto' module which helps compute the sha1 hash. I don't think we can use it in this project?
See this lib https://github.com/emn178/js-sha1 It's a single file src, I think it's okay to just include the file in our code.
That's what we need. For files, you'd need to load chunks from the file until the end, updating the sha1 for each chunk using
var hash = sha1.create();
for each chunk in the file hash.update(chunk);
hash.hex();
If you want to test it, compare to what "sha1sum" (a shell command) returns.
Thumbnail is the image the channel posts appears with in the Qt UI. Files is the list of attached file links, but you need to supply them as structured data: filename, size and hash are the minimum you need to supply.
retroshare://file?name=...&size=...&hash=...
Do I have to send a list of these urls in the createPostV2 API -> files -> []
"files" is a list of RsGxsFile, which is a structure containing the hash, name and size of each file. It's not a URL.
"files" is a list of RsGxsFile, which is a structure containing the hash, name and size of each file. It's not a URL.
Okay, i think I got confused
hi maybe you can develope a better comment viewer for channel/boards? like youtubes one? retroshare using wrong method to display comments on qt ui (channels/boards)
hi maybe you can develope a better comment viewer for channel/boards? like youtubes one? retroshare using wrong method to display comments on qt ui (channels/boards)
![]()
Something like this?
hi but without that right side, you has cloned right side like a table from qt ui add left side avatar, top name + timestamp under comment show reply, like (4) dislike (5), Score & ownvote
hi but without that right side, you has cloned right side like a table from qt ui add left side avatar, top name + timestamp under comment show reply, like (4) dislike (5), Score & ownvote
Okay I understand✅
would be nice to merge this at some point. It's getting too big a PR.
would be nice to merge this at some point. It's getting too big a PR.
We can merge. It is stable I will work with the updated in a new PR.
Okay to merge I guess. @csoler
could you fix the conflicts first?
could you fix the conflicts first?
I have no idea how to :) I will look into it.
could you fix the conflicts first?
I have no idea how to :) I will look into it.
just do a:
could you fix the conflicts first?
I have no idea how to :) I will look into it.
just do a:
- git fetch upstream
- git merge upstream/master Then fix the files that have conflicts, commit, and finally push to origin/[your working branch]
Right, I think this is the way to go. In this case I had an option on github only, so I made the changes.
Now I think it is okay to merge.
@rottencandy Can you pleasereview this. I don't know why it take so much time to call the content summaries and loading the post. This is taking too much of my time. Can you run this on your system?