Fix crash when trying to view Security settings in an invited room

This state event doesn't exist (or is inaccessible) to us, and tries to
access nullptr.

(cherry picked from commit 268975bc3b)
This commit is contained in:
Joshua Goins
2025-02-02 16:04:40 -05:00
parent bf9d1e5261
commit fcb32b1974

View File

@@ -747,7 +747,10 @@ QList<QString> NeoChatRoom::restrictedIds() const
QString NeoChatRoom::historyVisibility() const
{
return currentState().get("m.room.history_visibility"_ls)->contentJson()["history_visibility"_ls].toString();
if (auto stateEvent = currentState().get("m.room.history_visibility"_ls)) {
return stateEvent->contentJson()["history_visibility"_ls].toString();
}
return {};
}
void NeoChatRoom::setHistoryVisibility(const QString &historyVisibilityRule)