summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2020-10-28 13:06:28 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2020-10-28 13:06:28 +0100
commit70f35de449fdcbca2a4ecd1100e1fa614ad069b4 (patch)
treec104c06693424acf5660692ca520ee3475667ccc /src
parentFix ambiguous namespace on gcc7 (diff)
downloadnheko-70f35de449fdcbca2a4ecd1100e1fa614ad069b4.tar.xz
Don't pass around empty timeline
Diffstat (limited to 'src')
-rw-r--r--src/Cache.cpp16
-rw-r--r--src/Cache_p.h3
-rw-r--r--src/ChatPage.cpp2
-rw-r--r--src/ChatPage.h2
-rw-r--r--src/timeline/TimelineViewManager.cpp9
-rw-r--r--src/timeline/TimelineViewManager.h2
6 files changed, 15 insertions, 19 deletions
diff --git a/src/Cache.cpp b/src/Cache.cpp

index f187af62..b37f69b3 100644 --- a/src/Cache.cpp +++ b/src/Cache.cpp
@@ -1469,22 +1469,22 @@ Cache::getRoomInfo(const std::vector<std::string> &rooms) return room_info; } -std::map<QString, mtx::responses::Timeline> -Cache::roomMessages() +std::vector<QString> +Cache::roomIds() { auto txn = lmdb::txn::begin(env_, nullptr, MDB_RDONLY); - std::map<QString, mtx::responses::Timeline> msgs; + std::vector<QString> rooms; std::string room_id, unused; auto roomsCursor = lmdb::cursor::open(txn, roomsDb_); while (roomsCursor.get(room_id, unused, MDB_NEXT)) - msgs.emplace(QString::fromStdString(room_id), mtx::responses::Timeline()); + rooms.push_back(QString::fromStdString(room_id)); roomsCursor.close(); txn.commit(); - return msgs; + return rooms; } QMap<QString, mtx::responses::Notifications> @@ -3967,10 +3967,10 @@ setCurrentFormat() instance_->setCurrentFormat(); } -std::map<QString, mtx::responses::Timeline> -roomMessages() +std::vector<QString> +roomIds() { - return instance_->roomMessages(); + return instance_->roomIds(); } QMap<QString, mtx::responses::Notifications> diff --git a/src/Cache_p.h b/src/Cache_p.h
index 96000ae3..05e13128 100644 --- a/src/Cache_p.h +++ b/src/Cache_p.h
@@ -118,8 +118,7 @@ public: void setCurrentFormat(); bool runMigrations(); - std::map<QString, mtx::responses::Timeline> roomMessages(); - + std::vector<QString> roomIds(); QMap<QString, mtx::responses::Notifications> getTimelineMentions(); //! Retrieve all the user ids from a room. diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp
index fb34f91a..b587d521 100644 --- a/src/ChatPage.cpp +++ b/src/ChatPage.cpp
@@ -765,7 +765,7 @@ ChatPage::loadStateFromCache() cache::restoreSessions(); olm::client()->load(cache::restoreOlmAccount(), STORAGE_SECRET_KEY); - emit initializeEmptyViews(cache::client()->roomMessages()); + emit initializeEmptyViews(cache::client()->roomIds()); emit initializeRoomList(cache::roomInfo()); emit initializeMentions(cache::getTimelineMentions()); emit syncTags(cache::roomInfo().toStdMap()); diff --git a/src/ChatPage.h b/src/ChatPage.h
index da367c29..0c12d89f 100644 --- a/src/ChatPage.h +++ b/src/ChatPage.h
@@ -158,7 +158,7 @@ signals: void initializeRoomList(QMap<QString, RoomInfo>); void initializeViews(const mtx::responses::Rooms &rooms); - void initializeEmptyViews(const std::map<QString, mtx::responses::Timeline> &msgs); + void initializeEmptyViews(const std::vector<QString> &roomIds); void initializeMentions(const QMap<QString, mtx::responses::Notifications> &notifs); void syncUI(const mtx::responses::Rooms &rooms); void syncRoomlist(const std::map<QString, RoomInfo> &updates); diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp
index e79b86d7..858d1090 100644 --- a/src/timeline/TimelineViewManager.cpp +++ b/src/timeline/TimelineViewManager.cpp
@@ -451,13 +451,10 @@ TimelineViewManager::receivedSessionKey(const std::string &room_id, const std::s } void -TimelineViewManager::initWithMessages(const std::map<QString, mtx::responses::Timeline> &msgs) +TimelineViewManager::initWithMessages(const std::vector<QString> &roomIds) { - for (const auto &e : msgs) { - addRoom(e.first); - - models.value(e.first)->addEvents(e.second); - } + for (const auto &roomId : roomIds) + addRoom(roomId); } void diff --git a/src/timeline/TimelineViewManager.h b/src/timeline/TimelineViewManager.h
index 30bbc744..e42dd2f1 100644 --- a/src/timeline/TimelineViewManager.h +++ b/src/timeline/TimelineViewManager.h
@@ -94,7 +94,7 @@ signals: public slots: void updateReadReceipts(const QString &room_id, const std::vector<QString> &event_ids); void receivedSessionKey(const std::string &room_id, const std::string &session_id); - void initWithMessages(const std::map<QString, mtx::responses::Timeline> &msgs); + void initWithMessages(const std::vector<QString> &roomIds); void setHistoryView(const QString &room_id); void updateColorPalette();