fixed notifications in posted

This commit is contained in:
csoler 2020-02-09 20:54:11 +01:00
parent 62c5cda7f0
commit 41a81fa5d1
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
3 changed files with 30 additions and 7 deletions

View File

@ -44,13 +44,6 @@ class p3Posted: public p3PostBase, public RsPosted
p3Posted(RsGeneralDataService* gds, RsNetworkExchangeService* nes, RsGixs* gixs);
virtual RsServiceInfo getServiceInfo();
protected:
virtual void notifyChanges(std::vector<RsGxsNotify*>& changes)
{
return p3PostBase::notifyChanges(changes);
}
public:
// Posted Specific DataTypes.

View File

@ -105,6 +105,11 @@ PostedListWidget::PostedListWidget(const RsGxsGroupId &postedId, QWidget *parent
/* load settings */
processSettings(true);
mEventHandlerId = 0;
// Needs to be asynced because this function is likely to be called by another thread!
rsEvents->registerEventsHandler(RsEventType::GXS_POSTED, [this](std::shared_ptr<const RsEvent> event) { RsQThreadUtils::postToObject( [=]() { handleEvent_main_thread(event); }, this ); }, mEventHandlerId );
/* Initialize GUI */
setGroupId(postedId);
}
@ -116,6 +121,28 @@ PostedListWidget::~PostedListWidget()
delete(ui);
}
void PostedListWidget::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
{
const RsGxsPostedEvent *e = dynamic_cast<const RsGxsPostedEvent*>(event.get());
if(!e)
return;
switch(e->mPostedEventCode)
{
case RsPostedEventCode::UPDATED_POSTED_GROUP:
case RsPostedEventCode::NEW_POSTED_GROUP:
case RsPostedEventCode::UPDATED_MESSAGE:
case RsPostedEventCode::NEW_MESSAGE:
if(e->mPostedGroupId == groupId())
updateDisplay(true);
break;
default:
break;
}
}
void PostedListWidget::processSettings(bool load)
{
Settings->beginGroup(QString("PostedListWidget"));

View File

@ -57,6 +57,8 @@ public:
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
protected:
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
/* GxsMessageFramePostWidget */
virtual bool insertGroupData(const uint32_t &token, RsGroupMetaData &metaData);
virtual void insertAllPosts(const uint32_t &token, GxsMessageFramePostThread *thread);
@ -126,6 +128,7 @@ private:
/* UI - from Designer */
Ui::PostedListWidget *ui;
RsEventsHandlerId_t mEventHandlerId ;
};
#endif