Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F116514
D14.1733020363.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
D14.1733020363.diff
View Options
diff --git a/src/contents/ui/EventView.qml b/src/contents/ui/EventView.qml
--- a/src/contents/ui/EventView.qml
+++ b/src/contents/ui/EventView.qml
@@ -17,6 +17,8 @@
Item {
id: eventView
property var event
+ property var prevEvent
+ property var prevEventType: prevEvent ? getMessageType(prevEvent) : 'ignore'
property var sender
property var stateKeyUser
diff --git a/src/contents/ui/RoomTimelineView.qml b/src/contents/ui/RoomTimelineView.qml
--- a/src/contents/ui/RoomTimelineView.qml
+++ b/src/contents/ui/RoomTimelineView.qml
@@ -27,6 +27,7 @@
verticalLayoutDirection: ListView.BottomToTop
delegate: EventViewWrapper {
+ prevEvent: index < timeline.count - 1 ? timeline.at(index + 1) : undefined
event: timeline.at(index)
width: ListView.view.width
}
diff --git a/src/contents/ui/event-types/Simple.qml b/src/contents/ui/event-types/Simple.qml
--- a/src/contents/ui/event-types/Simple.qml
+++ b/src/contents/ui/event-types/Simple.qml
@@ -24,6 +24,17 @@
- 2 * Kirigami.Units.largeSpacing
)
}
+ property var shouldCollapseSender: (
+ !compactMode
+ && prevEventType
+ && prevEventType !== 'ignore'
+ && (
+ event.sender === prevEvent.sender
+ // local echo does not have a sender, will use the current user
+ || (!!event.isLocalEcho && !!prevEvent.isLocalEcho)
+ || (!!event.isLocalEcho && prevEvent.sender === matrixSdk.userId)
+ )
+ )
id: layout
RowLayout {
@@ -31,16 +42,18 @@
Layout.fillWidth: true
Layout.leftMargin: Kirigami.Units.largeSpacing
Layout.rightMargin: Kirigami.Units.largeSpacing
- Layout.topMargin: Kirigami.Units.largeSpacing
+ Layout.topMargin: shouldCollapseSender ? 0 : Kirigami.Units.largeSpacing
+ Layout.bottomMargin: 0
Kirigami.Avatar {
id: avatar
+ objectName: 'senderAvatar'
Layout.alignment: Qt.AlignTop
sourceSize.width: iconSize
sourceSize.height: iconSize
source: sender.avatarMxcUri ? matrixSdk.mxcUriToHttp(sender.avatarMxcUri) : ''
name: sender.name || sender.userId
- visible: !compactMode
+ visible: !compactMode && !shouldCollapseSender
TapHandler {
onTapped: {
@@ -49,11 +62,19 @@
}
}
+ Item {
+ objectName: 'senderCollapsedPlaceholder'
+ visible: shouldCollapseSender
+ Layout.preferredWidth: iconSize
+ Layout.preferredHeight: 1
+ }
+
ColumnLayout {
Layout.fillWidth: true
Layout.leftMargin: Kirigami.Units.largeSpacing
RowLayout {
+ visible: !shouldCollapseSender
Kirigami.Avatar {
id: avatarCompact
Layout.preferredWidth: Kirigami.Units.iconSizes.sizeForLabels
diff --git a/src/tests/quick-tests/tst_EventView.qml b/src/tests/quick-tests/tst_EventView.qml
--- a/src/tests/quick-tests/tst_EventView.qml
+++ b/src/tests/quick-tests/tst_EventView.qml
@@ -37,7 +37,9 @@
member: (_id) => ({}),
})
property var l10n: Helpers.fluentMock
- property var matrixSdk: TestHelpers.MatrixSdkMock {}
+ property var matrixSdk: TestHelpers.MatrixSdkMock {
+ property var userId: '@foo:tusooa.xyz'
+ }
property var kazvIOManager: TestHelpers.KazvIOManagerMock {}
property var localEcho: ({
eventId: '',
@@ -61,7 +63,7 @@
property var textEvent: ({
eventId: '',
- sender: '',
+ sender: '@foo:tusooa.xyz',
type: 'm.room.message',
stateKey: '',
content: {
@@ -73,7 +75,7 @@
property var htmlEvent: ({
eventId: '',
- sender: '',
+ sender: '@foo:tusooa.xyz',
type: 'm.room.message',
stateKey: '',
content: {
@@ -87,7 +89,7 @@
property var replyHtmlEvent: ({
eventId: '',
- sender: '',
+ sender: '@foo:tusooa.xyz',
type: 'm.room.message',
stateKey: '',
replyingToEventId: '$xxx',
@@ -102,7 +104,7 @@
property var replyNoQuoteHtmlEvent: ({
eventId: '',
- sender: '',
+ sender: '@foo:tusooa.xyz',
type: 'm.room.message',
stateKey: '',
replyingToEventId: '$xxx',
@@ -117,7 +119,7 @@
property var redactedEvent: ({
eventId: '',
- sender: '',
+ sender: '@foo:tusooa.xyz',
type: 'm.room.message',
stateKey: '',
content: {},
@@ -127,7 +129,7 @@
property var imageEvent: ({
eventId: '',
- sender: '',
+ sender: '@foo:tusooa.xyz',
type: 'm.room.message',
stateKey: '',
content: {
@@ -137,9 +139,34 @@
formattedTime: '4:06 P.M.',
})
+ property var eventBySomeoneElse: ({
+ eventId: '',
+ sender: '@bar:tusooa.xyz',
+ type: 'm.room.message',
+ stateKey: '',
+ content: {
+ msgtype: 'm.image',
+ body: 'some body',
+ },
+ formattedTime: '4:06 P.M.',
+ })
+
+ property var ignoredEvent: ({
+ eventId: '',
+ sender: '@foo:tusooa.xyz',
+ type: 'm.room.message',
+ relationType: 'm.replace',
+ stateKey: '',
+ content: {
+ msgtype: 'm.image',
+ body: 'some body',
+ },
+ formattedTime: '4:06 P.M.',
+ })
+
property var unknownTypeEvent: ({
eventId: '',
- sender: '',
+ sender: '@foo:tusooa.xyz',
type: 'moe.kazv.mxc.unknown.event',
stateKey: '',
content: {
@@ -150,7 +177,7 @@
property var unknownMsgtypeEvent: ({
eventId: '',
- sender: '',
+ sender: '@foo:tusooa.xyz',
type: 'm.room.message',
stateKey: '',
content: {
@@ -161,7 +188,7 @@
property var cannotDecryptEvent: ({
eventId: '',
- sender: '',
+ sender: '@foo:tusooa.xyz',
type: 'm.room.message',
stateKey: '',
content: {
@@ -245,6 +272,41 @@
event: item.cannotDecryptEvent
sender: item.sender
}
+
+ Kazv.EventView {
+ id: eventViewCollapseSameSender
+ event: item.imageEvent
+ sender: item.sender
+ prevEvent: item.redactedEvent
+ }
+
+ Kazv.EventView {
+ id: eventViewCollapseLocalEcho
+ event: item.localEcho
+ sender: item.sender
+ prevEvent: item.redactedEvent
+ }
+
+ Kazv.EventView {
+ id: eventViewDontCollapseDifferentSender
+ event: item.imageEvent
+ sender: item.sender
+ prevEvent: item.eventBySomeoneElse
+ }
+
+ Kazv.EventView {
+ id: eventViewDontCollapseLocalEchoDifferentSender
+ event: item.localEcho
+ sender: item.sender
+ prevEvent: item.eventBySomeoneElse
+ }
+
+ Kazv.EventView {
+ id: eventViewDontCollapseIgnoredEvent
+ event: item.imageEvent
+ sender: item.sender
+ prevEvent: item.ignoredEvent
+ }
}
TestCase {
@@ -343,5 +405,22 @@
verify(findChild(eventViewCannotDecrypt, 'textEventContent').text ===
l10n.get('event-cannot-decrypt-text'));
}
+
+ function test_collapseSender() {
+ verify(!findChild(eventViewCollapseSameSender, 'senderAvatar').visible);
+ verify(findChild(eventViewCollapseSameSender, 'senderCollapsedPlaceholder').visible);
+
+ verify(!findChild(eventViewCollapseLocalEcho, 'senderAvatar').visible);
+ verify(findChild(eventViewCollapseLocalEcho, 'senderCollapsedPlaceholder').visible);
+
+ verify(findChild(eventViewDontCollapseDifferentSender, 'senderAvatar').visible);
+ verify(!findChild(eventViewDontCollapseDifferentSender, 'senderCollapsedPlaceholder').visible);
+
+ verify(findChild(eventViewDontCollapseLocalEchoDifferentSender, 'senderAvatar').visible);
+ verify(!findChild(eventViewDontCollapseLocalEchoDifferentSender, 'senderCollapsedPlaceholder').visible);
+
+ verify(findChild(eventViewDontCollapseIgnoredEvent, 'senderAvatar').visible);
+ verify(!findChild(eventViewDontCollapseIgnoredEvent, 'senderCollapsedPlaceholder').visible);
+ }
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 30, 6:32 PM (15 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41774
Default Alt Text
D14.1733020363.diff (7 KB)
Attached To
Mode
D14: Collapse nickname and avatar of messages from the same sender
Attached
Detach File
Event Timeline
Log In to Comment