fixed notifications in forums, posted and channels

This commit is contained in:
csoler 2020-01-27 21:38:57 +01:00
parent fb9282f588
commit 90bb6c0011
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
12 changed files with 74 additions and 33 deletions

View File

@ -656,8 +656,7 @@ void p3GxsTrans::notifyChanges(std::vector<RsGxsNotify*>& changes)
#ifdef DEBUG_GXSTRANS
std::cout << "p3GxsTrans::notifyChanges(...)" << std::endl;
#endif
for( std::vector<RsGxsNotify*>::const_iterator it = changes.begin();
it != changes.end(); ++it )
for( auto it = changes.begin(); it != changes.end(); ++it )
{
RsGxsGroupChange* grpChange = dynamic_cast<RsGxsGroupChange *>(*it);
RsGxsMsgChange* msgChange = dynamic_cast<RsGxsMsgChange *>(*it);
@ -697,8 +696,8 @@ void p3GxsTrans::notifyChanges(std::vector<RsGxsNotify*>& changes)
}
#endif
}
delete *it;
}
RsGxsIfaceHelper::receiveChanges(changes);
}
uint32_t p3GxsTrans::AuthenPolicy()

View File

@ -110,15 +110,10 @@ enum class RsForumEventCode: uint8_t
UNKNOWN = 0x00,
NEW_FORUM = 0x01, /// emitted when new forum is received
UPDATED_FORUM = 0x02, /// emitted when existing forum is updated
/// new message reeived in a particular forum
NEW_MESSAGE = 0x03,
/// existing message has been updated in a particular forum
UPDATED_MESSAGE = 0x04,
/// forum was subscribed or unsubscribed
SUBSCRIBE_STATUS_CHANGED = 0x05,
NEW_MESSAGE = 0x03, /// new message reeived in a particular forum
UPDATED_MESSAGE = 0x04, /// existing message has been updated in a particular forum
SUBSCRIBE_STATUS_CHANGED = 0x05, /// forum was subscribed or unsubscribed
READ_STATUS_CHANGED = 0x06, /// msg was read or marked unread
};
struct RsGxsForumEvent: RsEvent

View File

@ -76,6 +76,7 @@ enum class RsPostedEventCode: uint8_t
SUBSCRIBE_STATUS_CHANGED = 0x03,
UPDATED_POSTED_GROUP = 0x04,
UPDATED_MESSAGE = 0x05,
READ_STATUS_CHANGED = 0x06,
};

View File

@ -364,13 +364,11 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
}
/* shouldn't need to worry about groups - as they need to be subscribed to */
delete *it;
}
if(!unprocessedGroups.empty())
request_SpecificSubscribedGroups(unprocessedGroups);
// // the call below deletes changes and its content.
// RsGxsIfaceHelper::receiveChanges(changes);
}
void p3GxsChannels::service_tick()

View File

@ -477,8 +477,8 @@ void p3GxsCircles::notifyChanges(std::vector<RsGxsNotify *> &changes)
#endif
p3Notify *notify = RsServer::notify();
std::vector<RsGxsNotify *>::iterator it;
for(it = changes.begin(); it != changes.end(); ++it)
for(auto it = changes.begin(); it != changes.end(); ++it)
{
RsGxsGroupChange *groupChange = dynamic_cast<RsGxsGroupChange *>(*it);
RsGxsMsgChange *msgChange = dynamic_cast<RsGxsMsgChange *>(*it);
@ -605,8 +605,8 @@ void p3GxsCircles::notifyChanges(std::vector<RsGxsNotify *> &changes)
}
}
delete *it;
}
RsGxsIfaceHelper::receiveChanges(changes); // this clear up the vector and delete its elements
}
/********************************************************************************/

View File

@ -315,9 +315,9 @@ void p3GxsForums::notifyChanges(std::vector<RsGxsNotify *> &changes)
}
/* shouldn't need to worry about groups - as they need to be subscribed to */
}
RsGxsIfaceHelper::receiveChanges(changes);
delete *it;
}
}
void p3GxsForums::service_tick()
@ -861,12 +861,19 @@ void p3GxsForums::setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair&
uint32_t mask = GXS_SERV::GXS_MSG_STATUS_GUI_NEW | GXS_SERV::GXS_MSG_STATUS_GUI_UNREAD;
uint32_t status = GXS_SERV::GXS_MSG_STATUS_GUI_UNREAD;
if (read)
{
status = 0;
}
setMsgStatusFlags(token, msgId, status, mask);
if (rsEvents)
{
auto ev = std::make_shared<RsGxsForumEvent>();
ev->mForumMsgId = msgId.second;
ev->mForumGroupId = msgId.first;
ev->mForumEventCode = RsForumEventCode::READ_STATUS_CHANGED;
rsEvents->postEvent(ev);
}
}
/********************************************************************************************/

