mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-26 07:55:44 -04:00
fixed notifications in posted
This commit is contained in:
parent
62c5cda7f0
commit
41a81fa5d1
3 changed files with 30 additions and 7 deletions
|
@ -44,13 +44,6 @@ class p3Posted: public p3PostBase, public RsPosted
|
||||||
p3Posted(RsGeneralDataService* gds, RsNetworkExchangeService* nes, RsGixs* gixs);
|
p3Posted(RsGeneralDataService* gds, RsNetworkExchangeService* nes, RsGixs* gixs);
|
||||||
virtual RsServiceInfo getServiceInfo();
|
virtual RsServiceInfo getServiceInfo();
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
virtual void notifyChanges(std::vector<RsGxsNotify*>& changes)
|
|
||||||
{
|
|
||||||
return p3PostBase::notifyChanges(changes);
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Posted Specific DataTypes.
|
// Posted Specific DataTypes.
|
||||||
|
|
|
@ -105,6 +105,11 @@ PostedListWidget::PostedListWidget(const RsGxsGroupId &postedId, QWidget *parent
|
||||||
/* load settings */
|
/* load settings */
|
||||||
processSettings(true);
|
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 */
|
/* Initialize GUI */
|
||||||
setGroupId(postedId);
|
setGroupId(postedId);
|
||||||
}
|
}
|
||||||
|
@ -116,6 +121,28 @@ PostedListWidget::~PostedListWidget()
|
||||||
delete(ui);
|
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)
|
void PostedListWidget::processSettings(bool load)
|
||||||
{
|
{
|
||||||
Settings->beginGroup(QString("PostedListWidget"));
|
Settings->beginGroup(QString("PostedListWidget"));
|
||||||
|
|
|
@ -57,6 +57,8 @@ public:
|
||||||
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
|
||||||
|
|
||||||
/* GxsMessageFramePostWidget */
|
/* GxsMessageFramePostWidget */
|
||||||
virtual bool insertGroupData(const uint32_t &token, RsGroupMetaData &metaData);
|
virtual bool insertGroupData(const uint32_t &token, RsGroupMetaData &metaData);
|
||||||
virtual void insertAllPosts(const uint32_t &token, GxsMessageFramePostThread *thread);
|
virtual void insertAllPosts(const uint32_t &token, GxsMessageFramePostThread *thread);
|
||||||
|
@ -126,6 +128,7 @@ private:
|
||||||
|
|
||||||
/* UI - from Designer */
|
/* UI - from Designer */
|
||||||
Ui::PostedListWidget *ui;
|
Ui::PostedListWidget *ui;
|
||||||
|
RsEventsHandlerId_t mEventHandlerId ;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue