Make call UI react to receiving unknown users' profile keys

This commit is contained in:
Marissa Le Coz 2024-10-09 20:25:12 -04:00 committed by GitHub
parent 2c8a4b8f68
commit a2f6027319
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 39 additions and 1 deletions

View File

@ -381,7 +381,7 @@ class CallDrawerSheet: InteractiveSheetViewController {
}
}
private func updateMembers() {
func updateMembers() {
let unsortedMembers: [JoinedMember] = databaseStorage.read {
callSheetDataSource.unsortedMembers(tx: $0.asV2Read)
}

View File

@ -559,6 +559,13 @@ class GroupCallViewController: UIViewController {
)
}
}
NotificationCenter.default.addObserver(
self,
selector: #selector(otherUsersProfileChanged(notification:)),
name: UserProfileNotifications.otherUsersProfileDidChange,
object: nil
)
}
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
@ -1405,6 +1412,37 @@ class GroupCallViewController: UIViewController {
callService.callUIAdapter.answerCall(call)
}
// MARK: Profile updates
@objc
private func otherUsersProfileChanged(notification: Notification) {
AssertIsOnMainThread()
guard let changedAddress = notification.userInfo?[UserProfileNotifications.profileAddressKey] as? SignalServiceAddress,
changedAddress.isValid else {
owsFailDebug("changedAddress was unexpectedly nil")
return
}
if let peekInfo = self.ringRtcCall.peekInfo {
let joinedAndPendingMembers = peekInfo.joinedMembers + peekInfo.pendingUsers
if joinedAndPendingMembers.contains(where: { uuid in
changedAddress == SignalServiceAddress(Aci(fromUUID: uuid))
}) {
self.bottomSheet.updateMembers()
switch self.ringRtcCall.kind {
case .signalGroup:
break
case .callLink:
// Refresh profiles in call link admin approval UI.
self.callLinkApprovalViewModel.loadRequestsWithSneakyTransaction(for: peekInfo.pendingUsers)
}
}
}
}
}
// MARK: CallViewControllerWindowReference