Explicitly reload data in delegates, if related events got loaded

This commit is contained in:
Nicolas Werner 2021-07-20 14:09:19 +02:00
parent 6d169cea7d
commit 88ed0fade7
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
7 changed files with 38 additions and 24 deletions

View file

@ -341,6 +341,7 @@ ScrollView {
required property var timestamp
required property int status
required property int index
required property int relatedEventCacheBuster
required property string previousMessageUserId
required property string day
required property string previousMessageDay
@ -446,6 +447,7 @@ ScrollView {
trustlevel: wrapper.trustlevel
timestamp: wrapper.timestamp
status: wrapper.status
relatedEventCacheBuster: wrapper.relatedEventCacheBuster
y: section.visible && section.active ? section.y + section.height : 0
HoverHandler {

View file

@ -40,6 +40,7 @@ Item {
required property int trustlevel
required property var timestamp
required property int status
required property int relatedEventCacheBuster
anchors.left: parent.left
anchors.right: parent.right
@ -90,25 +91,26 @@ Item {
}
visible: replyTo
userColor: replyTo, TimelineManager.userColor(userId, Nheko.colors.base)
blurhash: replyTo, fromModel(Room.Blurhash) ?? ""
body: replyTo, fromModel(Room.Body) ?? ""
formattedBody: replyTo, fromModel(Room.FormattedBody) ?? ""
userColor: r.relatedEventCacheBuster, TimelineManager.userColor(userId, Nheko.colors.base)
blurhash: r.relatedEventCacheBuster, fromModel(Room.Blurhash) ?? ""
body: r.relatedEventCacheBuster, fromModel(Room.Body) ?? ""
formattedBody: r.relatedEventCacheBuster, fromModel(Room.FormattedBody) ?? ""
eventId: fromModel(Room.EventId) ?? ""
filename: replyTo, fromModel(Room.Filename) ?? ""
filesize: replyTo, fromModel(Room.Filesize) ?? ""
proportionalHeight: replyTo, fromModel(Room.ProportionalHeight) ?? 1
type: replyTo, fromModel(Room.Type) ?? MtxEvent.UnknownMessage
typeString: replyTo, fromModel(Room.TypeString) ?? ""
url: replyTo, fromModel(Room.Url) ?? ""
originalWidth: replyTo, fromModel(Room.OriginalWidth) ?? 0
isOnlyEmoji: replyTo, fromModel(Room.IsOnlyEmoji) ?? false
userId: replyTo, fromModel(Room.UserId) ?? ""
userName: replyTo, fromModel(Room.UserName) ?? ""
thumbnailUrl: replyTo, fromModel(Room.ThumbnailUrl) ?? ""
roomTopic: replyTo, fromModel(Room.RoomTopic) ?? ""
roomName: replyTo, fromModel(Room.RoomName) ?? ""
callType: replyTo, fromModel(Room.CallType) ?? ""
filename: r.relatedEventCacheBuster, fromModel(Room.Filename) ?? ""
filesize: r.relatedEventCacheBuster, fromModel(Room.Filesize) ?? ""
proportionalHeight: r.relatedEventCacheBuster, fromModel(Room.ProportionalHeight) ?? 1
type: r.relatedEventCacheBuster, fromModel(Room.Type) ?? MtxEvent.UnknownMessage
typeString: r.relatedEventCacheBuster, fromModel(Room.TypeString) ?? ""
url: r.relatedEventCacheBuster, fromModel(Room.Url) ?? ""
originalWidth: r.relatedEventCacheBuster, fromModel(Room.OriginalWidth) ?? 0
isOnlyEmoji: r.relatedEventCacheBuster, fromModel(Room.IsOnlyEmoji) ?? false
userId: r.relatedEventCacheBuster, fromModel(Room.UserId) ?? ""
userName: r.relatedEventCacheBuster, fromModel(Room.UserName) ?? ""
thumbnailUrl: r.relatedEventCacheBuster, fromModel(Room.ThumbnailUrl) ?? ""
roomTopic: r.relatedEventCacheBuster, fromModel(Room.RoomTopic) ?? ""
roomName: r.relatedEventCacheBuster, fromModel(Room.RoomName) ?? ""
callType: r.relatedEventCacheBuster, fromModel(Room.CallType) ?? ""
relatedEventCacheBuster: r.relatedEventCacheBuster, fromModel(Room.RelatedEventCacheBuster) ?? 0
}
// actual message content
@ -134,6 +136,7 @@ Item {
roomTopic: r.roomTopic
roomName: r.roomName
callType: r.callType
relatedEventCacheBuster: r.relatedEventCacheBuster
isReply: false
}

View file

@ -29,6 +29,7 @@ Item {
required property string roomTopic
required property string roomName
required property string callType
required property int relatedEventCacheBuster
height: chooser.childrenRect.height
@ -301,7 +302,7 @@ Item {
body: formatted
isOnlyEmoji: false
isReply: d.isReply
formatted: room.formatPowerLevelEvent(d.eventId)
formatted: d.relatedEventCacheBuster, room.formatPowerLevelEvent(d.eventId)
}
}
@ -313,7 +314,7 @@ Item {
body: formatted
isOnlyEmoji: false
isReply: d.isReply
formatted: room.formatJoinRuleEvent(d.eventId)
formatted: d.relatedEventCacheBuster, room.formatJoinRuleEvent(d.eventId)
}
}
@ -325,7 +326,7 @@ Item {
body: formatted
isOnlyEmoji: false
isReply: d.isReply
formatted: room.formatHistoryVisibilityEvent(d.eventId)
formatted: d.relatedEventCacheBuster, room.formatHistoryVisibilityEvent(d.eventId)
}
}
@ -337,7 +338,7 @@ Item {
body: formatted
isOnlyEmoji: false
isReply: d.isReply
formatted: room.formatGuestAccessEvent(d.eventId)
formatted: d.relatedEventCacheBuster, room.formatGuestAccessEvent(d.eventId)
}
}
@ -349,7 +350,7 @@ Item {
body: formatted
isOnlyEmoji: false
isReply: d.isReply
formatted: room.formatMemberEvent(d.eventId)
formatted: d.relatedEventCacheBuster, room.formatMemberEvent(d.eventId)
}
}

