mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
fixed notifications in posted
This commit is contained in:
parent
62c5cda7f0
commit
41a81fa5d1
@ -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.
|
||||
|
@ -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"));
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user