added up-to-date info about sync period in group data details (channels, boards, forums) and warning when the sync period is too small w.r.t. the date of last post

This commit is contained in:
csoler 2020-10-24 21:17:34 +02:00
parent 709b323b03
commit c30107c248
20 changed files with 331 additions and 183 deletions

View file

@ -1695,6 +1695,14 @@ void RsGenExchange::notifyReceivePublishKey(const RsGxsGroupId &grpId)
mNotifications.push_back(gc);
}
void RsGenExchange::notifyChangedGroupSyncParams(const RsGxsGroupId &grpId)
{
RS_STACK_MUTEX(mGenMtx);
RsGxsGroupChange* gc = new RsGxsGroupChange(RsGxsNotify::TYPE_GROUP_SYNC_PARAMETERS_UPDATED,grpId, false);
mNotifications.push_back(gc);
}
void RsGenExchange::notifyChangedGroupStats(const RsGxsGroupId &grpId)
{
RS_STACK_MUTEX(mGenMtx);

View file

@ -133,28 +133,29 @@ public:
/*!
* @param messages messages are deleted after function returns
*/
virtual void receiveNewMessages(std::vector<RsNxsMsg*>& messages);
virtual void receiveNewMessages(std::vector<RsNxsMsg*>& messages) override;
/*!
* @param groups groups are deleted after function returns
*/
virtual void receiveNewGroups(std::vector<RsNxsGrp*>& groups);
virtual void receiveNewGroups(std::vector<RsNxsGrp*>& groups) override;
/*!
* @param grpId group id
*/
virtual void notifyReceivePublishKey(const RsGxsGroupId &grpId);
virtual void notifyReceivePublishKey(const RsGxsGroupId &grpId) override;
virtual void notifyChangedGroupSyncParams(const RsGxsGroupId &grpId) override;
/*!
* \brief notifyReceiveDistantSearchResults
* Should be called when new search results arrive.
* \param grpId
*/
virtual void receiveDistantSearchResults(TurtleRequestId id,const RsGxsGroupId &grpId);
virtual void receiveDistantSearchResults(TurtleRequestId id,const RsGxsGroupId &grpId) override;
/*!
* @param grpId group id
*/
virtual void notifyChangedGroupStats(const RsGxsGroupId &grpId);
virtual void notifyChangedGroupStats(const RsGxsGroupId &grpId) override;
/** E: Observer implementation **/

View file

@ -446,6 +446,7 @@ int RsGxsNetService::tick()
should_notify = should_notify || !mNewMessagesToNotify.empty() ;
should_notify = should_notify || !mNewPublishKeysToNotify.empty() ;
should_notify = should_notify || !mNewStatsToNotify.empty() ;
should_notify = should_notify || !mNewGrpSyncParamsToNotify.empty() ;
}
if(should_notify)
@ -490,7 +491,7 @@ void RsGxsNetService::processObserverNotifications()
std::vector<RsNxsGrp*> grps_copy ;
std::vector<RsNxsMsg*> msgs_copy ;
std::set<RsGxsGroupId> stat_copy ;
std::set<RsGxsGroupId> keys_copy ;
std::set<RsGxsGroupId> keys_copy,grpss_copy ;
{
RS_STACK_MUTEX(mNxsMutex) ;
@ -499,11 +500,13 @@ void RsGxsNetService::processObserverNotifications()
msgs_copy = mNewMessagesToNotify ;
stat_copy = mNewStatsToNotify ;
keys_copy = mNewPublishKeysToNotify ;
grpss_copy = mNewGrpSyncParamsToNotify ;
mNewGroupsToNotify.clear() ;
mNewMessagesToNotify.clear() ;
mNewStatsToNotify.clear() ;
mNewPublishKeysToNotify.clear() ;
mNewGrpSyncParamsToNotify.clear() ;
}
if(!grps_copy.empty()) mObserver->receiveNewGroups (grps_copy);
@ -514,6 +517,9 @@ void RsGxsNetService::processObserverNotifications()
for(std::set<RsGxsGroupId>::const_iterator it(stat_copy.begin());it!=stat_copy.end();++it)
mObserver->notifyChangedGroupStats(*it);
for(std::set<RsGxsGroupId>::const_iterator it(grpss_copy.begin());it!=grpss_copy.end();++it)
mObserver->notifyChangedGroupSyncParams(*it);
}
void RsGxsNetService::rejectMessage(const RsGxsMessageId& msg_id)
@ -4740,6 +4746,10 @@ void RsGxsNetService::setSyncAge(const RsGxsGroupId &grpId, uint32_t age_in_secs
locked_resetClientTS(grpId);
IndicateConfigChanged();
// also send an event so that UI is updated
mNewGrpSyncParamsToNotify.insert(grpId);
}
}
void RsGxsNetService::setKeepAge(const RsGxsGroupId &grpId, uint32_t age_in_secs)

