diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp index 594a41c2..e5d4c9be 100644 --- a/src/ChatPage.cpp +++ b/src/ChatPage.cpp @@ -566,7 +566,7 @@ ChatPage::ChatPage(QSharedPointer userSettings, QWidget *parent) connect(this, &ChatPage::initializeViews, view_manager_, - [this](const mtx::responses::Rooms &rooms) { view_manager_->initialize(rooms); }); + [this](const mtx::responses::Rooms &rooms) { view_manager_->sync(rooms); }); connect(this, &ChatPage::initializeEmptyViews, view_manager_, @@ -582,7 +582,7 @@ ChatPage::ChatPage(QSharedPointer userSettings, QWidget *parent) nhlog::db()->error("failed to retrieve invites: {}", e.what()); } - view_manager_->initialize(rooms); + view_manager_->sync(rooms); removeLeftRooms(rooms.leave); bool hasNotifications = false; diff --git a/src/timeline2/TimelineViewManager.cpp b/src/timeline2/TimelineViewManager.cpp index eed0682d..4ec089fa 100644 --- a/src/timeline2/TimelineViewManager.cpp +++ b/src/timeline2/TimelineViewManager.cpp @@ -27,9 +27,10 @@ TimelineViewManager::TimelineViewManager(QWidget *parent) } void -TimelineViewManager::initialize(const mtx::responses::Rooms &rooms) +TimelineViewManager::sync(const mtx::responses::Rooms &rooms) { for (auto it = rooms.join.cbegin(); it != rooms.join.cend(); ++it) { + // addRoom will only add the room, if it doesn't exist addRoom(QString::fromStdString(it->first)); models.value(QString::fromStdString(it->first))->addEvents(it->second.timeline); } diff --git a/src/timeline2/TimelineViewManager.h b/src/timeline2/TimelineViewManager.h index 687ae24e..9fcbc2f8 100644 --- a/src/timeline2/TimelineViewManager.h +++ b/src/timeline2/TimelineViewManager.h @@ -28,10 +28,9 @@ public: TimelineViewManager(QWidget *parent = 0); QWidget *getWidget() const { return container; } - void initialize(const mtx::responses::Rooms &rooms); + void sync(const mtx::responses::Rooms &rooms); void addRoom(const QString &room_id); - void sync(const mtx::responses::Rooms &rooms) {} void clearAll() { models.clear(); } Q_INVOKABLE TimelineModel *activeTimeline() const { return timeline_; }