Fix room switch so that if there is no saved text the user ends up with an empty chatbar

This commit is contained in:
James Graham
2026-01-30 08:54:49 +00:00
parent 007ebbc003
commit 6e28ada1a4
2 changed files with 3 additions and 6 deletions

View File

@@ -399,12 +399,7 @@ void ModelTest::testCompletionModel()
tester->setUseFetchMore(true);
model->setRoom(room);
model->setAutoCompletionType(CompletionModel::Room);
<<<<<<< HEAD
model->setText(u"foo"_s, u"#foo"_s);
auto roomListModel = new RoomListModel(this);
=======
auto roomListModel = new RoomListModel();
>>>>>>> da60b8068 (Fix merge issues)
roomListModel->setConnection(connection);
model->setRoomListModel(roomListModel);
}

View File

@@ -43,12 +43,14 @@ ChatBarMessageContentModel::ChatBarMessageContentModel(QObject *parent)
addAttachment(QUrl(m_room->cacheForType(m_type)->attachmentPath()));
}
clearModel();
const auto textSections = m_room->cacheForType(m_type)->text().split(u"\n\n"_s);
if (textSections.length() == 1 && textSections[0].isEmpty()) {
initializeModel();
return;
}
clearModel();
beginResetModel();
for (const auto &section : textSections) {
const auto type = MessageComponentType::typeForString(section);