mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-29 06:08:48 +03:00
Fix state reset command
This commit is contained in:
parent
6529240be8
commit
01915360b4
3 changed files with 11 additions and 3 deletions
|
@ -1669,7 +1669,7 @@ Cache::calculateRoomReadStatus(const std::string &room_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Cache::updateState(const std::string &room, const mtx::responses::StateEvents &state)
|
Cache::updateState(const std::string &room, const mtx::responses::StateEvents &state, bool wipe)
|
||||||
{
|
{
|
||||||
auto txn = lmdb::txn::begin(env_);
|
auto txn = lmdb::txn::begin(env_);
|
||||||
auto statesdb = getStatesDb(txn, room);
|
auto statesdb = getStatesDb(txn, room);
|
||||||
|
@ -1677,6 +1677,12 @@ Cache::updateState(const std::string &room, const mtx::responses::StateEvents &s
|
||||||
auto membersdb = getMembersDb(txn, room);
|
auto membersdb = getMembersDb(txn, room);
|
||||||
auto eventsDb = getEventsDb(txn, room);
|
auto eventsDb = getEventsDb(txn, room);
|
||||||
|
|
||||||
|
if (wipe) {
|
||||||
|
membersdb.drop(txn);
|
||||||
|
statesdb.drop(txn);
|
||||||
|
stateskeydb.drop(txn);
|
||||||
|
}
|
||||||
|
|
||||||
saveStateEvents(txn, statesdb, stateskeydb, membersdb, eventsDb, room, state.events);
|
saveStateEvents(txn, statesdb, stateskeydb, membersdb, eventsDb, room, state.events);
|
||||||
|
|
||||||
RoomInfo updatedInfo;
|
RoomInfo updatedInfo;
|
||||||
|
|
|
@ -118,7 +118,9 @@ public:
|
||||||
std::size_t len = 30);
|
std::size_t len = 30);
|
||||||
size_t memberCount(const std::string &room_id);
|
size_t memberCount(const std::string &room_id);
|
||||||
|
|
||||||
void updateState(const std::string &room, const mtx::responses::StateEvents &state);
|
void updateState(const std::string &room,
|
||||||
|
const mtx::responses::StateEvents &state,
|
||||||
|
bool wipe = false);
|
||||||
void saveState(const mtx::responses::Sync &res);
|
void saveState(const mtx::responses::Sync &res);
|
||||||
bool isInitialized();
|
bool isInitialized();
|
||||||
bool isDatabaseReady() { return databaseReady_ && isInitialized(); }
|
bool isDatabaseReady() { return databaseReady_ && isInitialized(); }
|
||||||
|
|
|
@ -496,7 +496,7 @@ TimelineModel::TimelineModel(TimelineViewManager *manager, QString room_id, QObj
|
||||||
showEventTimer.callOnTimeout(this, &TimelineModel::scrollTimerEvent);
|
showEventTimer.callOnTimeout(this, &TimelineModel::scrollTimerEvent);
|
||||||
|
|
||||||
connect(this, &TimelineModel::newState, this, [this](mtx::responses::StateEvents events_) {
|
connect(this, &TimelineModel::newState, this, [this](mtx::responses::StateEvents events_) {
|
||||||
cache::client()->updateState(room_id_.toStdString(), events_);
|
cache::client()->updateState(room_id_.toStdString(), events_, true);
|
||||||
this->syncState({std::move(events_.events)});
|
this->syncState({std::move(events_.events)});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue