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

@ -251,14 +251,20 @@ void NewsFeed::handleForumEvent(std::shared_ptr<const RsEvent> event)
switch(pe->mForumEventCode)
{
case RsForumEventCode::MODERATOR_LIST_CHANGED:
addFeedItem(new GxsForumGroupItem(this, NEWSFEED_UPDATED_FORUM, pe->mForumGroupId,pe->mModeratorsAdded,pe->mModeratorsRemoved, false, true));
break;
case RsForumEventCode::UPDATED_FORUM:
case RsForumEventCode::NEW_FORUM:
addFeedItem(new GxsForumGroupItem(this, NEWSFEED_FORUMNEWLIST, pe->mForumGroupId, false, true));
addFeedItem(new GxsForumGroupItem(this, NEWSFEED_NEW_FORUM, pe->mForumGroupId, false, true));
break;
case RsForumEventCode::UPDATED_MESSAGE:
case RsForumEventCode::NEW_MESSAGE:
addFeedItem(new GxsForumMsgItem(this, NEWSFEED_FORUMNEWLIST, pe->mForumGroupId, pe->mForumMsgId, false, true));
addFeedItem(new GxsForumMsgItem(this, NEWSFEED_NEW_FORUM, pe->mForumGroupId, pe->mForumMsgId, false, true));
break;
default: break;
}
}

View File

@ -31,8 +31,10 @@
const uint32_t NEWSFEED_PEERLIST = 0x0001;
const uint32_t NEWSFEED_FORUMNEWLIST = 0x0002;
const uint32_t NEWSFEED_FORUMMSGLIST = 0x0003;
const uint32_t NEWSFEED_NEW_FORUM = 0x0002;
const uint32_t NEWSFEED_NEW_FORUM_MSG = 0x0003;
const uint32_t NEWSFEED_UPDATED_FORUM = 0x000f;
const uint32_t NEWSFEED_CHANNELNEWLIST = 0x0004;
//const uint32_t NEWSFEED_CHANNELMSGLIST = 0x0005;
#if 0

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"));

View File

@ -37,6 +37,7 @@ class GxsForumGroupItem : public GxsGroupFeedItem
public:
/** Default Constructor */
GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGroupId &groupId, bool isHome, bool autoUpdate);
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);
GxsForumGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsForumGroup &group, bool isHome, bool autoUpdate);
~GxsForumGroupItem();
@ -65,6 +66,9 @@ private:
/** Qt Designer generated object */
Ui::GxsForumGroupItem *ui;
std::list<RsGxsId> mAddedModerators;
std::list<RsGxsId> mRemovedModerators;
};
#endif

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>618</width>
<height>161</height>
<width>784</width>
<height>464</height>
</rect>
</property>
<layout class="QGridLayout">
@ -104,8 +104,8 @@
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QGridLayout">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout">
<item row="0" column="0" rowspan="2">
<widget class="QLabel" name="forumlogo_label">
@ -280,7 +280,7 @@
</item>
</layout>
</item>
<item row="1" column="0">
<item>
<widget class="QFrame" name="expandFrame">
<layout class="QVBoxLayout">
<property name="spacing">
@ -334,6 +334,33 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="moderatorList_GB">
<property name="title">
<string>Moderator list</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QTextEdit" name="moderatorList_TE"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>