Remove Space Child

Add button to remove a child in a space if the user has the correct power levels
This commit is contained in:
James Graham
2023-09-29 20:15:17 +00:00
parent 925393deab
commit eba62103a4
7 changed files with 157 additions and 3 deletions

View File

@@ -1128,6 +1128,25 @@ void NeoChatRoom::addChild(const QString &childId, bool setChildParent)
}
}
void NeoChatRoom::removeChild(const QString &childId, bool unsetChildParent)
{
if (!isSpace()) {
return;
}
if (!canSendEvent("m.space.child"_ls)) {
return;
}
setState("m.space.child"_ls, childId, {});
if (unsetChildParent) {
if (auto child = static_cast<NeoChatRoom *>(connection()->room(childId))) {
if (child->canSendState("m.space.parent"_ls) && child->currentState().contains("m.space.parent"_ls, id())) {
child->setState("m.space.parent"_ls, id(), {});
}
}
}
}
PushNotificationState::State NeoChatRoom::pushNotificationState() const
{
return m_currentPushNotificationState;