Fix replies not reloading after fetching them

This commit is contained in:
Nicolas Werner 2021-07-16 11:47:49 +02:00
parent b453b65787
commit 0b864d9485
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
3 changed files with 28 additions and 23 deletions

View file

@ -86,29 +86,29 @@ Item {
// fancy reply, if this is a reply // fancy reply, if this is a reply
Reply { Reply {
function fromModel(role) { function fromModel(role) {
return replyTo != "" ? room.dataById(replyTo, role) : null; return replyTo != "" ? room.dataById(replyTo, role, r.eventId) : null;
} }
visible: replyTo visible: replyTo
userColor: TimelineManager.userColor(userId, Nheko.colors.base) userColor: replyTo, TimelineManager.userColor(userId, Nheko.colors.base)
blurhash: fromModel(Room.Blurhash) ?? "" blurhash: replyTo, fromModel(Room.Blurhash) ?? ""
body: fromModel(Room.Body) ?? "" body: replyTo, fromModel(Room.Body) ?? ""
formattedBody: fromModel(Room.FormattedBody) ?? "" formattedBody: replyTo, fromModel(Room.FormattedBody) ?? ""
eventId: fromModel(Room.EventId) ?? "" eventId: fromModel(Room.EventId) ?? ""
filename: fromModel(Room.Filename) ?? "" filename: replyTo, fromModel(Room.Filename) ?? ""
filesize: fromModel(Room.Filesize) ?? "" filesize: replyTo, fromModel(Room.Filesize) ?? ""
proportionalHeight: fromModel(Room.ProportionalHeight) ?? 1 proportionalHeight: replyTo, fromModel(Room.ProportionalHeight) ?? 1
type: fromModel(Room.Type) ?? MtxEvent.UnknownMessage type: replyTo, fromModel(Room.Type) ?? MtxEvent.UnknownMessage
typeString: fromModel(Room.TypeString) ?? "" typeString: replyTo, fromModel(Room.TypeString) ?? ""
url: fromModel(Room.Url) ?? "" url: replyTo, fromModel(Room.Url) ?? ""
originalWidth: fromModel(Room.OriginalWidth) ?? 0 originalWidth: replyTo, fromModel(Room.OriginalWidth) ?? 0
isOnlyEmoji: fromModel(Room.IsOnlyEmoji) ?? false isOnlyEmoji: replyTo, fromModel(Room.IsOnlyEmoji) ?? false
userId: fromModel(Room.UserId) ?? "" userId: replyTo, fromModel(Room.UserId) ?? ""
userName: fromModel(Room.UserName) ?? "" userName: replyTo, fromModel(Room.UserName) ?? ""
thumbnailUrl: fromModel(Room.ThumbnailUrl) ?? "" thumbnailUrl: replyTo, fromModel(Room.ThumbnailUrl) ?? ""
roomTopic: fromModel(Room.RoomTopic) ?? "" roomTopic: replyTo, fromModel(Room.RoomTopic) ?? ""
roomName: fromModel(Room.RoomName) ?? "" roomName: replyTo, fromModel(Room.RoomName) ?? ""
callType: fromModel(Room.CallType) ?? "" callType: replyTo, fromModel(Room.CallType) ?? ""
} }
// actual message content // actual message content

View file

@ -710,6 +710,14 @@ TimelineModel::data(const QModelIndex &index, int role) const
return data(*event, role); return data(*event, role);
} }
QVariant
TimelineModel::dataById(QString id, int role, QString relatedTo)
{
if (auto event = events.get(id.toStdString(), relatedTo.toStdString()))
return data(*event, role);
return QVariant();
}
bool bool
TimelineModel::canFetchMore(const QModelIndex &) const TimelineModel::canFetchMore(const QModelIndex &) const
{ {

View file

@ -215,10 +215,7 @@ public:
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) Q_INVOKABLE QVariant dataById(QString id, int role, QString relatedTo);
{
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;