feat: change leave room info last admin (MESSENGER-5783)

This commit is contained in:
JanNiklas Grabowski
2024-09-27 13:28:36 +02:00
parent 384bebc921
commit 7b6693631b
4 changed files with 9 additions and 5 deletions

View File

@@ -28,6 +28,7 @@ final class LeaveRoomHelper {
}
var canLeave = false
var hasInvites = false
// admins can only leave if there is at least one other admin
room.state { (state) in
@@ -39,9 +40,12 @@ final class LeaveRoomHelper {
}
}
}
if state?.membersCount.invited ?? 0 > 0 {
hasInvites = true
}
}
// A single admin can leave the room if he is the only member
if !canLeave && self.isOnlyMember(room) {
// A single admin can leave the room if he is the only member and there are no pending invites. User can leave DMs without a rule.
if !canLeave && self.isOnlyMember(room) && !hasInvites || room.isDirect {
canLeave = true
}