mirror of
https://github.com/RetroShare/RetroShare.git
synced 2026-09-12 19:50:17 +05:00
fix zero post counts in Channels/Forums/Boards on Startup
This commit is contained in:
parent
97e840e38c
commit
2c02a46d4a
@ -541,6 +541,18 @@ void GroupTreeWidget::setUnreadCount(QTreeWidgetItem *item, int unreadCount)
|
||||
item->setFont(GTW_COLUMN_NAME, itFont);
|
||||
}
|
||||
|
||||
void GroupTreeWidget::setCounts(QTreeWidgetItem *item, int unreadCount, int totalCount)
|
||||
{
|
||||
if (item == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
setUnreadCount(item, unreadCount);
|
||||
|
||||
item->setText(GTW_COLUMN_POSTS, QString::number(totalCount));
|
||||
item->setData(GTW_COLUMN_POSTS, ROLE_SORT, totalCount);
|
||||
}
|
||||
|
||||
QTreeWidgetItem *GroupTreeWidget::getItemFromId(const QString &id)
|
||||
{
|
||||
if (id.isEmpty()) {
|
||||
|
||||
@ -113,6 +113,7 @@ public:
|
||||
void fillGroupItems(QTreeWidgetItem *categoryItem, const QList<GroupItemInfo> &itemList);
|
||||
// Set the unread count of an item
|
||||
void setUnreadCount(QTreeWidgetItem *item, int unreadCount);
|
||||
void setCounts(QTreeWidgetItem *item, int unreadCount, int totalCount);
|
||||
|
||||
bool isSearchRequestItem(QPoint &point,uint32_t& search_req_id);
|
||||
bool isSearchRequestResult(QPoint &point, QString &group_id, uint32_t& search_req_id);
|
||||
|
||||
@ -1159,44 +1159,7 @@ void GxsGroupFrameDialog::updateGroupSummary()
|
||||
/*********************** **** **** **** ***********************/
|
||||
/*********************** **** **** **** ***********************/
|
||||
|
||||
void GxsGroupFrameDialog::updateGroupStatistics(const RsGxsGroupId &groupId)
|
||||
{
|
||||
mGroupStatisticsToUpdate.insert(groupId);
|
||||
mShouldUpdateGroupStatistics = true;
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::updateGroupStatisticsReal(const RsGxsGroupId &groupId)
|
||||
{
|
||||
RsThread::async([this,groupId]()
|
||||
{
|
||||
GxsGroupStatistic stats;
|
||||
|
||||
if(! getGroupStatistics(groupId, stats))
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << " failed to collect group statistics for group " << groupId << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
RsQThreadUtils::postToObject( [this,stats, groupId]()
|
||||
{
|
||||
/* Here it goes any code you want to be executed on the Qt Gui
|
||||
* thread, for example to update the data model with new information
|
||||
* after a blocking call to RetroShare API complete, note that
|
||||
* Qt::QueuedConnection is important!
|
||||
*/
|
||||
|
||||
QTreeWidgetItem *item = ui->groupTreeWidget->getItemFromId(QString::fromStdString(stats.mGrpId.toStdString()));
|
||||
|
||||
if (item)
|
||||
ui->groupTreeWidget->setUnreadCount(item, mCountChildMsgs ? (stats.mNumThreadMsgsUnread + stats.mNumChildMsgsUnread) : stats.mNumThreadMsgsUnread);
|
||||
|
||||
mCachedGroupStats[groupId] = stats;
|
||||
|
||||
getUserNotify()->updateIcon();
|
||||
|
||||
}, this );
|
||||
});
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::getServiceStatistics(GxsServiceStatistic& stats) const
|
||||
{
|
||||
@ -1282,3 +1245,42 @@ void GxsGroupFrameDialog::distantRequestGroupData()
|
||||
checkRequestGroup(group_id) ;
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::updateGroupStatistics(const RsGxsGroupId &groupId)
|
||||
{
|
||||
mGroupStatisticsToUpdate.insert(groupId);
|
||||
mShouldUpdateGroupStatistics = true;
|
||||
}
|
||||
|
||||
void GxsGroupFrameDialog::updateGroupStatisticsReal(const RsGxsGroupId &groupId)
|
||||
{
|
||||
RsThread::async([this,groupId]()
|
||||
{
|
||||
GxsGroupStatistic stats;
|
||||
|
||||
if(! getGroupStatistics(groupId, stats))
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << " failed to collect group statistics for group " << groupId << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
RsQThreadUtils::postToObject( [this,stats, groupId]()
|
||||
{
|
||||
/* Here it goes any code you want to be executed on the Qt Gui
|
||||
* thread, for example to update the data model with new information
|
||||
* after a blocking call to RetroShare API complete, note that
|
||||
* Qt::QueuedConnection is important!
|
||||
*/
|
||||
|
||||
QTreeWidgetItem *item = ui->groupTreeWidget->getItemFromId(QString::fromStdString(stats.mGrpId.toStdString()));
|
||||
|
||||
if (item)
|
||||
// ui->groupTreeWidget->setUnreadCount(item, mCountChildMsgs ? (stats.mNumThreadMsgsUnread + stats.mNumChildMsgsUnread) : stats.mNumThreadMsgsUnread);
|
||||
ui->groupTreeWidget->setCounts(item, mCountChildMsgs ? (stats.mNumThreadMsgsUnread + stats.mNumChildMsgsUnread) : stats.mNumThreadMsgsUnread, stats.mNumMsgs);
|
||||
|
||||
mCachedGroupStats[groupId] = stats;
|
||||
|
||||
getUserNotify()->updateIcon();
|
||||
|
||||
}, this );
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user