mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
fixed model update when new vote is posted by user
This commit is contained in:
parent
364e9ffdd2
commit
0e4d438066
@ -115,6 +115,7 @@ enum class RsPostedEventCode: uint8_t
|
|||||||
UPDATED_MESSAGE = 0x05,
|
UPDATED_MESSAGE = 0x05,
|
||||||
READ_STATUS_CHANGED = 0x06,
|
READ_STATUS_CHANGED = 0x06,
|
||||||
STATISTICS_CHANGED = 0x07,
|
STATISTICS_CHANGED = 0x07,
|
||||||
|
MESSAGE_VOTES_UPDATED = 0x08,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -127,6 +128,7 @@ struct RsGxsPostedEvent: RsEvent
|
|||||||
RsPostedEventCode mPostedEventCode;
|
RsPostedEventCode mPostedEventCode;
|
||||||
RsGxsGroupId mPostedGroupId;
|
RsGxsGroupId mPostedGroupId;
|
||||||
RsGxsMessageId mPostedMsgId;
|
RsGxsMessageId mPostedMsgId;
|
||||||
|
RsGxsMessageId mPostedThreadId;
|
||||||
|
|
||||||
///* @see RsEvent @see RsSerializable
|
///* @see RsEvent @see RsSerializable
|
||||||
void serial_process( RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) override
|
void serial_process( RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) override
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
/****
|
/****
|
||||||
* #define POSTBASE_DEBUG 1
|
* #define POSTBASE_DEBUG 1
|
||||||
****/
|
****/
|
||||||
|
#define POSTBASE_DEBUG 1
|
||||||
|
|
||||||
#define POSTBASE_BACKGROUND_PROCESSING 0x0002
|
#define POSTBASE_BACKGROUND_PROCESSING 0x0002
|
||||||
#define PROCESSING_START_PERIOD 30
|
#define PROCESSING_START_PERIOD 30
|
||||||
@ -93,27 +94,49 @@ void p3PostBase::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
|||||||
|
|
||||||
if(msgChange)
|
if(msgChange)
|
||||||
{
|
{
|
||||||
#ifdef POSTBASE_DEBUG
|
|
||||||
std::cerr << "p3PostBase::notifyChanges() Found Message Change Notification";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef POSTBASE_DEBUG
|
|
||||||
std::cerr << "p3PostBase::notifyChanges() Msgs for Group: " << mit->first;
|
|
||||||
std::cerr << std::endl;
|
|
||||||
#endif
|
|
||||||
// To start with we are just going to trigger updates on these groups.
|
// To start with we are just going to trigger updates on these groups.
|
||||||
// FUTURE OPTIMISATION.
|
// FUTURE OPTIMISATION.
|
||||||
// It could be taken a step further and directly request these msgs for an update.
|
// It could be taken a step further and directly request these msgs for an update.
|
||||||
addGroupForProcessing(msgChange->mGroupId);
|
addGroupForProcessing(msgChange->mGroupId);
|
||||||
|
|
||||||
if (rsEvents && (msgChange->getType() == RsGxsNotify::TYPE_RECEIVED_NEW || msgChange->getType() == RsGxsNotify::TYPE_PUBLISHED))
|
if (rsEvents)
|
||||||
|
{
|
||||||
|
switch(msgChange->getType())
|
||||||
|
{
|
||||||
|
case RsGxsNotify::TYPE_RECEIVED_NEW:
|
||||||
|
case RsGxsNotify::TYPE_PUBLISHED:
|
||||||
|
{
|
||||||
|
auto ev = std::make_shared<RsGxsPostedEvent>();
|
||||||
|
ev->mPostedMsgId = msgChange->mMsgId;
|
||||||
|
ev->mPostedThreadId = msgChange->mNewMsgItem->meta.mThreadId;
|
||||||
|
ev->mPostedGroupId = msgChange->mGroupId;
|
||||||
|
ev->mPostedEventCode = RsPostedEventCode::NEW_MESSAGE;
|
||||||
|
rsEvents->postEvent(ev);
|
||||||
|
#ifdef POSTBASE_DEBUG
|
||||||
|
std::cerr << "p3PostBase::notifyChanges() Found Message Change Notification: NEW/PUBLISHED ID=" << msgChange->mMsgId << " in group " << msgChange->mGroupId << ", thread ID = " << msgChange->mNewMsgItem->meta.mThreadId << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RsGxsNotify::TYPE_PROCESSED:
|
||||||
{
|
{
|
||||||
auto ev = std::make_shared<RsGxsPostedEvent>();
|
auto ev = std::make_shared<RsGxsPostedEvent>();
|
||||||
ev->mPostedMsgId = msgChange->mMsgId;
|
ev->mPostedMsgId = msgChange->mMsgId;
|
||||||
ev->mPostedGroupId = msgChange->mGroupId;
|
ev->mPostedGroupId = msgChange->mGroupId;
|
||||||
ev->mPostedEventCode = RsPostedEventCode::NEW_MESSAGE;
|
ev->mPostedEventCode = RsPostedEventCode::MESSAGE_VOTES_UPDATED;
|
||||||
rsEvents->postEvent(ev);
|
rsEvents->postEvent(ev);
|
||||||
|
#ifdef POSTBASE_DEBUG
|
||||||
|
std::cerr << "p3PostBase::notifyChanges() Found Message Change Notification: PROCESSED ID=" << msgChange->mMsgId << " in group " << msgChange->mGroupId << std::endl;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
#ifdef POSTBASE_DEBUG
|
||||||
|
std::cerr << "p3PostBase::notifyChanges() Found Message Change Notification: type " << msgChange->getType() << " (ignored) " << msgChange->mMsgId << std::endl;
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ RsPostedPostsModel::RsPostedPostsModel(QObject *parent)
|
|||||||
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event)
|
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event)
|
||||||
{
|
{
|
||||||
RsQThreadUtils::postToObject([=](){ handleEvent_main_thread(event); }, this );
|
RsQThreadUtils::postToObject([=](){ handleEvent_main_thread(event); }, this );
|
||||||
}, mEventHandlerId, RsEventType::GXS_CHANNELS );
|
}, mEventHandlerId, RsEventType::GXS_POSTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
RsPostedPostsModel::~RsPostedPostsModel()
|
RsPostedPostsModel::~RsPostedPostsModel()
|
||||||
@ -72,6 +72,8 @@ void RsPostedPostsModel::handleEvent_main_thread(std::shared_ptr<const RsEvent>
|
|||||||
{
|
{
|
||||||
case RsPostedEventCode::UPDATED_MESSAGE:
|
case RsPostedEventCode::UPDATED_MESSAGE:
|
||||||
case RsPostedEventCode::READ_STATUS_CHANGED:
|
case RsPostedEventCode::READ_STATUS_CHANGED:
|
||||||
|
case RsPostedEventCode::MESSAGE_VOTES_UPDATED:
|
||||||
|
case RsPostedEventCode::NEW_MESSAGE:
|
||||||
{
|
{
|
||||||
// Normally we should just emit dataChanged() on the index of the data that has changed:
|
// Normally we should just emit dataChanged() on the index of the data that has changed:
|
||||||
//
|
//
|
||||||
@ -105,7 +107,10 @@ void RsPostedPostsModel::handleEvent_main_thread(std::shared_ptr<const RsEvent>
|
|||||||
{
|
{
|
||||||
mPosts[j] = posts[i];
|
mPosts[j] = posts[i];
|
||||||
|
|
||||||
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mFilteredPosts.size(),0,(void*)NULL));
|
//emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mFilteredPosts.size(),0,(void*)NULL));
|
||||||
|
|
||||||
|
preMods();
|
||||||
|
postMods();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},this);
|
},this);
|
||||||
|
Loading…
Reference in New Issue
Block a user