added NewsFeed item for advertising about new/removed moderators

This commit is contained in:
csoler 2020-04-27 15:11:32 +02:00
parent f7199f1f1c
commit 89843a6cbe
No known key found for this signature in database
GPG key ID: 7BCA522266C0804C
5 changed files with 111 additions and 12 deletions

View file

@ -20,6 +20,7 @@
#include "GxsForumGroupItem.h"
#include "ui_GxsForumGroupItem.h"
#include "gui/NewsFeed.h"
#include "FeedHolder.h"
#include "gui/RetroShareLink.h"
@ -37,6 +38,16 @@ GxsForumGroupItem::GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, co
requestGroup();
}
GxsForumGroupItem::GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, const std::list<RsGxsId>& added_moderators,const std::list<RsGxsId>& removed_moderators,bool isHome, bool autoUpdate):
GxsGroupFeedItem(feedHolder, feedId, groupId, isHome, rsGxsForums, autoUpdate),
mAddedModerators(added_moderators),
mRemovedModerators(removed_moderators)
{
setup();
requestGroup();
}
GxsForumGroupItem::GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsForumGroup &group, bool isHome, bool autoUpdate) :
GxsGroupFeedItem(feedHolder, feedId, group.mMeta.mGroupId, isHome, rsGxsForums, autoUpdate)
{
@ -158,10 +169,59 @@ void GxsForumGroupItem::fill()
ui->subscribeButton->setEnabled(true);
}
// if (mIsNew)
// {
if(feedId() == NEWSFEED_UPDATED_FORUM)
{
if(!mAddedModerators.empty() || !mRemovedModerators.empty())
{
ui->titleLabel->setText(tr("Moderator list changed"));
ui->moderatorList_GB->show();
QString msg;
if(!mAddedModerators.empty())
{
msg += "<b>Added moderators:</b>" ;
msg += "<p>";
for(auto& gxsid: mAddedModerators)
{
RsIdentityDetails det;
if(rsIdentity->getIdDetails(gxsid,det))
msg += QString::fromUtf8(det.mNickname.c_str())+" ("+QString::fromStdString(gxsid.toStdString())+"), ";
else
msg += QString("[Unknown name]") + " ("+QString::fromStdString(gxsid.toStdString())+"), ";
}
msg.resize(msg.size()-2);
msg += "</p>";
}
if(!mRemovedModerators.empty())
{
msg += "<b>Removed moderators:</b>" ;
msg += "<p>";
for(auto& gxsid: mRemovedModerators)
{
RsIdentityDetails det;
if( rsIdentity->getIdDetails(gxsid,det))
msg += QString::fromUtf8(det.mNickname.c_str())+" ("+QString::fromStdString(gxsid.toStdString())+"), ";
else
msg += QString("[Unknown name]") + " ("+QString::fromStdString(gxsid.toStdString())+"), ";
}
msg.resize(msg.size()-2);
msg += "</p>";
}
ui->moderatorList_TE->setText(msg);
}
else
{
ui->moderatorList_GB->hide();
ui->titleLabel->setText(tr("Forum updated"));
ui->moderatorList_GB->hide();
}
}
else
ui->titleLabel->setText(tr("New Forum"));
// }
// else
// {
// ui->titleLabel->setText(tr("Updated Forum"));