View file

@ -30,6 +30,7 @@ Item {
property string roomTopic
property string roomName
property string callType
property int relatedEventCacheBuster
width: parent.width
height: replyContainer.height
@ -95,6 +96,7 @@ Item {
roomTopic: r.roomTopic
roomName: r.roomName
callType: r.callType
relatedEventCacheBuster: r.relatedEventCacheBuster
enabled: false
width: parent.width
isReply: true

View file

@ -122,7 +122,6 @@ Menu {
id: gridView
model: roomid ? TimelineManager.completerFor("stickers", roomid) : null
Layout.preferredHeight: cellHeight * 3.5
Layout.preferredWidth: stickersPerRow * stickerDimPad + 20
Layout.leftMargin: 4

View file

@ -344,6 +344,7 @@ TimelineModel::TimelineModel(TimelineViewManager *manager, QString room_id, QObj
&EventStore::dataChanged,
this,
[this](int from, int to) {
relatedEventCacheBuster++;
nhlog::ui()->debug(
"data changed {} to {}", events.size() - to - 1, events.size() - from - 1);
emit dataChanged(index(events.size() - to - 1, 0),
@ -443,6 +444,7 @@ TimelineModel::roleNames() const
{RoomTopic, "roomTopic"},
{CallType, "callType"},
{Dump, "dump"},
{RelatedEventCacheBuster, "relatedEventCacheBuster"},
};
}
int
@ -676,6 +678,8 @@ TimelineModel::data(const mtx::events::collections::TimelineEvents &event, int r
return QVariant(m);
}
case RelatedEventCacheBuster:
return relatedEventCacheBuster;
default:
return QVariant();
}

View file

@ -208,6 +208,7 @@ public:
RoomTopic,
CallType,
Dump,
RelatedEventCacheBuster,
};
Q_ENUM(Roles);
@ -400,6 +401,8 @@ private:
int notification_count = 0, highlight_count = 0;
unsigned int relatedEventCacheBuster = 0;
bool decryptDescription = true;
bool m_paginationInProgress = false;
bool isSpace_ = false;