View file

@ -608,6 +608,7 @@ private:
std::vector<RsNxsMsg*> mNewMessagesToNotify ;
std::set<RsGxsGroupId> mNewStatsToNotify ;
std::set<RsGxsGroupId> mNewPublishKeysToNotify ;
std::set<RsGxsGroupId> mNewGrpSyncParamsToNotify ;
// Distant search result map
std::map<TurtleRequestId,std::map<RsGxsGroupId,RsGxsGroupSearchResults> > mDistantSearchResults ;

View file

@ -48,6 +48,7 @@ public:
TYPE_UPDATED = 0x07,
TYPE_MESSAGE_DELETED = 0x08,
TYPE_GROUP_DELETED = 0x09,
TYPE_GROUP_SYNC_PARAMETERS_UPDATED = 0x0a,
};
virtual NotifyType getType() = 0;

View file

@ -61,6 +61,11 @@ public:
*/
virtual void notifyReceivePublishKey(const RsGxsGroupId &grpId) = 0;
/*!
* \brief notifyChangedGroupSyncParams
* \param caled when a group sync parameter is updated
*/
virtual void notifyChangedGroupSyncParams(const RsGxsGroupId &grpId) = 0;
/*!
* @param grpId group id
*/

View file

@ -113,6 +113,7 @@ enum class RsChannelEventCode: uint8_t
READ_STATUS_CHANGED = 0x07, // existing message has been read or set to unread
RECEIVED_DISTANT_SEARCH_RESULT = 0x08, // result for the given group id available for the given turtle request id
STATISTICS_CHANGED = 0x09, // stats (nb of supplier friends, how many msgs they have etc) has changed
SYNC_PARAMETERS_UPDATED = 0x0a, // sync and storage times have changed
};
struct RsGxsChannelEvent: RsEvent

View file

@ -115,6 +115,7 @@ enum class RsForumEventCode: uint8_t
READ_STATUS_CHANGED = 0x06, /// msg was read or marked unread
STATISTICS_CHANGED = 0x07, /// suppliers and how many messages they have changed
MODERATOR_LIST_CHANGED = 0x08, /// forum moderation list has changed.
SYNC_PARAMETERS_UPDATED = 0x0a, /// sync and storage times have changed
};
struct RsGxsForumEvent: RsEvent

View file

@ -116,6 +116,7 @@ enum class RsPostedEventCode: uint8_t
READ_STATUS_CHANGED = 0x06,
STATISTICS_CHANGED = 0x07,
MESSAGE_VOTES_UPDATED = 0x08,
SYNC_PARAMETERS_UPDATED = 0x09,
};

View file

@ -309,6 +309,15 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
}
break;
case RsGxsNotify::TYPE_GROUP_SYNC_PARAMETERS_UPDATED:
{
auto ev = std::make_shared<RsGxsChannelEvent>();
ev->mChannelGroupId = grpChange->mGroupId;
ev->mChannelEventCode = RsChannelEventCode::SYNC_PARAMETERS_UPDATED;
rsEvents->postEvent(ev);
}
break;
case RsGxsNotify::TYPE_STATISTICS_CHANGED:
{
auto ev = std::make_shared<RsGxsChannelEvent>();

View file

@ -256,7 +256,16 @@ void p3GxsForums::notifyChanges(std::vector<RsGxsNotify *> &changes)
}
break;
case RsGxsNotify::TYPE_PUBLISHED:
case RsGxsNotify::TYPE_GROUP_SYNC_PARAMETERS_UPDATED:
{
auto ev = std::make_shared<RsGxsForumEvent>();
ev->mForumGroupId = grpChange->mGroupId;
ev->mForumEventCode = RsForumEventCode::SYNC_PARAMETERS_UPDATED;
rsEvents->postEvent(ev);
}
break;
case RsGxsNotify::TYPE_PUBLISHED:
case RsGxsNotify::TYPE_RECEIVED_NEW:
{
/* group received */

View file

@ -162,6 +162,15 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
}
break;
case RsGxsNotify::TYPE_GROUP_SYNC_PARAMETERS_UPDATED:
{
auto ev = std::make_shared<RsGxsPostedEvent>();
ev->mPostedGroupId = group_id;
ev->mPostedEventCode = RsPostedEventCode::SYNC_PARAMETERS_UPDATED;
rsEvents->postEvent(ev);
}
break;
case RsGxsNotify::TYPE_STATISTICS_CHANGED:
{
auto ev = std::make_shared<RsGxsPostedEvent>();