mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-22 21:34:32 -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);
|
setAutoDownload(false);
|
||||||
settingsChanged();
|
settingsChanged();
|
||||||
setGroupId(channelId);
|
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()
|
GxsChannelPostsWidget::~GxsChannelPostsWidget()
|
||||||
|
@ -712,6 +741,7 @@ bool GxsChannelPostsWidget::insertGroupData(const uint32_t &token, RsGroupMetaDa
|
||||||
{
|
{
|
||||||
insertChannelDetails(groups[0]);
|
insertChannelDetails(groups[0]);
|
||||||
metaData = groups[0].mMeta;
|
metaData = groups[0].mMeta;
|
||||||
|
mChannelGroupId = groups[0].mMeta.mGroupId;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -721,6 +751,7 @@ bool GxsChannelPostsWidget::insertGroupData(const uint32_t &token, RsGroupMetaDa
|
||||||
{
|
{
|
||||||
insertChannelDetails(distant_group);
|
insertChannelDetails(distant_group);
|
||||||
metaData = distant_group.mMeta;
|
metaData = distant_group.mMeta;
|
||||||
|
mChannelGroupId = distant_group.mMeta.mGroupId;
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,11 +97,14 @@ private:
|
||||||
void insertChannelPosts(std::vector<RsGxsChannelPost> &posts, GxsMessageFramePostThread *thread, bool related);
|
void insertChannelPosts(std::vector<RsGxsChannelPost> &posts, GxsMessageFramePostThread *thread, bool related);
|
||||||
|
|
||||||
void createPostItem(const RsGxsChannelPost &post, bool related);
|
void createPostItem(const RsGxsChannelPost &post, bool related);
|
||||||
|
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QAction *mAutoDownloadAction;
|
QAction *mAutoDownloadAction;
|
||||||
|
|
||||||
bool mUseThread;
|
bool mUseThread;
|
||||||
|
RsGxsGroupId mChannelGroupId;
|
||||||
|
RsEventsHandlerId_t mEventHandlerId ;
|
||||||
|
|
||||||
/* UI - from Designer */
|
/* UI - from Designer */
|
||||||
Ui::GxsChannelPostsWidget *ui;
|
Ui::GxsChannelPostsWidget *ui;
|
||||||
|
|
|
@ -432,6 +432,35 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget
|
||||||
#ifdef SUSPENDED_CODE
|
#ifdef SUSPENDED_CODE
|
||||||
ui->threadTreeWidget->enableColumnCustomize(true);
|
ui->threadTreeWidget->enableColumnCustomize(true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
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 GxsForumThreadWidget::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
|
||||||
|
{
|
||||||
|
if(event->mType == RsEventType::GXS_FORUMS)
|
||||||
|
{
|
||||||
|
const RsGxsForumEvent *e = dynamic_cast<const RsGxsForumEvent*>(event.get());
|
||||||
|
|
||||||
|
if(!e)
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch(e->mForumEventCode)
|
||||||
|
{
|
||||||
|
case RsGxsForumEvent::UPDATED_FORUM:
|
||||||
|
case RsGxsForumEvent::NEW_FORUM:
|
||||||
|
case RsGxsForumEvent::UPDATED_MESSAGE:
|
||||||
|
case RsGxsForumEvent::NEW_MESSAGE:
|
||||||
|
if(e->mForumGroupId == mForumGroup.mMeta.mGroupId)
|
||||||
|
updateDisplay(true);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsForumThreadWidget::blank()
|
void GxsForumThreadWidget::blank()
|
||||||
|
|
|
@ -172,6 +172,8 @@ private:
|
||||||
void updateMessageData(const RsGxsMessageId& msgId);
|
void updateMessageData(const RsGxsMessageId& msgId);
|
||||||
void updateForumDescription();
|
void updateForumDescription();
|
||||||
|
|
||||||
|
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RsGxsGroupId mLastForumID;
|
RsGxsGroupId mLastForumID;
|
||||||
RsGxsMessageId mThreadId;
|
RsGxsMessageId mThreadId;
|
||||||
|
@ -201,6 +203,7 @@ private:
|
||||||
QList<RsGxsMessageId> mSavedExpandedMessages;
|
QList<RsGxsMessageId> mSavedExpandedMessages;
|
||||||
|
|
||||||
Ui::GxsForumThreadWidget *ui;
|
Ui::GxsForumThreadWidget *ui;
|
||||||
|
RsEventsHandlerId_t mEventHandlerId;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GXSFORUMTHREADWIDGET_H
|
#endif // GXSFORUMTHREADWIDGET_H
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue