diff --git a/Linphone/TelecomManager/TelecomManager.swift b/Linphone/TelecomManager/TelecomManager.swift index 7a353d160..b730cae1c 100644 --- a/Linphone/TelecomManager/TelecomManager.swift +++ b/Linphone/TelecomManager/TelecomManager.swift @@ -162,6 +162,21 @@ class TelecomManager: ObservableObject { } } + func doCallOrJoinConf(address: Address, isVideo: Bool = false, isConference: Bool = false) { + if address.asStringUriOnly().hasPrefix("sip:conference-focus@sip.linphone.org") { + do { + let meetingAddress = try Factory.Instance.createAddress(addr: address.asStringUriOnly()) + + meetingWaitingRoomDisplayed = true + meetingWaitingRoomSelected = meetingAddress + } catch {} + } else { + doCallWithCore( + addr: address, isVideo: isVideo, isConference: isConference + ) + } + } + func doCallWithCore(addr: Address, isVideo: Bool, isConference: Bool) { CoreContext.shared.doOnCoreQueue { core in do { diff --git a/Linphone/UI/Main/Contacts/Fragments/ContactInnerActionsFragment.swift b/Linphone/UI/Main/Contacts/Fragments/ContactInnerActionsFragment.swift index 9d50cfc1e..7a3d96ce9 100644 --- a/Linphone/UI/Main/Contacts/Fragments/ContactInnerActionsFragment.swift +++ b/Linphone/UI/Main/Contacts/Fragments/ContactInnerActionsFragment.swift @@ -93,9 +93,7 @@ struct ContactInnerActionsFragment: View { .background(.white) .onTapGesture { withAnimation { - telecomManager.doCallWithCore( - addr: contactsManager.lastSearch[contactViewModel.indexDisplayedFriend!].friend!.addresses[index], isVideo: false, isConference: false - ) + telecomManager.doCallOrJoinConf(address: contactsManager.lastSearch[contactViewModel.indexDisplayedFriend!].friend!.addresses[index]) } } .onLongPressGesture(minimumDuration: 0.2) { diff --git a/Linphone/UI/Main/Contacts/Fragments/ContactInnerFragment.swift b/Linphone/UI/Main/Contacts/Fragments/ContactInnerFragment.swift index 7974d0a88..47748c66f 100644 --- a/Linphone/UI/Main/Contacts/Fragments/ContactInnerFragment.swift +++ b/Linphone/UI/Main/Contacts/Fragments/ContactInnerFragment.swift @@ -158,7 +158,7 @@ struct ContactInnerFragment: View { Spacer() Button(action: { - telecomManager.doCallWithCore(addr: contactsManager.lastSearch[contactViewModel.indexDisplayedFriend!].friend!.address!, isVideo: false, isConference: false) + telecomManager.doCallOrJoinConf(address: contactsManager.lastSearch[contactViewModel.indexDisplayedFriend!].friend!.address!) }, label: { VStack { HStack(alignment: .center) { @@ -208,7 +208,7 @@ struct ContactInnerFragment: View { Spacer() Button(action: { - telecomManager.doCallWithCore(addr: contactsManager.lastSearch[contactViewModel.indexDisplayedFriend!].friend!.address!, isVideo: true, isConference: false) + telecomManager.doCallOrJoinConf(address: contactsManager.lastSearch[contactViewModel.indexDisplayedFriend!].friend!.address!, isVideo: true) }, label: { VStack { HStack(alignment: .center) { diff --git a/Linphone/UI/Main/Conversations/Fragments/ChatBubbleView.swift b/Linphone/UI/Main/Conversations/Fragments/ChatBubbleView.swift index 72efc4905..9622af92b 100644 --- a/Linphone/UI/Main/Conversations/Fragments/ChatBubbleView.swift +++ b/Linphone/UI/Main/Conversations/Fragments/ChatBubbleView.swift @@ -74,13 +74,13 @@ struct ChatBubbleView: View { .if(result.1 < geometryProxy.size.height/2) { view in view.frame(maxHeight: result.1) } - .if(result.0 >= result.1 && result.0 >= geometryProxy.size.width - 110 && result.1 >= geometryProxy.size.height/2.5) { view in + .if(result.0 >= result.1 && geometryProxy.size.width > 0 && result.0 >= geometryProxy.size.width - 110 && result.1 >= geometryProxy.size.height/2.5) { view in view.frame( maxWidth: geometryProxy.size.width - 110, maxHeight: result.1 * ((geometryProxy.size.width - 110) / result.0) ) } - .if(result.0 < result.1 && result.1 >= geometryProxy.size.height/2.5) { view in + .if(result.0 < result.1 && geometryProxy.size.width > 0 && result.1 >= geometryProxy.size.height/2.5) { view in view.frame( maxWidth: result.0 * ((geometryProxy.size.height/2.5) / result.1), maxHeight: geometryProxy.size.height/2.5 diff --git a/Linphone/UI/Main/Conversations/Model/ConversationModel.swift b/Linphone/UI/Main/Conversations/Model/ConversationModel.swift index 35aa5dd28..8fdc88ef4 100644 --- a/Linphone/UI/Main/Conversations/Model/ConversationModel.swift +++ b/Linphone/UI/Main/Conversations/Model/ConversationModel.swift @@ -128,9 +128,7 @@ class ConversationModel: ObservableObject { func call() { coreContext.doOnCoreQueue { _ in if self.chatRoom.peerAddress != nil { - TelecomManager.shared.doCallWithCore( - addr: self.chatRoom.peerAddress!, isVideo: false, isConference: false - ) + TelecomManager.shared.doCallOrJoinConf(address: self.chatRoom.peerAddress!) } } } diff --git a/Linphone/UI/Main/History/Fragments/DialerBottomSheet.swift b/Linphone/UI/Main/History/Fragments/DialerBottomSheet.swift index c07b8a3a1..7a5a3bda9 100644 --- a/Linphone/UI/Main/History/Fragments/DialerBottomSheet.swift +++ b/Linphone/UI/Main/History/Fragments/DialerBottomSheet.swift @@ -451,7 +451,7 @@ struct DialerBottomSheet: View { if !startCallViewModel.searchField.isEmpty { do { let address = try Factory.Instance.createAddress(addr: String("sip:" + startCallViewModel.searchField + "@" + startCallViewModel.domain)) - telecomManager.doCallWithCore(addr: address, isVideo: false, isConference: false) + telecomManager.doCallOrJoinConf(address: address) } catch { } diff --git a/Linphone/UI/Main/History/Fragments/HistoryContactFragment.swift b/Linphone/UI/Main/History/Fragments/HistoryContactFragment.swift index ed3a6b0fb..1121b86e0 100644 --- a/Linphone/UI/Main/History/Fragments/HistoryContactFragment.swift +++ b/Linphone/UI/Main/History/Fragments/HistoryContactFragment.swift @@ -413,13 +413,9 @@ struct HistoryContactFragment: View { if historyViewModel.displayedCallIsConference.isEmpty { Button(action: { if historyViewModel.displayedCall!.dir == .Outgoing && historyViewModel.displayedCall!.toAddress != nil { - telecomManager.doCallWithCore( - addr: historyViewModel.displayedCall!.toAddress!, isVideo: false, isConference: false - ) + telecomManager.doCallOrJoinConf(address: historyViewModel.displayedCall!.toAddress!) } else if historyViewModel.displayedCall!.dir == .Incoming && historyViewModel.displayedCall!.fromAddress != nil { - telecomManager.doCallWithCore( - addr: historyViewModel.displayedCall!.fromAddress!, isVideo: false, isConference: false - ) + telecomManager.doCallOrJoinConf(address: historyViewModel.displayedCall!.fromAddress!) } }, label: { VStack { @@ -473,13 +469,9 @@ struct HistoryContactFragment: View { Button(action: { if historyViewModel.displayedCall!.dir == .Outgoing && historyViewModel.displayedCall!.toAddress != nil { - telecomManager.doCallWithCore( - addr: historyViewModel.displayedCall!.toAddress!, isVideo: true, isConference: false - ) + telecomManager.doCallOrJoinConf(address: historyViewModel.displayedCall!.toAddress!, isVideo: true) } else if historyViewModel.displayedCall!.dir == .Incoming && historyViewModel.displayedCall!.fromAddress != nil { - telecomManager.doCallWithCore( - addr: historyViewModel.displayedCall!.fromAddress!, isVideo: true, isConference: false - ) + telecomManager.doCallOrJoinConf(address: historyViewModel.displayedCall!.fromAddress!, isVideo: true) } }, label: { VStack { @@ -511,9 +503,7 @@ struct HistoryContactFragment: View { telecomManager.meetingWaitingRoomSelected = meetingAddress } catch {} } else { - telecomManager.doCallWithCore( - addr: historyViewModel.displayedCall!.toAddress!, isVideo: false, isConference: false - ) + telecomManager.doCallOrJoinConf(address: historyViewModel.displayedCall!.toAddress!) } } else if historyViewModel.displayedCall!.fromAddress != nil { if historyViewModel.displayedCall!.fromAddress!.asStringUriOnly().hasPrefix("sip:conference-focus@sip.linphone.org") { @@ -524,9 +514,7 @@ struct HistoryContactFragment: View { telecomManager.meetingWaitingRoomSelected = meetingAddress } catch {} } else { - telecomManager.doCallWithCore( - addr: historyViewModel.displayedCall!.fromAddress!, isVideo: false, isConference: false - ) + telecomManager.doCallOrJoinConf(address: historyViewModel.displayedCall!.fromAddress!) } } } diff --git a/Linphone/UI/Main/History/Fragments/HistoryListFragment.swift b/Linphone/UI/Main/History/Fragments/HistoryListFragment.swift index cae8fa86b..f101a6802 100644 --- a/Linphone/UI/Main/History/Fragments/HistoryListFragment.swift +++ b/Linphone/UI/Main/History/Fragments/HistoryListFragment.swift @@ -257,31 +257,9 @@ struct HistoryListFragment: View { func doCall(index: Int) { if historyListViewModel.callLogs[index].dir == .Outgoing && historyListViewModel.callLogs[index].toAddress != nil { - if historyListViewModel.callLogs[index].toAddress!.asStringUriOnly().hasPrefix("sip:conference-focus@sip.linphone.org") { - do { - let meetingAddress = try Factory.Instance.createAddress(addr: historyListViewModel.callLogs[index].toAddress!.asStringUriOnly()) - - telecomManager.meetingWaitingRoomDisplayed = true - telecomManager.meetingWaitingRoomSelected = meetingAddress - } catch {} - } else { - telecomManager.doCallWithCore( - addr: historyListViewModel.callLogs[index].toAddress!, isVideo: false, isConference: false - ) - } + telecomManager.doCallOrJoinConf(address: historyListViewModel.callLogs[index].toAddress!) } else if historyListViewModel.callLogs[index].fromAddress != nil { - if historyListViewModel.callLogs[index].fromAddress!.asStringUriOnly().hasPrefix("sip:conference-focus@sip.linphone.org") { - do { - let meetingAddress = try Factory.Instance.createAddress(addr: historyListViewModel.callLogs[index].fromAddress!.asStringUriOnly()) - - telecomManager.meetingWaitingRoomDisplayed = true - telecomManager.meetingWaitingRoomSelected = meetingAddress - } catch {} - } else { - telecomManager.doCallWithCore( - addr: historyListViewModel.callLogs[index].fromAddress!, isVideo: false, isConference: false - ) - } + telecomManager.doCallOrJoinConf(address: historyListViewModel.callLogs[index].fromAddress!) } } } diff --git a/Linphone/UI/Main/History/Fragments/StartCallFragment.swift b/Linphone/UI/Main/History/Fragments/StartCallFragment.swift index 37a5f2a4f..d6c465356 100644 --- a/Linphone/UI/Main/History/Fragments/StartCallFragment.swift +++ b/Linphone/UI/Main/History/Fragments/StartCallFragment.swift @@ -219,7 +219,7 @@ struct StartCallFragment: View { withAnimation { isShowStartCallFragment.toggle() - telecomManager.doCallWithCore(addr: addr, isVideo: false, isConference: false) + telecomManager.doCallOrJoinConf(address: addr) } } }) @@ -304,9 +304,7 @@ struct StartCallFragment: View { withAnimation { isShowStartCallFragment.toggle() if contactsManager.lastSearchSuggestions[index].address != nil { - telecomManager.doCallWithCore( - addr: contactsManager.lastSearchSuggestions[index].address!, isVideo: false, isConference: false - ) + telecomManager.doCallOrJoinConf(address: contactsManager.lastSearchSuggestions[index].address!) } } }