Null check decoded messages in loadPinnedMessage

`decryptMessage` returns null if it fails to decode the passed message. This value
then got fed into `EventHandler::richBody` which logged a warning and cleared `m_pinnedMessage`.
If we instead retain the value as an `EncryptedEvent`, the UI will pin the encrypted event
placeholder instead of hiding the existence of pins.
This commit is contained in:
Veres Károly
2026-01-10 02:26:39 +01:00
committed by Tobias Fella
parent b684fb451d
commit 71c84be4b4

View File

@@ -1186,7 +1186,10 @@ void NeoChatRoom::loadPinnedMessage()
connection()->callApi<GetOneRoomEventJob>(id(), mostRecentEventId).then([this](const auto &job) {
auto event = fromJson<event_ptr_tt<RoomEvent>>(job->jsonData());
if (auto encEv = eventCast<EncryptedEvent>(event.get())) {
event = decryptMessage(*encEv);
auto decryptedMessage = decryptMessage(*encEv);
if (decryptedMessage) {
event = std::move(decryptedMessage);
}
}
m_pinnedMessage = EventHandler::richBody(this, event.get());
Q_EMIT pinnedMessageChanged();