From 6bae643b8e75d5d03f1a15773990315e4a1ab462 Mon Sep 17 00:00:00 2001 From: defnax Date: Fri, 14 Mar 2025 21:23:08 +0100 Subject: [PATCH] Added new Wire notify, for new joind users --- retroshare-gui/src/gui/NewsFeed.cpp | 7 +++-- .../src/gui/feeds/WireNotifyGroupItem.cpp | 31 +++++++++++++++++-- .../src/gui/feeds/WireNotifyGroupItem.h | 4 ++- .../src/gui/feeds/WireNotifyGroupItem.ui | 6 +++- .../src/gui/feeds/WireNotifyPostItem.cpp | 13 +++----- 5 files changed, 45 insertions(+), 16 deletions(-) diff --git a/retroshare-gui/src/gui/NewsFeed.cpp b/retroshare-gui/src/gui/NewsFeed.cpp index b9eff0c08..facb8458c 100644 --- a/retroshare-gui/src/gui/NewsFeed.cpp +++ b/retroshare-gui/src/gui/NewsFeed.cpp @@ -532,16 +532,19 @@ void NewsFeed::handleWireEvent(std::shared_ptr event) case RsWireEventCode::FOLLOW_STATUS_CHANGED: addFeedItem( new WireNotifyGroupItem(this, NEWSFEED_WIRELIST, pe->mWireGroupId, false, true)); break; + case RsWireEventCode::NEW_WIRE: + addFeedItem( new WireNotifyGroupItem(this, NEWSFEED_WIRELIST, pe->mWireGroupId, false, true)); + break; case RsWireEventCode::NEW_POST: addFeedItem( new WireNotifyPostItem(this, NEWSFEED_WIRELIST, pe->mWireGroupId, pe->mWireMsgId, false, true)); break; case RsWireEventCode::NEW_REPLY: addFeedItem( new WireNotifyPostItem(this, NEWSFEED_WIRELIST, pe->mWireGroupId, pe->mWireMsgId, false, true)); break; - case RsWireEventCode::NEW_LIKE: + case RsWireEventCode::NEW_REPUBLISH: addFeedItem( new WireNotifyPostItem(this, NEWSFEED_WIRELIST, pe->mWireGroupId, pe->mWireMsgId, false, true)); break; - case RsWireEventCode::NEW_REPUBLISH: + case RsWireEventCode::NEW_LIKE: addFeedItem( new WireNotifyPostItem(this, NEWSFEED_WIRELIST, pe->mWireGroupId, pe->mWireMsgId, false, true)); break; // case RsWireEventCode::WIRE_UPDATED: diff --git a/retroshare-gui/src/gui/feeds/WireNotifyGroupItem.cpp b/retroshare-gui/src/gui/feeds/WireNotifyGroupItem.cpp index 0bc40a517..1ee884167 100644 --- a/retroshare-gui/src/gui/feeds/WireNotifyGroupItem.cpp +++ b/retroshare-gui/src/gui/feeds/WireNotifyGroupItem.cpp @@ -36,20 +36,45 @@ WireNotifyGroupItem::WireNotifyGroupItem(FeedHolder *feedHolder, uint32_t feedId GxsGroupFeedItem(feedHolder, feedId, groupId, isHome, rsWire, autoUpdate) { setup(); - requestGroup(); + addEventHandler(); } WireNotifyGroupItem::WireNotifyGroupItem(FeedHolder *feedHolder, uint32_t feedId, const RsWireGroup &group, bool isHome, bool autoUpdate) : GxsGroupFeedItem(feedHolder, feedId, group.mMeta.mGroupId, isHome, rsWire, autoUpdate) { setup(); - setGroup(group); + addEventHandler(); +} + +void WireNotifyGroupItem::addEventHandler() +{ + mEventHandlerId = 0; + rsEvents->registerEventsHandler( [this](std::shared_ptr event) + { + RsQThreadUtils::postToObject([=]() + { + const auto *e = dynamic_cast(event.get()); + + if(!e || e->mWireGroupId != this->groupId()) + return; + + switch(e->mWireEventCode) + { + case RsWireEventCode::FOLLOW_STATUS_CHANGED: + case RsWireEventCode::WIRE_UPDATED: + break; + default: + break; + } + }, this ); + }, mEventHandlerId, RsEventType::WIRE ); } WireNotifyGroupItem::~WireNotifyGroupItem() { + rsEvents->unregisterEventsHandler(mEventHandlerId); delete(ui); } @@ -75,7 +100,7 @@ void WireNotifyGroupItem::setup() connect(ui->copyLinkButton, SIGNAL(clicked()), this, SLOT(copyGroupLink())); //ui->copyLinkButton->hide(); // No link type at this moment - + ui->nameLabel->setEnabled(false); ui->expandFrame->hide(); } diff --git a/retroshare-gui/src/gui/feeds/WireNotifyGroupItem.h b/retroshare-gui/src/gui/feeds/WireNotifyGroupItem.h index 7a401552a..e2ee46970 100644 --- a/retroshare-gui/src/gui/feeds/WireNotifyGroupItem.h +++ b/retroshare-gui/src/gui/feeds/WireNotifyGroupItem.h @@ -51,7 +51,7 @@ protected: /* GxsGroupFeedItem */ virtual QString groupName(); virtual void loadGroup() override; - virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_UNKNOWN; } + virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_WIRE; } private slots: void toggle() override; @@ -60,12 +60,14 @@ private slots: private: void fill(); void setup(); + void addEventHandler(); private: RsWireGroup mGroup; /** Qt Designer generated object */ Ui::WireNotifyGroupItem *ui; + RsEventsHandlerId_t mEventHandlerId; }; #endif // WIRENOTIFYGROUPITEM_H \ No newline at end of file diff --git a/retroshare-gui/src/gui/feeds/WireNotifyGroupItem.ui b/retroshare-gui/src/gui/feeds/WireNotifyGroupItem.ui index b85573091..7c3548c12 100644 --- a/retroshare-gui/src/gui/feeds/WireNotifyGroupItem.ui +++ b/retroshare-gui/src/gui/feeds/WireNotifyGroupItem.ui @@ -172,6 +172,7 @@ 11 + 75 true true @@ -186,6 +187,7 @@ 11 + 75 true true @@ -215,6 +217,7 @@ + 75 true @@ -227,6 +230,7 @@ + 75 true true @@ -252,7 +256,7 @@ Qt::NoFocus - Subscribe to Posted + <html><head/><body><p>Follow to User</p></body></html> Follow diff --git a/retroshare-gui/src/gui/feeds/WireNotifyPostItem.cpp b/retroshare-gui/src/gui/feeds/WireNotifyPostItem.cpp index 2f7da6a65..b4970e3d3 100644 --- a/retroshare-gui/src/gui/feeds/WireNotifyPostItem.cpp +++ b/retroshare-gui/src/gui/feeds/WireNotifyPostItem.cpp @@ -203,6 +203,7 @@ void WireNotifyPostItem::setup() ui->titleLabel->setMinimumWidth(100); ui->subjectLabel->setMinimumWidth(100); //ui->warning_label->setMinimumWidth(100); + ui->titleLabel->setEnabled(false); ui->feedFrame->setProperty("new", false); ui->feedFrame->style()->unpolish(ui->feedFrame); @@ -543,16 +544,14 @@ void WireNotifyPostItem::fill() removeItem(); } -// title = tr("Wire Feed") + ": "; -// RetroShareLink link = RetroShareLink::createGxsGroupLink(RetroShareLink::TYPE_WIRE, mPulse.mMeta.mGroupId, groupName()); -// title += link.toHtml(); -// ui->titleLabel->setText(title); - msgText = tr("Pulse") + ": "; RetroShareLink msgLink = RetroShareLink::createGxsMessageLink(RetroShareLink::TYPE_WIRE, mPulse.mMeta.mGroupId, mPulse.mMeta.mMsgId, messageName()); msgText += msgLink.toHtml(); ui->subjectLabel->setText(msgText); + ui->pulseMessage->setText(QString::fromUtf8(mPulse.mPulseText.c_str())); + ui->datetimelabel->setText(DateTime::formatLongDateTime(mPulse.mRefPublishTs)); + if (IS_GROUP_SUBSCRIBED(mGroupMeta.mSubscribeFlags) || IS_GROUP_ADMIN(mGroupMeta.mSubscribeFlags)) { ui->unsubscribeButton->setEnabled(true); @@ -571,8 +570,6 @@ void WireNotifyPostItem::fill() } else { - /* subject */ - ui->titleLabel->setText(QString::fromUtf8(mPulse.mMeta.mMsgName.c_str())); /* disable buttons: deletion facility not enabled with cache services yet */ ui->clearButton->setEnabled(false); @@ -645,8 +642,6 @@ void WireNotifyPostItem::fill() // if (wasExpanded() || ui->expandFrame->isVisible()) { // fillExpandFrame(); // } - ui->pulseMessage->setText(QString::fromUtf8(mPulse.mPulseText.c_str())); - ui->datetimelabel->setText(DateTime::formatLongDateTime(mPulse.mRefPublishTs)); // if ( (mPulse.mAttachmentCount != 0) || (mPulse.mSize != 0) ) { // ui->filelabel->setVisible(true);