diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp
index 8df17457..19c3fb30 100644
--- a/src/timeline/TimelineModel.cpp
+++ b/src/timeline/TimelineModel.cpp
@@ -724,6 +724,20 @@ TimelineModel::fetchMore(const QModelIndex &)
}
void
+TimelineModel::sync(const mtx::responses::JoinedRoom &room)
+{
+ this->syncState(room.state);
+ this->addEvents(room.timeline);
+
+ if (room.unread_notifications.highlight_count != highlight_count ||
+ room.unread_notifications.notification_count != notification_count) {
+ notification_count = room.unread_notifications.notification_count;
+ highlight_count = room.unread_notifications.highlight_count;
+ emit notificationsChanged();
+ }
+}
+
+void
TimelineModel::syncState(const mtx::responses::State &s)
{
using namespace mtx::events;
@@ -866,14 +880,18 @@ TimelineModel::updateLastMessage()
if (std::visit([](const auto &e) -> bool { return isYourJoin(e); }, *event)) {
auto time = mtx::accessors::origin_server_ts(*event);
uint64_t ts = time.toMSecsSinceEpoch();
- emit manager_->updateRoomsLastMessage(
- room_id_,
+ auto description =
DescInfo{QString::fromStdString(mtx::accessors::event_id(*event)),
QString::fromStdString(http::client()->user_id().to_string()),
tr("You joined this room."),
utils::descriptiveTime(time),
ts,
- time});
+ time};
+ if (description != lastMessage_) {
+ lastMessage_ = description;
+ emit manager_->updateRoomsLastMessage(room_id_, lastMessage_);
+ emit lastMessageChanged();
+ }
return;
}
if (!std::visit([](const auto &e) -> bool { return isMessage(e); }, *event))
@@ -884,7 +902,11 @@ TimelineModel::updateLastMessage()
QString::fromStdString(http::client()->user_id().to_string()),
cache::displayName(room_id_,
QString::fromStdString(mtx::accessors::sender(*event))));
- emit manager_->updateRoomsLastMessage(room_id_, description);
+ if (description != lastMessage_) {
+ lastMessage_ = description;
+ emit manager_->updateRoomsLastMessage(room_id_, description);
+ emit lastMessageChanged();
+ }
return;
}
}
|