From b29108a2f7eca9131654371733f5b4570b628d06 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Sun, 11 Jan 2026 16:27:44 -0500 Subject: [PATCH] Fix reply colors being broken if you're faster than the server This is that bug that causes reply colors to be white, and this error to print in the log: qrc:/qt/qml/org/kde/neochat/messagecontent/ReplyComponent.qml:41: TypeError: Cannot read property 'color' of null The reason why this happens is inside of EventMessageContentModel, it needs to be able to find the relevant event in the room to fetch the room member (and then their color.) Dependent on many variables to align, this can happen easily if you are faster than your server giving you said events. But this is an easy fix, we obviously get the event afterwards and just need to re-evaluate the the author property. I also made sure it falls back to some color instead of white, which will also quiet the error. (cherry picked from commit b45967508cc7bd2237e3f13ee8de58cb51040fff) --- src/messagecontent/ReplyComponent.qml | 2 +- src/messagecontent/models/eventmessagecontentmodel.cpp | 2 ++ src/messagecontent/models/messagecontentmodel.cpp | 1 - 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/messagecontent/ReplyComponent.qml b/src/messagecontent/ReplyComponent.qml index 894f5cff6..117d1d0b0 100644 --- a/src/messagecontent/ReplyComponent.qml +++ b/src/messagecontent/ReplyComponent.qml @@ -38,7 +38,7 @@ RowLayout { Layout.fillHeight: true implicitWidth: Kirigami.Units.smallSpacing - color: root.replyContentModel.author.color + color: root.replyContentModel.author?.color ?? Kirigami.Theme.highlightColor radius: Kirigami.Units.cornerRadius } ColumnLayout { diff --git a/src/messagecontent/models/eventmessagecontentmodel.cpp b/src/messagecontent/models/eventmessagecontentmodel.cpp index f25dcda63..19dc47196 100644 --- a/src/messagecontent/models/eventmessagecontentmodel.cpp +++ b/src/messagecontent/models/eventmessagecontentmodel.cpp @@ -269,6 +269,8 @@ void EventMessageContentModel::resetModel() updateItineraryModel(); Q_EMIT componentsUpdated(); + // We need QML to re-evaluate author (for example, reply colors) if it was previously null. + Q_EMIT authorChanged(); } void EventMessageContentModel::resetContent(bool isEditing, bool isThreading) diff --git a/src/messagecontent/models/messagecontentmodel.cpp b/src/messagecontent/models/messagecontentmodel.cpp index b801d052e..fa79c5e43 100644 --- a/src/messagecontent/models/messagecontentmodel.cpp +++ b/src/messagecontent/models/messagecontentmodel.cpp @@ -87,7 +87,6 @@ QDateTime MessageContentModel::time() const QString MessageContentModel::timeString() const { return time().toLocalTime().toString(u"hh:mm"_s); - ; } QString MessageContentModel::authorId() const