diff --git a/resources/qml/TimelineRow.qml b/resources/qml/TimelineRow.qml
index 53453e99..58e367a0 100644
--- a/resources/qml/TimelineRow.qml
+++ b/resources/qml/TimelineRow.qml
@@ -71,8 +71,6 @@ Item {
RowLayout {
id: row
- property var replyData: chat.model.getDump(replyTo, eventId)
-
anchors.rightMargin: 1
anchors.leftMargin: Nheko.avatarSize + 16
anchors.left: parent.left
@@ -87,26 +85,30 @@ Item {
// fancy reply, if this is a reply
Reply {
+ function fromModel(role) {
+ return replyTo != "" ? room.dataById(replyTo, role) : null;
+ }
+
visible: replyTo
userColor: TimelineManager.userColor(userId, Nheko.colors.base)
- blurhash: row.replyData.blurhash ?? ""
- body: row.replyData.body ?? ""
- formattedBody: row.replyData.formattedBody ?? ""
- eventId: row.replyData.eventId ?? ""
- filename: row.replyData.filename ?? ""
- filesize: row.replyData.filesize ?? ""
- proportionalHeight: row.replyData.proportionalHeight ?? 1
- type: row.replyData.type ?? MtxEvent.UnknownMessage
- typeString: row.replyData.typeString ?? ""
- url: row.replyData.url ?? ""
- originalWidth: row.replyData.originalWidth ?? 0
- isOnlyEmoji: row.replyData.isOnlyEmoji ?? false
- userId: row.replyData.userId ?? ""
- userName: row.replyData.userName ?? ""
- thumbnailUrl: row.replyData.thumbnailUrl ?? ""
- roomTopic: row.replyData.roomTopic ?? ""
- roomName: row.replyData.roomName ?? ""
- callType: row.replyData.callType ?? ""
+ blurhash: fromModel(Room.Blurhash) ?? ""
+ body: fromModel(Room.Body) ?? ""
+ formattedBody: fromModel(Room.FormattedBody) ?? ""
+ eventId: fromModel(Room.EventId) ?? ""
+ filename: fromModel(Room.Filename) ?? ""
+ filesize: fromModel(Room.Filesize) ?? ""
+ proportionalHeight: fromModel(Room.ProportionalHeight) ?? 1
+ type: fromModel(Room.Type) ?? MtxEvent.UnknownMessage
+ typeString: fromModel(Room.TypeString) ?? ""
+ url: fromModel(Room.Url) ?? ""
+ originalWidth: fromModel(Room.OriginalWidth) ?? 0
+ isOnlyEmoji: fromModel(Room.IsOnlyEmoji) ?? false
+ userId: fromModel(Room.UserId) ?? ""
+ userName: fromModel(Room.UserName) ?? ""
+ thumbnailUrl: fromModel(Room.ThumbnailUrl) ?? ""
+ roomTopic: fromModel(Room.RoomTopic) ?? ""
+ roomName: fromModel(Room.RoomName) ?? ""
+ callType: fromModel(Room.CallType) ?? ""
}
// actual message content
diff --git a/src/timeline/TimelineModel.h b/src/timeline/TimelineModel.h
index 46153732..a3c973d6 100644
--- a/src/timeline/TimelineModel.h
+++ b/src/timeline/TimelineModel.h
@@ -209,11 +209,16 @@ public:
CallType,
Dump,
};
+ Q_ENUM(Roles);
QHash<int, QByteArray> roleNames() const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
QVariant data(const mtx::events::collections::TimelineEvents &event, int role) const;
+ Q_INVOKABLE QVariant dataById(QString id, int role)
+ {
+ return data(index(idToIndex(id)), role);
+ }
bool canFetchMore(const QModelIndex &) const override;
void fetchMore(const QModelIndex &) override;
diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp
index a45294d1..a6fc674e 100644
--- a/src/timeline/TimelineViewManager.cpp
+++ b/src/timeline/TimelineViewManager.cpp
@@ -178,6 +178,8 @@ TimelineViewManager::TimelineViewManager(CallManager *callManager, ChatPage *par
0,
"RoomSettingsModel",
"Room Settings needs to be instantiated on the C++ side");
+ qmlRegisterUncreatableType<TimelineModel>(
+ "im.nheko", 1, 0, "Room", "Room needs to be instantiated on the C++ side");
static auto self = this;
qmlRegisterSingletonType<MainWindow>(
|