Don't use full dump for replies

This commit is contained in:
Nicolas Werner 2021-07-12 22:28:01 +02:00
parent f704e381c3
commit 9d6bc706ff
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9
3 changed files with 29 additions and 20 deletions

View File

@ -71,8 +71,6 @@ Item {
RowLayout { RowLayout {
id: row id: row
property var replyData: chat.model.getDump(replyTo, eventId)
anchors.rightMargin: 1 anchors.rightMargin: 1
anchors.leftMargin: Nheko.avatarSize + 16 anchors.leftMargin: Nheko.avatarSize + 16
anchors.left: parent.left anchors.left: parent.left
@ -87,26 +85,30 @@ Item {
// fancy reply, if this is a reply // fancy reply, if this is a reply
Reply { Reply {
function fromModel(role) {
return replyTo != "" ? room.dataById(replyTo, role) : null;
}
visible: replyTo visible: replyTo
userColor: TimelineManager.userColor(userId, Nheko.colors.base) userColor: TimelineManager.userColor(userId, Nheko.colors.base)
blurhash: row.replyData.blurhash ?? "" blurhash: fromModel(Room.Blurhash) ?? ""
body: row.replyData.body ?? "" body: fromModel(Room.Body) ?? ""
formattedBody: row.replyData.formattedBody ?? "" formattedBody: fromModel(Room.FormattedBody) ?? ""
eventId: row.replyData.eventId ?? "" eventId: fromModel(Room.EventId) ?? ""
filename: row.replyData.filename ?? "" filename: fromModel(Room.Filename) ?? ""
filesize: row.replyData.filesize ?? "" filesize: fromModel(Room.Filesize) ?? ""
proportionalHeight: row.replyData.proportionalHeight ?? 1 proportionalHeight: fromModel(Room.ProportionalHeight) ?? 1
type: row.replyData.type ?? MtxEvent.UnknownMessage type: fromModel(Room.Type) ?? MtxEvent.UnknownMessage
typeString: row.replyData.typeString ?? "" typeString: fromModel(Room.TypeString) ?? ""
url: row.replyData.url ?? "" url: fromModel(Room.Url) ?? ""
originalWidth: row.replyData.originalWidth ?? 0 originalWidth: fromModel(Room.OriginalWidth) ?? 0
isOnlyEmoji: row.replyData.isOnlyEmoji ?? false isOnlyEmoji: fromModel(Room.IsOnlyEmoji) ?? false
userId: row.replyData.userId ?? "" userId: fromModel(Room.UserId) ?? ""
userName: row.replyData.userName ?? "" userName: fromModel(Room.UserName) ?? ""
thumbnailUrl: row.replyData.thumbnailUrl ?? "" thumbnailUrl: fromModel(Room.ThumbnailUrl) ?? ""
roomTopic: row.replyData.roomTopic ?? "" roomTopic: fromModel(Room.RoomTopic) ?? ""
roomName: row.replyData.roomName ?? "" roomName: fromModel(Room.RoomName) ?? ""
callType: row.replyData.callType ?? "" callType: fromModel(Room.CallType) ?? ""
} }
// actual message content // actual message content

View File

@ -209,11 +209,16 @@ public:
CallType, CallType,
Dump, Dump,
}; };
Q_ENUM(Roles);
QHash<int, QByteArray> roleNames() const override; QHash<int, QByteArray> roleNames() const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override; int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
QVariant data(const mtx::events::collections::TimelineEvents &event, int role) const; 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; bool canFetchMore(const QModelIndex &) const override;
void fetchMore(const QModelIndex &) override; void fetchMore(const QModelIndex &) override;

View File

@ -178,6 +178,8 @@ TimelineViewManager::TimelineViewManager(CallManager *callManager, ChatPage *par
0, 0,
"RoomSettingsModel", "RoomSettingsModel",
"Room Settings needs to be instantiated on the C++ side"); "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; static auto self = this;
qmlRegisterSingletonType<MainWindow>( qmlRegisterSingletonType<MainWindow>(