Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F128177
D108.1734934504.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
7 KB
Referenced Files
None
Subscribers
None
D108.1734934504.diff
View Options
diff --git a/src/contents/ui/RoomListViewItemDelegate.qml b/src/contents/ui/RoomListViewItemDelegate.qml
--- a/src/contents/ui/RoomListViewItemDelegate.qml
+++ b/src/contents/ui/RoomListViewItemDelegate.qml
@@ -30,7 +30,7 @@
property var lastUnreadMessageReaders: lastUnreadMessage ? lastUnreadMessage.readers() : null
// The readers count is to make hasUnreadMessages prop reactive
// against our newly-posted receipts
- property var hasUnreadMessages: getHasUnreadMessages(roomTimeline, roomTimeline.count, lastUnreadMessageReaders ? lastUnreadMessageReaders.count : 0)
+ property var hasUnreadMessages: getHasUnreadMessages(item, roomTimeline, roomTimeline.count, lastUnreadMessageReaders ? lastUnreadMessageReaders.count : 0)
onClicked: switchToRoomRequested(item.roomId)
checkable: true
@@ -77,13 +77,38 @@
}
Rectangle {
+ objectName: 'unreadNotificationCount'
+ Layout.alignment: Qt.AlignRight
+ Layout.rightMargin: Kirigami.Units.largeSpacing
+ Layout.preferredWidth: Math.max(unreadNotificationCountLabel.implicitWidth, Kirigami.Units.gridUnit)
+ Layout.preferredHeight: Kirigami.Units.gridUnit
+ radius: Kirigami.Units.gridUnit / 2
+ color: Kirigami.Theme.activeBackgroundColor
+ visible: !!item.unreadNotificationCount
+
+ RowLayout {
+ anchors.fill: parent
+ Label {
+ id: unreadNotificationCountLabel
+ Layout.alignment: Qt.AlignHCenter
+ color: Kirigami.Theme.activeTextColor
+ text: l10n.get('room-list-view-room-item-unread-notification-count', { count: item.unreadNotificationCount })
+ Accessible.ignored: true
+ }
+ }
+ Accessible.role: Accessible.Indicator
+ Accessible.name: l10n.get('room-list-view-room-item-unread-notification-count-text', { count: item.unreadNotificationCount })
+ }
+
+ Rectangle {
+ objectName: 'unreadIndicator'
Layout.alignment: Qt.AlignRight
Layout.rightMargin: Kirigami.Units.largeSpacing
Layout.preferredWidth: Kirigami.Units.iconSizes.small
Layout.preferredHeight: Kirigami.Units.iconSizes.small
radius: Kirigami.Units.iconSizes.small / 2
color: Kirigami.Theme.activeTextColor
- visible: hasUnreadMessages
+ visible: !item.unreadNotificationCount && hasUnreadMessages
Accessible.role: Accessible.Indicator
Accessible.name: l10n.get('room-list-view-room-item-unread-indicator')
}
@@ -111,8 +136,8 @@
room: item
}
- function getHasUnreadMessages(timeline, timelineCount, readersCount) {
- return !!getLastUnreadMessage(timeline, timelineCount);
+ function getHasUnreadMessages(room, timeline, timelineCount, readersCount) {
+ return !!room.unreadNotificationCount || !!getLastUnreadMessage(timeline, timelineCount);
}
function getLastUnreadMessage(timeline, timelineCount) {
diff --git a/src/l10n/cmn-Hans/100-ui.ftl b/src/l10n/cmn-Hans/100-ui.ftl
--- a/src/l10n/cmn-Hans/100-ui.ftl
+++ b/src/l10n/cmn-Hans/100-ui.ftl
@@ -57,6 +57,8 @@
room-list-view-room-item-title-id = 未命名房间({ $roomId })
room-list-view-room-item-fav-action = 设为最爱
room-list-view-room-item-unread-indicator = 未读
+room-list-view-room-item-unread-notification-count = { $count }
+room-list-view-room-item-unread-notification-count-text = { $count } 条未读通知
room-tags-fav-action-notification = 把 { $name } 设为了最爱
room-tags-fav-action-notification-failed = 不能把 { $name } 设为最爱。错误代码:{ $errorCode }。错误讯息:{ $errorMsg }。
room-tags-unfav-action-notification = 把 { $name } 从最爱中移除了
diff --git a/src/l10n/en/100-ui.ftl b/src/l10n/en/100-ui.ftl
--- a/src/l10n/en/100-ui.ftl
+++ b/src/l10n/en/100-ui.ftl
@@ -57,6 +57,12 @@
room-list-view-room-item-title-id = Unnamed room ({ $roomId })
room-list-view-room-item-fav-action = Set as favourite
room-list-view-room-item-unread-indicator = Unread
+room-list-view-room-item-unread-notification-count = { $count }
+room-list-view-room-item-unread-notification-count-text = { $count } unread {
+ $count ->
+ [1] message
+ *[other] messages
+ }
room-tags-fav-action-notification = Set { $name } as favourite
room-tags-fav-action-notification-failed = Cannot set { $name } as favourite. Error code: { $errorCode }. Error message: { $errorMsg }.
room-tags-unfav-action-notification = Removed { $name } from favourites
diff --git a/src/matrix-room.hpp b/src/matrix-room.hpp
--- a/src/matrix-room.hpp
+++ b/src/matrix-room.hpp
@@ -59,6 +59,7 @@
LAGER_QT_READER(QStringList, memberNames);
LAGER_QT_READER(QStringList, tagIds);
LAGER_QT_READER(Membership, membership);
+ LAGER_QT_READER(int, unreadNotificationCount);
Q_INVOKABLE MatrixRoomMember *memberAt(int index) const;
diff --git a/src/matrix-room.cpp b/src/matrix-room.cpp
--- a/src/matrix-room.cpp
+++ b/src/matrix-room.cpp
@@ -77,6 +77,7 @@
tagsMap);
}))
, LAGER_QT(membership)(m_room.membership().map([](const auto &membership) { return static_cast<Membership>(membership); }))
+ , LAGER_QT(unreadNotificationCount)(m_room.unreadNotificationEventIds().map([](const auto &cont) -> int { return cont.size(); }))
, m_setTypingThrottled(QFunctionUtils::Throttle([self=QPointer<MatrixRoom>(this)]() {
if (self) {
self->setTypingImpl();
diff --git a/src/tests/quick-tests/tst_RoomListViewItemDelegate.qml b/src/tests/quick-tests/tst_RoomListViewItemDelegate.qml
--- a/src/tests/quick-tests/tst_RoomListViewItemDelegate.qml
+++ b/src/tests/quick-tests/tst_RoomListViewItemDelegate.qml
@@ -21,14 +21,22 @@
property var roomInvite: Helpers.factory.room({
membership: MK.MatrixRoom.Invite,
+ unreadNotificationCount: 0,
})
property var roomJoin: Helpers.factory.room({
membership: MK.MatrixRoom.Join,
+ unreadNotificationCount: 0,
})
property var roomLeave: Helpers.factory.room({
membership: MK.MatrixRoom.Leave,
+ unreadNotificationCount: 0,
+ })
+
+ property var roomWithUnreadNotificationCount: Helpers.factory.room({
+ membership: MK.MatrixRoom.Join,
+ unreadNotificationCount: 2,
})
property var timelineUnread: QtObject {
@@ -189,6 +197,24 @@
}]
}
}
+
+ Kazv.RoomListViewItemDelegate {
+ id: delegateUnread
+ item: Object.assign({}, roomJoin, {
+ timeline () {
+ return timelineUnread;
+ },
+ })
+ }
+
+ Kazv.RoomListViewItemDelegate {
+ id: delegateWithUnreadNotifications
+ item: Object.assign({}, roomWithUnreadNotificationCount, {
+ timeline () {
+ return timelineUnread;
+ },
+ })
+ }
}
TestCase {
@@ -256,5 +282,13 @@
otherNum: 1,
}));
}
+
+ function test_unreadIndicators() {
+ verify(!findChild(delegateWithUnreadNotifications, 'unreadIndicator').visible);
+ verify(findChild(delegateWithUnreadNotifications, 'unreadNotificationCount').visible);
+
+ verify(findChild(delegateUnread, 'unreadIndicator').visible);
+ verify(!findChild(delegateUnread, 'unreadNotificationCount').visible);
+ }
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 22, 10:15 PM (18 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
48282
Default Alt Text
D108.1734934504.diff (7 KB)
Attached To
Mode
D108: Add unread notification count to room list view
Attached
Detach File
Event Timeline
Log In to Comment