mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-12-17 01:24:15 -05:00
improved code consistency in feed item loading/killing
This commit is contained in:
parent
516ccdf4bd
commit
c3fb087f92
12 changed files with 119 additions and 58 deletions
|
|
@ -78,7 +78,8 @@ BaseBoardsCommentsItem::BaseBoardsCommentsItem( FeedHolder *feedHolder, uint32_t
|
||||||
|
|
||||||
BaseBoardsCommentsItem::~BaseBoardsCommentsItem()
|
BaseBoardsCommentsItem::~BaseBoardsCommentsItem()
|
||||||
{
|
{
|
||||||
auto timeout = std::chrono::steady_clock::now() + std::chrono::milliseconds(200);
|
auto timeout = std::chrono::steady_clock::now() + std::chrono::milliseconds(GROUP_ITEM_LOADING_TIMEOUT_ms);
|
||||||
|
|
||||||
while( (mIsLoadingGroup || mIsLoadingMessage || mIsLoadingComment)
|
while( (mIsLoadingGroup || mIsLoadingMessage || mIsLoadingComment)
|
||||||
&& std::chrono::steady_clock::now() < timeout)
|
&& std::chrono::steady_clock::now() < timeout)
|
||||||
{
|
{
|
||||||
|
|
@ -126,6 +127,7 @@ bool BaseBoardsCommentsItem::setPost(const RsPostedPost &post, bool doFill)
|
||||||
void BaseBoardsCommentsItem::loadGroup()
|
void BaseBoardsCommentsItem::loadGroup()
|
||||||
{
|
{
|
||||||
mIsLoadingGroup = true;
|
mIsLoadingGroup = true;
|
||||||
|
|
||||||
RsThread::async([this]()
|
RsThread::async([this]()
|
||||||
{
|
{
|
||||||
// 1 - get group data
|
// 1 - get group data
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ void ChannelsCommentsItem::paintEvent(QPaintEvent *e)
|
||||||
|
|
||||||
ChannelsCommentsItem::~ChannelsCommentsItem()
|
ChannelsCommentsItem::~ChannelsCommentsItem()
|
||||||
{
|
{
|
||||||
auto timeout = std::chrono::steady_clock::now() + std::chrono::milliseconds(300);
|
auto timeout = std::chrono::steady_clock::now() + std::chrono::milliseconds(GROUP_ITEM_LOADING_TIMEOUT_ms);
|
||||||
|
|
||||||
while( mLoading && std::chrono::steady_clock::now() < timeout )
|
while( mLoading && std::chrono::steady_clock::now() < timeout )
|
||||||
{
|
{
|
||||||
|
|
@ -293,12 +293,14 @@ void ChannelsCommentsItem::load()
|
||||||
if(!rsGxsChannels->getChannelsInfo(groupIds,groups)) // would be better to call channel Summaries for a single group
|
if(!rsGxsChannels->getChannelsInfo(groupIds,groups)) // would be better to call channel Summaries for a single group
|
||||||
{
|
{
|
||||||
RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl;
|
RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl;
|
||||||
|
mLoading= false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (groups.size() != 1)
|
if (groups.size() != 1)
|
||||||
{
|
{
|
||||||
std::cerr << "GxsGxsChannelGroupItem::loadGroup() Wrong number of Items" << std::endl;
|
std::cerr << "GxsGxsChannelGroupItem::loadGroup() Wrong number of Items" << std::endl;
|
||||||
|
mLoading= false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
RsGxsChannelGroup group(groups[0]);
|
RsGxsChannelGroup group(groups[0]);
|
||||||
|
|
@ -312,6 +314,7 @@ void ChannelsCommentsItem::load()
|
||||||
if(! rsGxsChannels->getChannelContent( groupId(), std::set<RsGxsMessageId>( { messageId(),mThreadId } ),posts,comments,votes))
|
if(! rsGxsChannels->getChannelContent( groupId(), std::set<RsGxsMessageId>( { messageId(),mThreadId } ),posts,comments,votes))
|
||||||
{
|
{
|
||||||
RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl;
|
RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl;
|
||||||
|
mLoading= false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -325,8 +328,12 @@ void ChannelsCommentsItem::load()
|
||||||
|
|
||||||
mGroupMeta = group.mMeta;
|
mGroupMeta = group.mMeta;
|
||||||
|
|
||||||
if(comments.size()==1)
|
if(comments.size()!=1)
|
||||||
{
|
{
|
||||||
|
mLoading=false;
|
||||||
|
removeItem();
|
||||||
|
}
|
||||||
|
|
||||||
RsGxsComment cmt(comments[0]);
|
RsGxsComment cmt(comments[0]);
|
||||||
|
|
||||||
uint32_t autorized_lines = (int)floor( (ui->avatarLabel->height() - ui->button_HL->sizeHint().height())
|
uint32_t autorized_lines = (int)floor( (ui->avatarLabel->height() - ui->button_HL->sizeHint().height())
|
||||||
|
|
@ -345,12 +352,6 @@ void ChannelsCommentsItem::load()
|
||||||
ui->avatarLabel->setPixmap(pixmap);
|
ui->avatarLabel->setPixmap(pixmap);
|
||||||
|
|
||||||
//Change this item to be uploaded with thread element. This is really bad practice.
|
//Change this item to be uploaded with thread element. This is really bad practice.
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mLoading=false;
|
|
||||||
removeItem();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (posts.size() == 1)
|
if (posts.size() == 1)
|
||||||
setPost(posts[0]);
|
setPost(posts[0]);
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@
|
||||||
GxsChannelGroupItem::GxsChannelGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, bool isHome, bool autoUpdate) :
|
GxsChannelGroupItem::GxsChannelGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, bool isHome, bool autoUpdate) :
|
||||||
GxsGroupFeedItem(feedHolder, feedId, groupId, isHome, rsGxsChannels, autoUpdate)
|
GxsGroupFeedItem(feedHolder, feedId, groupId, isHome, rsGxsChannels, autoUpdate)
|
||||||
{
|
{
|
||||||
|
mIsLoading = false;
|
||||||
setup();
|
setup();
|
||||||
requestGroup();
|
requestGroup();
|
||||||
addEventHandler();
|
addEventHandler();
|
||||||
|
|
@ -44,6 +45,7 @@ GxsChannelGroupItem::GxsChannelGroupItem(FeedHolder *feedHolder, uint32_t feedId
|
||||||
GxsChannelGroupItem::GxsChannelGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsChannelGroup &group, bool isHome, bool autoUpdate) :
|
GxsChannelGroupItem::GxsChannelGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsChannelGroup &group, bool isHome, bool autoUpdate) :
|
||||||
GxsGroupFeedItem(feedHolder, feedId, group.mMeta.mGroupId, isHome, rsGxsChannels, autoUpdate)
|
GxsGroupFeedItem(feedHolder, feedId, group.mMeta.mGroupId, isHome, rsGxsChannels, autoUpdate)
|
||||||
{
|
{
|
||||||
|
mIsLoading = false;
|
||||||
setup();
|
setup();
|
||||||
setGroup(group);
|
setGroup(group);
|
||||||
addEventHandler();
|
addEventHandler();
|
||||||
|
|
@ -77,6 +79,14 @@ void GxsChannelGroupItem::addEventHandler()
|
||||||
|
|
||||||
GxsChannelGroupItem::~GxsChannelGroupItem()
|
GxsChannelGroupItem::~GxsChannelGroupItem()
|
||||||
{
|
{
|
||||||
|
auto timeout = std::chrono::steady_clock::now() + std::chrono::milliseconds(GROUP_ITEM_LOADING_TIMEOUT_ms);
|
||||||
|
|
||||||
|
while( mIsLoading && std::chrono::steady_clock::now() < timeout )
|
||||||
|
{
|
||||||
|
RsDbg() << __PRETTY_FUNCTION__ << " is Waiting for data to load " << std::endl;
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||||
|
}
|
||||||
|
|
||||||
rsEvents->unregisterEventsHandler(mEventHandlerId);
|
rsEvents->unregisterEventsHandler(mEventHandlerId);
|
||||||
delete(ui);
|
delete(ui);
|
||||||
}
|
}
|
||||||
|
|
@ -121,6 +131,8 @@ bool GxsChannelGroupItem::setGroup(const RsGxsChannelGroup &group)
|
||||||
|
|
||||||
void GxsChannelGroupItem::loadGroup()
|
void GxsChannelGroupItem::loadGroup()
|
||||||
{
|
{
|
||||||
|
mIsLoading = true;
|
||||||
|
|
||||||
RsThread::async([this]()
|
RsThread::async([this]()
|
||||||
{
|
{
|
||||||
// 1 - get group data
|
// 1 - get group data
|
||||||
|
|
@ -131,6 +143,7 @@ void GxsChannelGroupItem::loadGroup()
|
||||||
if(!rsGxsChannels->getChannelsInfo(groupIds,groups))
|
if(!rsGxsChannels->getChannelsInfo(groupIds,groups))
|
||||||
{
|
{
|
||||||
RsErr() << "PostedItem::loadGroup() ERROR getting data" << std::endl;
|
RsErr() << "PostedItem::loadGroup() ERROR getting data" << std::endl;
|
||||||
|
mIsLoading = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -138,6 +151,7 @@ void GxsChannelGroupItem::loadGroup()
|
||||||
{
|
{
|
||||||
std::cerr << "GxsGxsChannelGroupItem::loadGroup() Wrong number of Items";
|
std::cerr << "GxsGxsChannelGroupItem::loadGroup() Wrong number of Items";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
mIsLoading = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
RsGxsChannelGroup group(groups[0]);
|
RsGxsChannelGroup group(groups[0]);
|
||||||
|
|
@ -149,6 +163,7 @@ void GxsChannelGroupItem::loadGroup()
|
||||||
* after a blocking call to RetroShare API complete */
|
* after a blocking call to RetroShare API complete */
|
||||||
|
|
||||||
setGroup(group);
|
setGroup(group);
|
||||||
|
mIsLoading = false;
|
||||||
|
|
||||||
}, this );
|
}, this );
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,8 @@ private:
|
||||||
void setup();
|
void setup();
|
||||||
void addEventHandler();
|
void addEventHandler();
|
||||||
|
|
||||||
|
bool mIsLoading;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RsGxsChannelGroup mGroup;
|
RsGxsChannelGroup mGroup;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,7 @@ void GxsChannelPostItem::paintEvent(QPaintEvent *e)
|
||||||
|
|
||||||
GxsChannelPostItem::~GxsChannelPostItem()
|
GxsChannelPostItem::~GxsChannelPostItem()
|
||||||
{
|
{
|
||||||
auto timeout = std::chrono::steady_clock::now() + std::chrono::milliseconds(300);
|
auto timeout = std::chrono::steady_clock::now() + std::chrono::milliseconds(GROUP_ITEM_LOADING_TIMEOUT_ms);
|
||||||
|
|
||||||
while( (mLoadingGroup || mLoadingMessage || mLoadingComment)
|
while( (mLoadingGroup || mLoadingMessage || mLoadingComment)
|
||||||
&& std::chrono::steady_clock::now() < timeout)
|
&& std::chrono::steady_clock::now() < timeout)
|
||||||
|
|
@ -306,6 +306,7 @@ void GxsChannelPostItem::loadGroup()
|
||||||
if(!rsGxsChannels->getChannelsInfo(groupIds,groups)) // would be better to call channel Summaries for a single group
|
if(!rsGxsChannels->getChannelsInfo(groupIds,groups)) // would be better to call channel Summaries for a single group
|
||||||
{
|
{
|
||||||
RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl;
|
RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl;
|
||||||
|
mLoadingGroup = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -313,6 +314,7 @@ void GxsChannelPostItem::loadGroup()
|
||||||
{
|
{
|
||||||
std::cerr << "GxsGxsChannelGroupItem::loadGroup() Wrong number of Items";
|
std::cerr << "GxsGxsChannelGroupItem::loadGroup() Wrong number of Items";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
mLoadingGroup = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
RsGxsChannelGroup group(groups[0]);
|
RsGxsChannelGroup group(groups[0]);
|
||||||
|
|
@ -348,6 +350,7 @@ void GxsChannelPostItem::loadMessage()
|
||||||
if(! rsGxsChannels->getChannelContent( groupId(), std::set<RsGxsMessageId>( { messageId() } ),posts,comments,votes))
|
if(! rsGxsChannels->getChannelContent( groupId(), std::set<RsGxsMessageId>( { messageId() } ),posts,comments,votes))
|
||||||
{
|
{
|
||||||
RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl;
|
RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl;
|
||||||
|
mLoadingMessage = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -377,11 +380,11 @@ void GxsChannelPostItem::loadMessage()
|
||||||
ui->commLabel->show();
|
ui->commLabel->show();
|
||||||
ui->commLabel->setText(QString::fromUtf8(cmt.mComment.c_str()));
|
ui->commLabel->setText(QString::fromUtf8(cmt.mComment.c_str()));
|
||||||
|
|
||||||
//Change this item to be uploaded with thread element.
|
// Change this item to be uploaded with thread element. Note: this is terrible coding.
|
||||||
setMessageId(cmt.mMeta.mThreadId);
|
setMessageId(cmt.mMeta.mThreadId);
|
||||||
requestMessage();
|
|
||||||
|
|
||||||
mLoadingMessage = false;
|
mLoadingMessage = false;
|
||||||
|
|
||||||
|
requestMessage();
|
||||||
}, this );
|
}, this );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -424,6 +427,7 @@ void GxsChannelPostItem::loadComment()
|
||||||
if(! rsGxsChannels->getChannelComments( groupId(),msgIds,comments))
|
if(! rsGxsChannels->getChannelComments( groupId(),msgIds,comments))
|
||||||
{
|
{
|
||||||
RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl;
|
RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl;
|
||||||
|
mLoadingComment = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -446,13 +450,6 @@ void GxsChannelPostItem::loadComment()
|
||||||
|
|
||||||
void GxsChannelPostItem::fill()
|
void GxsChannelPostItem::fill()
|
||||||
{
|
{
|
||||||
/* fill in */
|
|
||||||
|
|
||||||
// if (isLoading()) {
|
|
||||||
// /* Wait for all requests */
|
|
||||||
//return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
#ifdef DEBUG_ITEM
|
#ifdef DEBUG_ITEM
|
||||||
std::cerr << "GxsChannelPostItem::fill()";
|
std::cerr << "GxsChannelPostItem::fill()";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@
|
||||||
GxsForumGroupItem::GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, bool isHome, bool autoUpdate) :
|
GxsForumGroupItem::GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, bool isHome, bool autoUpdate) :
|
||||||
GxsGroupFeedItem(feedHolder, feedId, groupId, isHome, rsGxsForums, autoUpdate)
|
GxsGroupFeedItem(feedHolder, feedId, groupId, isHome, rsGxsForums, autoUpdate)
|
||||||
{
|
{
|
||||||
|
mIsLoading = false;
|
||||||
setup();
|
setup();
|
||||||
requestGroup();
|
requestGroup();
|
||||||
addEventHandler();
|
addEventHandler();
|
||||||
|
|
@ -44,6 +45,7 @@ GxsForumGroupItem::GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, co
|
||||||
mAddedModerators(added_moderators),
|
mAddedModerators(added_moderators),
|
||||||
mRemovedModerators(removed_moderators)
|
mRemovedModerators(removed_moderators)
|
||||||
{
|
{
|
||||||
|
mIsLoading = false;
|
||||||
setup();
|
setup();
|
||||||
requestGroup();
|
requestGroup();
|
||||||
addEventHandler();
|
addEventHandler();
|
||||||
|
|
@ -85,6 +87,14 @@ GxsForumGroupItem::GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, co
|
||||||
|
|
||||||
GxsForumGroupItem::~GxsForumGroupItem()
|
GxsForumGroupItem::~GxsForumGroupItem()
|
||||||
{
|
{
|
||||||
|
auto timeout = std::chrono::steady_clock::now() + std::chrono::milliseconds(GROUP_ITEM_LOADING_TIMEOUT_ms);
|
||||||
|
|
||||||
|
while( mIsLoading && std::chrono::steady_clock::now() < timeout )
|
||||||
|
{
|
||||||
|
RsDbg() << __PRETTY_FUNCTION__ << " is Waiting for data to load " << std::endl;
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||||
|
}
|
||||||
|
|
||||||
rsEvents->unregisterEventsHandler(mEventHandlerId);
|
rsEvents->unregisterEventsHandler(mEventHandlerId);
|
||||||
delete(ui);
|
delete(ui);
|
||||||
}
|
}
|
||||||
|
|
@ -129,6 +139,8 @@ bool GxsForumGroupItem::setGroup(const RsGxsForumGroup &group)
|
||||||
|
|
||||||
void GxsForumGroupItem::loadGroup()
|
void GxsForumGroupItem::loadGroup()
|
||||||
{
|
{
|
||||||
|
mIsLoading = true;
|
||||||
|
|
||||||
RsThread::async([this]()
|
RsThread::async([this]()
|
||||||
{
|
{
|
||||||
// 1 - get group data
|
// 1 - get group data
|
||||||
|
|
@ -143,6 +155,7 @@ void GxsForumGroupItem::loadGroup()
|
||||||
if(!rsGxsForums->getForumsInfo(forumIds,groups))
|
if(!rsGxsForums->getForumsInfo(forumIds,groups))
|
||||||
{
|
{
|
||||||
RsErr() << "GxsForumGroupItem::loadGroup() ERROR getting data" << std::endl;
|
RsErr() << "GxsForumGroupItem::loadGroup() ERROR getting data" << std::endl;
|
||||||
|
mIsLoading = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -150,6 +163,7 @@ void GxsForumGroupItem::loadGroup()
|
||||||
{
|
{
|
||||||
std::cerr << "GxsForumGroupItem::loadGroup() Wrong number of Items";
|
std::cerr << "GxsForumGroupItem::loadGroup() Wrong number of Items";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
mIsLoading = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
RsGxsForumGroup group(groups[0]);// no reference to teporary accross threads!
|
RsGxsForumGroup group(groups[0]);// no reference to teporary accross threads!
|
||||||
|
|
@ -161,6 +175,7 @@ void GxsForumGroupItem::loadGroup()
|
||||||
* after a blocking call to RetroShare API complete */
|
* after a blocking call to RetroShare API complete */
|
||||||
|
|
||||||
setGroup(group);
|
setGroup(group);
|
||||||
|
mIsLoading = false;
|
||||||
|
|
||||||
}, this );
|
}, this );
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,8 @@ private:
|
||||||
/** Qt Designer generated object */
|
/** Qt Designer generated object */
|
||||||
Ui::GxsForumGroupItem *ui;
|
Ui::GxsForumGroupItem *ui;
|
||||||
|
|
||||||
|
bool mIsLoading;
|
||||||
|
|
||||||
std::list<RsGxsId> mAddedModerators;
|
std::list<RsGxsId> mAddedModerators;
|
||||||
std::list<RsGxsId> mRemovedModerators;
|
std::list<RsGxsId> mRemovedModerators;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ GxsForumMsgItem::GxsForumMsgItem(FeedHolder *feedHolder, uint32_t feedId, const
|
||||||
|
|
||||||
GxsForumMsgItem::~GxsForumMsgItem()
|
GxsForumMsgItem::~GxsForumMsgItem()
|
||||||
{
|
{
|
||||||
auto timeout = std::chrono::steady_clock::now() + std::chrono::milliseconds(300);
|
auto timeout = std::chrono::steady_clock::now() + std::chrono::milliseconds(GROUP_ITEM_LOADING_TIMEOUT_ms);
|
||||||
|
|
||||||
while( (mLoadingGroup || mLoadingMessage || mLoadingSetAsRead || mLoadingParentMessage)
|
while( (mLoadingGroup || mLoadingMessage || mLoadingSetAsRead || mLoadingParentMessage)
|
||||||
&& std::chrono::steady_clock::now() < timeout)
|
&& std::chrono::steady_clock::now() < timeout)
|
||||||
|
|
@ -202,6 +202,7 @@ void GxsForumMsgItem::loadGroup()
|
||||||
if(!rsGxsForums->getForumsInfo(forumIds,groups))
|
if(!rsGxsForums->getForumsInfo(forumIds,groups))
|
||||||
{
|
{
|
||||||
RsErr() << "GxsForumGroupItem::loadGroup() ERROR getting data" << std::endl;
|
RsErr() << "GxsForumGroupItem::loadGroup() ERROR getting data" << std::endl;
|
||||||
|
mLoadingGroup = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -209,6 +210,7 @@ void GxsForumMsgItem::loadGroup()
|
||||||
{
|
{
|
||||||
std::cerr << "GxsForumGroupItem::loadGroup() Wrong number of Items";
|
std::cerr << "GxsForumGroupItem::loadGroup() Wrong number of Items";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
mLoadingGroup = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
RsGxsForumGroup group(groups[0]);
|
RsGxsForumGroup group(groups[0]);
|
||||||
|
|
@ -249,6 +251,7 @@ void GxsForumMsgItem::loadMessage()
|
||||||
{
|
{
|
||||||
std::cerr << "GxsForumMsgItem::loadMessage() ERROR getting data";
|
std::cerr << "GxsForumMsgItem::loadMessage() ERROR getting data";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
mLoadingMessage = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -256,6 +259,7 @@ void GxsForumMsgItem::loadMessage()
|
||||||
{
|
{
|
||||||
std::cerr << "GxsForumMsgItem::loadMessage() Wrong number of Items";
|
std::cerr << "GxsForumMsgItem::loadMessage() Wrong number of Items";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
mLoadingMessage = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
RsGxsForumMsg msg(msgs[0]);
|
RsGxsForumMsg msg(msgs[0]);
|
||||||
|
|
@ -296,6 +300,7 @@ void GxsForumMsgItem::loadParentMessage(const RsGxsMessageId& parent_msg)
|
||||||
{
|
{
|
||||||
std::cerr << "GxsForumMsgItem::loadMessage() ERROR getting data";
|
std::cerr << "GxsForumMsgItem::loadMessage() ERROR getting data";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
mLoadingParentMessage = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -303,6 +308,7 @@ void GxsForumMsgItem::loadParentMessage(const RsGxsMessageId& parent_msg)
|
||||||
{
|
{
|
||||||
std::cerr << "GxsForumMsgItem::loadMessage() Wrong number of Items";
|
std::cerr << "GxsForumMsgItem::loadMessage() Wrong number of Items";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
mLoadingParentMessage = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
RsGxsForumMsg msg(msgs[0]);
|
RsGxsForumMsg msg(msgs[0]);
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@
|
||||||
PostedGroupItem::PostedGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, bool isHome, bool autoUpdate) :
|
PostedGroupItem::PostedGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, bool isHome, bool autoUpdate) :
|
||||||
GxsGroupFeedItem(feedHolder, feedId, groupId, isHome, rsPosted, autoUpdate)
|
GxsGroupFeedItem(feedHolder, feedId, groupId, isHome, rsPosted, autoUpdate)
|
||||||
{
|
{
|
||||||
|
mIsLoadingGroup = false;
|
||||||
setup();
|
setup();
|
||||||
|
|
||||||
requestGroup();
|
requestGroup();
|
||||||
|
|
@ -43,6 +44,7 @@ PostedGroupItem::PostedGroupItem(FeedHolder *feedHolder, uint32_t feedId, const
|
||||||
PostedGroupItem::PostedGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsPostedGroup &group, bool isHome, bool autoUpdate) :
|
PostedGroupItem::PostedGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsPostedGroup &group, bool isHome, bool autoUpdate) :
|
||||||
GxsGroupFeedItem(feedHolder, feedId, group.mMeta.mGroupId, isHome, rsPosted, autoUpdate)
|
GxsGroupFeedItem(feedHolder, feedId, group.mMeta.mGroupId, isHome, rsPosted, autoUpdate)
|
||||||
{
|
{
|
||||||
|
mIsLoadingGroup = false;
|
||||||
setup();
|
setup();
|
||||||
|
|
||||||
setGroup(group);
|
setGroup(group);
|
||||||
|
|
@ -50,6 +52,16 @@ PostedGroupItem::PostedGroupItem(FeedHolder *feedHolder, uint32_t feedId, const
|
||||||
|
|
||||||
PostedGroupItem::~PostedGroupItem()
|
PostedGroupItem::~PostedGroupItem()
|
||||||
{
|
{
|
||||||
|
auto timeout = std::chrono::steady_clock::now() + std::chrono::milliseconds(GROUP_ITEM_LOADING_TIMEOUT_ms);
|
||||||
|
|
||||||
|
while( mIsLoadingGroup && std::chrono::steady_clock::now() < timeout)
|
||||||
|
{
|
||||||
|
RsDbg() << __PRETTY_FUNCTION__ << " is Waiting "
|
||||||
|
<< (mIsLoadingGroup ? "Group " : "")
|
||||||
|
<< "loading finished." << std::endl;
|
||||||
|
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||||
|
}
|
||||||
delete(ui);
|
delete(ui);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -95,6 +107,8 @@ bool PostedGroupItem::setGroup(const RsPostedGroup &group)
|
||||||
|
|
||||||
void PostedGroupItem::loadGroup()
|
void PostedGroupItem::loadGroup()
|
||||||
{
|
{
|
||||||
|
mIsLoadingGroup = true;
|
||||||
|
|
||||||
RsThread::async([this]()
|
RsThread::async([this]()
|
||||||
{
|
{
|
||||||
// 1 - get group data
|
// 1 - get group data
|
||||||
|
|
@ -109,6 +123,7 @@ void PostedGroupItem::loadGroup()
|
||||||
if(!rsPosted->getBoardsInfo(groupIds,groups))
|
if(!rsPosted->getBoardsInfo(groupIds,groups))
|
||||||
{
|
{
|
||||||
RsErr() << "GxsPostedGroupItem::loadGroup() ERROR getting data" << std::endl;
|
RsErr() << "GxsPostedGroupItem::loadGroup() ERROR getting data" << std::endl;
|
||||||
|
mIsLoadingGroup = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -116,6 +131,7 @@ void PostedGroupItem::loadGroup()
|
||||||
{
|
{
|
||||||
std::cerr << "GxsPostedGroupItem::loadGroup() Wrong number of Items";
|
std::cerr << "GxsPostedGroupItem::loadGroup() Wrong number of Items";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
mIsLoadingGroup = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
RsPostedGroup group(groups[0]);
|
RsPostedGroup group(groups[0]);
|
||||||
|
|
@ -127,6 +143,7 @@ void PostedGroupItem::loadGroup()
|
||||||
* after a blocking call to RetroShare API complete */
|
* after a blocking call to RetroShare API complete */
|
||||||
|
|
||||||
setGroup(group);
|
setGroup(group);
|
||||||
|
mIsLoadingGroup = false;
|
||||||
|
|
||||||
}, this );
|
}, this );
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ private:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RsPostedGroup mGroup;
|
RsPostedGroup mGroup;
|
||||||
|
bool mIsLoadingGroup;
|
||||||
|
|
||||||
/** Qt Designer generated object */
|
/** Qt Designer generated object */
|
||||||
Ui::PostedGroupItem *ui;
|
Ui::PostedGroupItem *ui;
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,8 @@
|
||||||
* #define DEBUG_ITEM 1
|
* #define DEBUG_ITEM 1
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
const uint GxsGroupFeedItem::GROUP_ITEM_LOADING_TIMEOUT_ms = 2000;
|
||||||
|
|
||||||
GxsGroupFeedItem::GxsGroupFeedItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, bool isHome, RsGxsIfaceHelper *iface, bool /*autoUpdate*/) :
|
GxsGroupFeedItem::GxsGroupFeedItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, bool isHome, RsGxsIfaceHelper *iface, bool /*autoUpdate*/) :
|
||||||
FeedItem(feedHolder,feedId,NULL)
|
FeedItem(feedHolder,feedId,NULL)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ protected slots:
|
||||||
protected:
|
protected:
|
||||||
bool mIsHome;
|
bool mIsHome;
|
||||||
RsGxsIfaceHelper *mGxsIface;
|
RsGxsIfaceHelper *mGxsIface;
|
||||||
|
static const uint GROUP_ITEM_LOADING_TIMEOUT_ms ;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
/* RsGxsUpdateBroadcastBase */
|
/* RsGxsUpdateBroadcastBase */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue