Make roomlist look nice

This commit is contained in:
Nicolas Werner 2021-05-21 21:19:03 +02:00
parent 10fd2752f9
commit cd67046f60
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
10 changed files with 265 additions and 45 deletions

View file

@ -723,6 +723,20 @@ TimelineModel::fetchMore(const QModelIndex &)
events.fetchMore();
}
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)
{
@ -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;
}
}