aboutsummaryrefslogtreecommitdiff
path: root/lib/syncdata.cpp
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-02-13 19:25:24 +0100
committerAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-02-13 19:25:24 +0100
commit044ae4a029b710571420f830a497647f7a54698a (patch)
tree14d50ba0eb1a5cfac995f13cd6059aed74e506b2 /lib/syncdata.cpp
parentb0aef4af9cbf00755c7b70c71d77f0bf7ce0d200 (diff)
parent10ac7c13cdcd62b62af6e89cb726376cfbc53302 (diff)
downloadlibquotient-044ae4a029b710571420f830a497647f7a54698a.tar.gz
libquotient-044ae4a029b710571420f830a497647f7a54698a.zip
Merge branch 'dev'
The result is FTBFS as yet; next commits will fix that, along with a few other things.
Diffstat (limited to 'lib/syncdata.cpp')
-rw-r--r--lib/syncdata.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/syncdata.cpp b/lib/syncdata.cpp
index d0533fc9..78957cbe 100644
--- a/lib/syncdata.cpp
+++ b/lib/syncdata.cpp
@@ -219,14 +219,18 @@ void SyncData::parseJson(const QJsonObject& json, const QString& baseDir)
// We have a Qt container on the right and an STL one on the left
roomData.reserve(roomData.size() + static_cast<size_t>(rs.size()));
for (auto roomIt = rs.begin(); roomIt != rs.end(); ++roomIt) {
- auto roomJson =
- roomIt->isObject()
- ? roomIt->toObject()
- : loadJson(baseDir + fileNameForRoom(roomIt.key()));
- if (roomJson.isEmpty()) {
- unresolvedRoomIds.push_back(roomIt.key());
- continue;
- }
+ QJsonObject roomJson;
+ if (!baseDir.isEmpty()) {
+ // Loading data from the local cache, with room objects saved in
+ // individual files rather than inline
+ roomJson = loadJson(baseDir + fileNameForRoom(roomIt.key()));
+ if (roomJson.isEmpty()) {
+ unresolvedRoomIds.push_back(roomIt.key());
+ continue;
+ }
+ } else // When loading from /sync response, everything is inline
+ roomJson = roomIt->toObject();
+
roomData.emplace_back(roomIt.key(), joinState, roomJson);
const auto& r = roomData.back();
totalEvents += r.state.size() + r.ephemeral.size()