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
Reply {
function fromModel(role) {
return replyTo != "" ? room.dataById(replyTo, role) : null;
return replyTo != "" ? room.dataById(replyTo, role, r.eventId) : null;
}
visible: replyTo
userColor: TimelineManager.userColor(userId, Nheko.colors.base)
blurhash: fromModel(Room.Blurhash) ?? ""
body: fromModel(Room.Body) ?? ""
formattedBody: fromModel(Room.FormattedBody) ?? ""
userColor: replyTo, TimelineManager.userColor(userId, Nheko.colors.base)
blurhash: replyTo, fromModel(Room.Blurhash) ?? ""
body: replyTo, fromModel(Room.Body) ?? ""
formattedBody: replyTo, 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) ?? ""
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) ?? ""
}
// actual message content

View file

@ -710,6 +710,14 @@ TimelineModel::data(const QModelIndex &index, int role) const
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
TimelineModel::canFetchMore(const QModelIndex &) const
{

View file

@ -215,10 +215,7 @@ public:
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);
}
Q_INVOKABLE QVariant dataById(QString id, int role, QString relatedTo);
bool canFetchMore(const QModelIndex &) const override;
void fetchMore(const QModelIndex &) override;