diff --git a/resources/qml/TopBar.qml b/resources/qml/TopBar.qml index 20eff7f3..c9d26019 100644 --- a/resources/qml/TopBar.qml +++ b/resources/qml/TopBar.qml @@ -271,7 +271,12 @@ Pane { height: implicitHeight 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.preferredHeight: height diff --git a/src/timeline/EventStore.cpp b/src/timeline/EventStore.cpp index 264cde77..b0ea07ec 100644 --- a/src/timeline/EventStore.cpp +++ b/src/timeline/EventStore.cpp @@ -48,9 +48,13 @@ EventStore::EventStore(std::string room_id, QObject *) cache::client()->storeEvent(room_id_, id, {timeline}); if (!relatedTo.empty()) { - auto idx = idToIndex(relatedTo); - if (idx) - emit dataChanged(*idx, *idx); + if (relatedTo == "pins") { + emit pinsChanged(); + } else { + auto idx = idToIndex(relatedTo); + if (idx) + emit dataChanged(*idx, *idx); + } } }, Qt::QueuedConnection); diff --git a/src/timeline/EventStore.h b/src/timeline/EventStore.h index 6317cbbe..5cfab727 100644 --- a/src/timeline/EventStore.h +++ b/src/timeline/EventStore.h @@ -101,6 +101,7 @@ signals: void beginResetModel(); void endResetModel(); void dataChanged(int from, int to); + void pinsChanged(); void newEncryptedImage(mtx::crypto::EncryptedFile encryptionInfo); void eventFetched(std::string id, std::string relatedTo, diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index 578d63b7..53559644 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -398,6 +398,7 @@ TimelineModel::TimelineModel(TimelineViewManager *manager, QString room_id, QObj "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)); }); + connect(&events, &EventStore::pinsChanged, this, &TimelineModel::pinnedMessagesChanged); connect(&events, &EventStore::beginInsertRows, this, [this](int from, int to) { int first = events.size() - to;