From a035d6542d4f0abcda8dfe648584881a272aff75 Mon Sep 17 00:00:00 2001 From: James Graham Date: Sat, 9 Dec 2023 15:30:19 +0000 Subject: [PATCH] Fix spoilers in roomlist subtitles Make sure spoilers aren't revealed in SubtitleRole like in LastEventRole then remove LastEventRole because it is no longer used --- src/models/roomlistmodel.cpp | 14 +++++--------- src/models/roomlistmodel.h | 1 - 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/models/roomlistmodel.cpp b/src/models/roomlistmodel.cpp index baef96f96..1b7b28d1b 100644 --- a/src/models/roomlistmodel.cpp +++ b/src/models/roomlistmodel.cpp @@ -174,10 +174,10 @@ void RoomListModel::connectRoomSignals(NeoChatRoom *room) refresh(room); }); connect(room, &Room::addedMessages, this, [this, room] { - refresh(room, {LastEventRole, SubtitleTextRole, LastActiveTimeRole}); + refresh(room, {SubtitleTextRole, LastActiveTimeRole}); }); connect(room, &Room::pendingEventMerged, this, [this, room] { - refresh(room, {LastEventRole, SubtitleTextRole}); + refresh(room, {SubtitleTextRole}); }); connect(room, &Room::unreadStatsChanged, this, &RoomListModel::refreshNotificationCount); connect(room, &Room::highlightCountChanged, this, &RoomListModel::refreshHighlightCount); @@ -332,12 +332,6 @@ QVariant RoomListModel::data(const QModelIndex &index, int role) const if (role == HighlightCountRole) { return room->highlightCount(); } - if (role == LastEventRole) { - if (room->lastEventIsSpoiler()) { - return QString(); - } - return room->lastEventToString(); - } if (role == LastActiveTimeRole) { return room->lastActiveTime(); } @@ -354,6 +348,9 @@ QVariant RoomListModel::data(const QModelIndex &index, int role) const return m_categoryVisibility.value(data(index, CategoryRole).toInt(), true); } if (role == SubtitleTextRole) { + if (room->lastEventIsSpoiler()) { + return QString(); + } return room->lastEventToString(Qt::PlainText, true); } if (role == AvatarImageRole) { @@ -396,7 +393,6 @@ QHash RoomListModel::roleNames() const roles[CategoryRole] = "category"; roles[NotificationCountRole] = "notificationCount"; roles[HighlightCountRole] = "highlightCount"; - roles[LastEventRole] = "lastEvent"; roles[LastActiveTimeRole] = "lastActiveTime"; roles[JoinStateRole] = "joinState"; roles[CurrentRoomRole] = "currentRoom"; diff --git a/src/models/roomlistmodel.h b/src/models/roomlistmodel.h index e1f5140b0..3c7d0ac05 100644 --- a/src/models/roomlistmodel.h +++ b/src/models/roomlistmodel.h @@ -69,7 +69,6 @@ public: CategoryRole, /**< The room category, e.g favourite. */ NotificationCountRole, /**< The number of notifications in the room. */ HighlightCountRole, /**< The number of highlighted messages in the room. */ - LastEventRole, /**< Text for the last event in the room. */ LastActiveTimeRole, /**< The timestamp of the last event sent in the room. */ JoinStateRole, /**< The local user's join state in the room. */ CurrentRoomRole, /**< The room object for the room. */