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.
This commit is contained in:
Joshua Goins
2026-01-11 16:27:44 -05:00
parent 2ec1fa92fa
commit b45967508c
3 changed files with 3 additions and 2 deletions

View File

@@ -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 {

View File

@@ -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)

View File

@@ -87,7 +87,6 @@ QDateTime MessageContentModel::time() const
QString MessageContentModel::timeString() const
{
return time().toLocalTime().toString(u"hh:mm"_s);
;
}
QString MessageContentModel::authorId() const