mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-31 10:19:24 -04:00
added notifications for channel posts
This commit is contained in:
parent
a54cf981a6
commit
c348366eef
4 changed files with 66 additions and 0 deletions
|
@ -128,6 +128,35 @@ GxsChannelPostsWidget::GxsChannelPostsWidget(const RsGxsGroupId &channelId, QWid
|
|||
setAutoDownload(false);
|
||||
settingsChanged();
|
||||
setGroupId(channelId);
|
||||
|
||||
mEventHandlerId = 0;
|
||||
// Needs to be asynced because this function is likely to be called by another thread!
|
||||
|
||||
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject( [=]() { handleEvent_main_thread(event); }, this ); }, mEventHandlerId );
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidget::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
|
||||
{
|
||||
if(event->mType == RsEventType::GXS_CHANNELS)
|
||||
{
|
||||
const RsGxsChannelEvent *e = dynamic_cast<const RsGxsChannelEvent*>(event.get());
|
||||
|
||||
if(!e)
|
||||
return;
|
||||
|
||||
switch(e->mChannelEventCode)
|
||||
{
|
||||
case RsGxsChannelEvent::UPDATED_CHANNEL:
|
||||
case RsGxsChannelEvent::NEW_CHANNEL:
|
||||
case RsGxsChannelEvent::UPDATED_MESSAGE:
|
||||
case RsGxsChannelEvent::NEW_MESSAGE:
|
||||
if(e->mChannelGroupId == mChannelGroupId)
|
||||
updateDisplay(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GxsChannelPostsWidget::~GxsChannelPostsWidget()
|
||||
|
@ -712,6 +741,7 @@ bool GxsChannelPostsWidget::insertGroupData(const uint32_t &token, RsGroupMetaDa
|
|||
{
|
||||
insertChannelDetails(groups[0]);
|
||||
metaData = groups[0].mMeta;
|
||||
mChannelGroupId = groups[0].mMeta.mGroupId;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
@ -721,6 +751,7 @@ bool GxsChannelPostsWidget::insertGroupData(const uint32_t &token, RsGroupMetaDa
|
|||
{
|
||||
insertChannelDetails(distant_group);
|
||||
metaData = distant_group.mMeta;
|
||||
mChannelGroupId = distant_group.mMeta.mGroupId;
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,11 +97,14 @@ private:
|
|||
void insertChannelPosts(std::vector<RsGxsChannelPost> &posts, GxsMessageFramePostThread *thread, bool related);
|
||||
|
||||
void createPostItem(const RsGxsChannelPost &post, bool related);
|
||||
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
|
||||
|
||||
private:
|
||||
QAction *mAutoDownloadAction;
|
||||
|
||||
bool mUseThread;
|
||||
RsGxsGroupId mChannelGroupId;
|
||||
RsEventsHandlerId_t mEventHandlerId ;
|
||||
|
||||
/* UI - from Designer */
|
||||
Ui::GxsChannelPostsWidget *ui;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue