Fix pins not refreshing after being loaded

This commit is contained in:
Nicolas Werner 2022-06-15 15:36:58 +02:00
parent bcc6c518be
commit 3eafd4396e
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
4 changed files with 15 additions and 4 deletions

View file

@ -271,7 +271,12 @@ Pane {
height: implicitHeight height: implicitHeight
Reply { Reply {
property var e: room ? room.getDump(modelData, "") : {} id: reply
property var e: room ? room.getDump(modelData, "pins") : {}
Connections {
function onPinnedMessagesChanged() { reply.e = room.getDump(modelData, "pins") }
target: room
}
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: height Layout.preferredHeight: height

View file

@ -48,9 +48,13 @@ EventStore::EventStore(std::string room_id, QObject *)
cache::client()->storeEvent(room_id_, id, {timeline}); cache::client()->storeEvent(room_id_, id, {timeline});
if (!relatedTo.empty()) { if (!relatedTo.empty()) {
auto idx = idToIndex(relatedTo); if (relatedTo == "pins") {
if (idx) emit pinsChanged();
emit dataChanged(*idx, *idx); } else {
auto idx = idToIndex(relatedTo);
if (idx)
emit dataChanged(*idx, *idx);
}
} }
}, },
Qt::QueuedConnection); Qt::QueuedConnection);

View file

@ -101,6 +101,7 @@ signals:
void beginResetModel(); void beginResetModel();
void endResetModel(); void endResetModel();
void dataChanged(int from, int to); void dataChanged(int from, int to);
void pinsChanged();
void newEncryptedImage(mtx::crypto::EncryptedFile encryptionInfo); void newEncryptedImage(mtx::crypto::EncryptedFile encryptionInfo);
void eventFetched(std::string id, void eventFetched(std::string id,
std::string relatedTo, std::string relatedTo,

View file

@ -398,6 +398,7 @@ TimelineModel::TimelineModel(TimelineViewManager *manager, QString room_id, QObj
"data changed {} to {}", events.size() - to - 1, events.size() - from - 1); "data changed {} to {}", events.size() - to - 1, events.size() - from - 1);
emit dataChanged(index(events.size() - to - 1, 0), index(events.size() - from - 1, 0)); emit dataChanged(index(events.size() - to - 1, 0), index(events.size() - from - 1, 0));
}); });
connect(&events, &EventStore::pinsChanged, this, &TimelineModel::pinnedMessagesChanged);
connect(&events, &EventStore::beginInsertRows, this, [this](int from, int to) { connect(&events, &EventStore::beginInsertRows, this, [this](int from, int to) {
int first = events.size() - to; int first = events.size() - to;