View File

@ -661,9 +661,9 @@ void p3IdService::notifyChanges(std::vector<RsGxsNotify *> &changes)
changes[i] = NULL ;
}
}
}
RsGxsIfaceHelper::receiveChanges(changes);
delete changes[i];
}
}
/********************************************************************************/

View File

@ -87,9 +87,7 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
std::cerr << std::endl;
#endif
std::vector<RsGxsNotify *>::iterator it;
for(it = changes.begin(); it != changes.end(); ++it)
for(auto it = changes.begin(); it != changes.end(); ++it)
{
RsGxsMsgChange *msgChange = dynamic_cast<RsGxsMsgChange *>(*it);
@ -173,8 +171,9 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
break;
}
}
delete *it;
}
receiveHelperChanges(changes);
#ifdef POSTBASE_DEBUG
std::cerr << "p3PostBase::notifyChanges() -> receiveChanges()";
@ -206,6 +205,15 @@ void p3PostBase::setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair&
setMsgStatusFlags(token, msgId, status, mask);
if (rsEvents)
{
auto ev = std::make_shared<RsGxsPostedEvent>();
ev->mPostedMsgId = msgId.second;
ev->mPostedGroupId = msgId.first;
ev->mPostedEventCode = RsPostedEventCode::READ_STATUS_CHANGED;
rsEvents->postEvent(ev);
}
}

View File

@ -60,14 +60,21 @@ void PostedDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
switch(e->mPostedEventCode)
{
case RsPostedEventCode::NEW_MESSAGE:
case RsPostedEventCode::NEW_POSTED_GROUP: // [[fallthrough]];
updateMessageSummaryList(e->mPostedGroupId);
break;
case RsPostedEventCode::UPDATED_MESSAGE: // [[fallthrough]];
updateDisplay(false);
break;
case RsPostedEventCode::READ_STATUS_CHANGED: // [[fallthrough]];
updateMessageSummaryList(e->mPostedGroupId);
break;
case RsPostedEventCode::NEW_POSTED_GROUP: // [[fallthrough]];
case RsPostedEventCode::SUBSCRIBE_STATUS_CHANGED: // [[fallthrough]];
updateDisplay(true);
break;
updateDisplay(true);
break;
default: break;
}
}

View File

@ -32,6 +32,7 @@
#include "gui/common/RSTreeWidget.h"
#include "gui/notifyqt.h"
#include "gui/common/UIStateHelper.h"
#include "gui/common/UserNotify.h"
#include "GxsCommentDialog.h"
//#define DEBUG_GROUPFRAMEDIALOG

View File

@ -64,12 +64,23 @@ void GxsChannelDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> ev
switch(e->mChannelEventCode)
{
case RsChannelEventCode::READ_STATUS_CHANGED:
case RsChannelEventCode::NEW_MESSAGE:
updateMessageSummaryList(e->mChannelGroupId);
break;
case RsChannelEventCode::UPDATED_MESSAGE: // [[fallthrough]];
updateDisplay(false);
break;
case RsChannelEventCode::READ_STATUS_CHANGED:
updateMessageSummaryList(e->mChannelGroupId);
break;
case RsChannelEventCode::NEW_CHANNEL: // [[fallthrough]];
case RsChannelEventCode::SUBSCRIBE_STATUS_CHANGED:
updateDisplay(true);
break;
default:
break;
}

View File

@ -59,7 +59,21 @@ void GxsForumsDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> eve
switch(e->mForumEventCode)
{
case RsForumEventCode::SUBSCRIBE_STATUS_CHANGED: updateDisplay(true);
case RsForumEventCode::NEW_MESSAGE:
updateMessageSummaryList(e->mForumGroupId);
break;
case RsForumEventCode::UPDATED_MESSAGE: // [[fallthrough]];
updateDisplay(false);
break;
case RsForumEventCode::READ_STATUS_CHANGED:
updateMessageSummaryList(e->mForumGroupId);
break;
case RsForumEventCode::NEW_FORUM: // [[fallthrough]];
case RsForumEventCode::SUBSCRIBE_STATUS_CHANGED:
updateDisplay(true);
break;
default:
break;