mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
fixed notifications on circle not working due to cache reload failure. That circle cache code needs a real cleanup
This commit is contained in:
parent
ce6abe5d66
commit
65fa29e789
@ -103,7 +103,7 @@
|
||||
#define MIN_CIRCLE_LOAD_GAP 5
|
||||
#define GXS_CIRCLE_DELAY_TO_FORCE_MEMBERSHIP_UPDATE 60 // re-check every 1 mins. Normally this shouldn't be necessary since notifications inform abotu new messages.
|
||||
#define GXS_CIRCLE_DELAY_TO_CHECK_MEMBERSHIP_UPDATE 60 // re-check every 1 mins. Normally this shouldn't be necessary since notifications inform abotu new messages.
|
||||
#define GXS_CIRCLE_DELAY_TO_SEND_CACHE_UPDATED_EVENT 10 // do not send cache update events more often than every 10 secs.
|
||||
#define GXS_CIRCLE_DELAY_TO_SEND_CACHE_UPDATED_EVENT 2 // do not send cache update events more often than every 2 secs.
|
||||
|
||||
/********************************************************************************/
|
||||
/******************* Startup / Tick ******************************************/
|
||||
@ -532,6 +532,7 @@ void p3GxsCircles::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
||||
#endif
|
||||
|
||||
p3Notify *notify = RsServer::notify();
|
||||
std::set<RsGxsCircleId> circles_to_reload;
|
||||
|
||||
for(auto it = changes.begin(); it != changes.end(); ++it)
|
||||
{
|
||||
@ -576,6 +577,7 @@ void p3GxsCircles::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
||||
}
|
||||
|
||||
mCircleCache.erase(circle_id);
|
||||
circles_to_reload.insert(circle_id);
|
||||
mCacheUpdated = true;
|
||||
}
|
||||
|
||||
@ -608,6 +610,7 @@ void p3GxsCircles::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
||||
RsStackMutex stack(mCircleMtx); /********** STACK LOCKED MTX ******/
|
||||
mCircleCache.erase(RsGxsCircleId(*git));
|
||||
mCacheUpdated = true;
|
||||
circles_to_reload.insert(RsGxsCircleId(*git));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -686,6 +689,7 @@ void p3GxsCircles::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
||||
RsStackMutex stack(mCircleMtx); /********** STACK LOCKED MTX ******/
|
||||
mCircleCache.erase(RsGxsCircleId(*git));
|
||||
mCacheUpdated = true;
|
||||
circles_to_reload.insert(RsGxsCircleId(*git));
|
||||
}
|
||||
|
||||
}
|
||||
@ -693,6 +697,9 @@ void p3GxsCircles::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
||||
|
||||
delete c;
|
||||
}
|
||||
|
||||
for(auto& circle_id:circles_to_reload)
|
||||
force_cache_reload(circle_id);
|
||||
}
|
||||
|
||||
/********************************************************************************/
|
||||
|
@ -293,17 +293,35 @@ void NewsFeed::handleChannelEvent(std::shared_ptr<const RsEvent> event)
|
||||
}
|
||||
|
||||
void NewsFeed::handleCircleEvent(std::shared_ptr<const RsEvent> event)
|
||||
{
|
||||
// Gives the backend a few secs to load the cache data while not blocking the UI. This is not so nice, but there's no proper
|
||||
// other way to do that.
|
||||
|
||||
RsThread::async( [event,this]()
|
||||
{
|
||||
const RsGxsCircleEvent *pe = dynamic_cast<const RsGxsCircleEvent*>(event.get());
|
||||
if(!pe)
|
||||
return;
|
||||
|
||||
RsGxsCircleDetails details;
|
||||
|
||||
if(pe->mCircleId.isNull()) // probably an item for cache update
|
||||
return ;
|
||||
|
||||
if(!rsGxsCircles->getCircleDetails(pe->mCircleId,details))
|
||||
RsGxsCircleDetails details;
|
||||
bool loaded = false;
|
||||
|
||||
for(int i=0;i<5 && !loaded;++i)
|
||||
if(rsGxsCircles->getCircleDetails(pe->mCircleId,details))
|
||||
{
|
||||
std::cerr << "Cache item loaded for circle " << pe->mCircleId << std::endl;
|
||||
loaded = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Cache item for circle " << pe->mCircleId << " not loaded. Waiting " << i << "s" << std::endl;
|
||||
rstime::rs_usleep(1000*1000);
|
||||
}
|
||||
|
||||
if(!loaded)
|
||||
{
|
||||
std::cerr << "(EE) Cannot get information about circle " << pe->mCircleId << ". Not in cache?" << std::endl;
|
||||
return;
|
||||
@ -346,6 +364,10 @@ void NewsFeed::handleCircleEvent(std::shared_ptr<const RsEvent> event)
|
||||
// Note: In this case you're never an admin of the circle, since these notification
|
||||
// would be a direct consequence of your own actions.
|
||||
|
||||
RsQThreadUtils::postToObject( [event,details,this]()
|
||||
{
|
||||
const RsGxsCircleEvent *pe = static_cast<const RsGxsCircleEvent*>(event.get());
|
||||
|
||||
switch(pe->mCircleEventType)
|
||||
{
|
||||
case RsGxsCircleEventCode::CIRCLE_MEMBERSHIP_REQUEST:
|
||||
@ -385,6 +407,7 @@ void NewsFeed::handleCircleEvent(std::shared_ptr<const RsEvent> event)
|
||||
|
||||
default: break;
|
||||
}
|
||||
}, this ); }); // damn!
|
||||
}
|
||||
|
||||
void NewsFeed::handleConnectionEvent(std::shared_ptr<const RsEvent> event)
|
||||
|
@ -86,13 +86,13 @@ void GxsCircleItem::setup()
|
||||
RsGxsCircleDetails circleDetails;
|
||||
if (rsGxsCircles->getCircleDetails(mCircleId, circleDetails))
|
||||
{
|
||||
ui->nameLabel->setText(QString::fromUtf8(circleDetails.mCircleName.c_str()) + " (ID: " + QString::fromStdString(circleDetails.mCircleId.toStdString()) + ")");
|
||||
|
||||
// from here we can figure out if we already have requested membership or not
|
||||
|
||||
if (mType == RS_FEED_ITEM_CIRCLE_MEMB_REQ)
|
||||
{
|
||||
ui->titleLabel->setText(tr("You received a membership request a circle you're administrating:"));
|
||||
ui->nameLabel->setText(QString::fromUtf8(circleDetails.mCircleName.c_str()));
|
||||
ui->gxsIdLabel->setText(idName);
|
||||
ui->iconLabel->setPixmap(pixmap);
|
||||
ui->gxsIdLabel->setId(mGxsId);
|
||||
|
||||
@ -102,8 +102,6 @@ void GxsCircleItem::setup()
|
||||
else if (mType == RS_FEED_ITEM_CIRCLE_INVITE_REC)
|
||||
{
|
||||
ui->titleLabel->setText(tr("You received an invitation for this circle:"));
|
||||
ui->nameLabel->setText(QString::fromUtf8(circleDetails.mCircleName.c_str()));
|
||||
ui->gxsIdLabel->setText(idName);
|
||||
ui->iconLabel->setPixmap(pixmap);
|
||||
ui->gxsIdLabel->setId(mGxsId);
|
||||
|
||||
@ -114,8 +112,6 @@ void GxsCircleItem::setup()
|
||||
else if (mType == RS_FEED_ITEM_CIRCLE_MEMB_LEAVE)
|
||||
{
|
||||
ui->titleLabel->setText(idName + tr(" has left this circle."));
|
||||
ui->nameLabel->setText(QString::fromUtf8(circleDetails.mCircleName.c_str()));
|
||||
ui->gxsIdLabel->setText(idName);
|
||||
ui->iconLabel->setPixmap(pixmap);
|
||||
ui->gxsIdLabel->setId(mGxsId);
|
||||
|
||||
@ -125,8 +121,6 @@ void GxsCircleItem::setup()
|
||||
else if (mType == RS_FEED_ITEM_CIRCLE_MEMB_JOIN)
|
||||
{
|
||||
ui->titleLabel->setText(idName + tr(" which you invited, has join this circle you're administrating."));
|
||||
ui->nameLabel->setText(QString::fromUtf8(circleDetails.mCircleName.c_str()));
|
||||
ui->gxsIdLabel->setText(idName);
|
||||
ui->iconLabel->setPixmap(pixmap);
|
||||
ui->gxsIdLabel->setId(mGxsId);
|
||||
|
||||
@ -137,8 +131,6 @@ void GxsCircleItem::setup()
|
||||
{
|
||||
ui->titleLabel->setText(tr("Your identity %1 has been revoked from this circle.").arg(idName));
|
||||
|
||||
ui->nameLabel->setText(QString::fromUtf8(circleDetails.mCircleName.c_str()));
|
||||
ui->gxsIdLabel->setText(idName);
|
||||
ui->iconLabel->setPixmap(pixmap);
|
||||
ui->gxsIdLabel->setId(mGxsId);
|
||||
|
||||
@ -149,8 +141,6 @@ void GxsCircleItem::setup()
|
||||
{
|
||||
ui->titleLabel->setText(tr("Your identity %1 as been accepted in this circle.").arg(idName));
|
||||
|
||||
ui->nameLabel->setText(QString::fromUtf8(circleDetails.mCircleName.c_str()));
|
||||
ui->gxsIdLabel->setText(idName);
|
||||
ui->iconLabel->setPixmap(pixmap);
|
||||
ui->gxsIdLabel->setId(mGxsId);
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>618</width>
|
||||
<height>104</height>
|
||||
<height>172</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="GxsCircleItemGLayout">
|
||||
@ -104,8 +104,8 @@
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" rowspan="3">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="logoLabel">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
@ -130,12 +130,68 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="5">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="titleLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<italic>true</italic>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Circle msg</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="nameHLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Circle name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="nameLabel">
|
||||
<property name="text">
|
||||
<string notr="true">name</string>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="nameHSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="forLabel">
|
||||
<property name="text">
|
||||
<string>for identity</string>
|
||||
<string>Identity:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -180,7 +236,9 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="acceptButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
@ -200,7 +258,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="revokeButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
@ -220,7 +278,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<item>
|
||||
<widget class="QPushButton" name="expandButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
@ -240,7 +298,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="4">
|
||||
<item>
|
||||
<spacer name="tollbarHSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
@ -256,7 +314,7 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="5">
|
||||
<item>
|
||||
<widget class="QPushButton" name="clearButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
@ -276,50 +334,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="5">
|
||||
<layout class="QHBoxLayout" name="nameHLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="titleLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<italic>true</italic>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Circle</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="nameLabel">
|
||||
<property name="text">
|
||||
<string notr="true">name</string>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="nameHSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
@ -336,8 +351,8 @@
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../images.qrc"/>
|
||||
<include location="../icons.qrc"/>
|
||||
<include location="../images.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
Loading…
Reference in New Issue
Block a user