|
|
|
@ -648,8 +648,12 @@ ChatPage::loadStateFromCache() |
|
|
|
|
qDebug() << "Restored nextBatchToken" << cache_->nextBatchToken(); |
|
|
|
|
client_->setNextBatchToken(cache_->nextBatchToken()); |
|
|
|
|
|
|
|
|
|
// Fetch all the joined room's state.
|
|
|
|
|
auto rooms = cache_->states(); |
|
|
|
|
qRegisterMetaType<QMap<QString, RoomState>>(); |
|
|
|
|
|
|
|
|
|
QtConcurrent::run(cache_.data(), &Cache::states); |
|
|
|
|
|
|
|
|
|
connect(cache_.data(), &Cache::statesLoaded, this, [this](QMap<QString, RoomState> rooms) { |
|
|
|
|
qDebug() << "Cache data loaded"; |
|
|
|
|
|
|
|
|
|
for (auto it = rooms.constBegin(); it != rooms.constEnd(); ++it) { |
|
|
|
|
auto roomState = QSharedPointer<RoomState>(new RoomState(it.value())); |
|
|
|
@ -663,8 +667,8 @@ ChatPage::loadStateFromCache() |
|
|
|
|
roomStates_.insert(it.key(), roomState); |
|
|
|
|
|
|
|
|
|
// Create or restore the settings for this room.
|
|
|
|
|
roomSettings_.insert(it.key(), |
|
|
|
|
QSharedPointer<RoomSettings>(new RoomSettings(it.key()))); |
|
|
|
|
roomSettings_.insert( |
|
|
|
|
it.key(), QSharedPointer<RoomSettings>(new RoomSettings(it.key()))); |
|
|
|
|
|
|
|
|
|
// Resolve user avatars.
|
|
|
|
|
for (const auto membership : roomState->memberships) { |
|
|
|
@ -688,6 +692,7 @@ ChatPage::loadStateFromCache() |
|
|
|
|
|
|
|
|
|
// Start receiving events.
|
|
|
|
|
client_->sync(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void |
|
|
|
|