Fix SIP user to native user mapping is wrong #4176 (also clear dialpad entry when call is started)
This commit is contained in:
parent
58b69b1fe4
commit
0125c7675d
|
@ -0,0 +1 @@
|
||||||
|
SIP user to native user mapping is wrong
|
|
@ -170,8 +170,10 @@ class DialPadFragment : Fragment(), TextWatcher {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun clear() {
|
fun clear() {
|
||||||
digits.setText("")
|
if (::digits.isInitialized) {
|
||||||
|
digits.setText("")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun formatNumber(dialString: String): String {
|
private fun formatNumber(dialString: String): String {
|
||||||
|
|
|
@ -39,15 +39,21 @@ class DialPadLookup @Inject constructor(
|
||||||
suspend fun lookupPhoneNumber(phoneNumber: String): Result {
|
suspend fun lookupPhoneNumber(phoneNumber: String): Result {
|
||||||
session.vectorCallService.protocolChecker.awaitCheckProtocols()
|
session.vectorCallService.protocolChecker.awaitCheckProtocols()
|
||||||
val thirdPartyUser = session.pstnLookup(phoneNumber, webRtcCallManager.supportedPSTNProtocol).firstOrNull() ?: throw Failure.NoResult
|
val thirdPartyUser = session.pstnLookup(phoneNumber, webRtcCallManager.supportedPSTNProtocol).firstOrNull() ?: throw Failure.NoResult
|
||||||
// check to see if this is a virtual user, in which case we should find the native user
|
val sipUserId = thirdPartyUser.userId
|
||||||
val nativeUserId = if (webRtcCallManager.supportsVirtualRooms) {
|
val nativeLookupResults = session.sipNativeLookup(thirdPartyUser.userId)
|
||||||
val nativeLookupResults = session.sipNativeLookup(thirdPartyUser.userId)
|
// If I have a native user I check for an existing native room with him...
|
||||||
nativeLookupResults.firstOrNull()?.userId ?: thirdPartyUser.userId
|
val roomId = if (nativeLookupResults.isNotEmpty()) {
|
||||||
|
val nativeUserId = nativeLookupResults.first().userId
|
||||||
|
if (nativeUserId == session.myUserId) {
|
||||||
|
throw Failure.NumberIsYours
|
||||||
|
}
|
||||||
|
session.getExistingDirectRoomWithUser(nativeUserId)
|
||||||
|
// if there is not, just create a DM with the sip user
|
||||||
|
?: directRoomHelper.ensureDMExists(sipUserId)
|
||||||
} else {
|
} else {
|
||||||
thirdPartyUser.userId
|
// do the same if there is no corresponding native user.
|
||||||
|
directRoomHelper.ensureDMExists(sipUserId)
|
||||||
}
|
}
|
||||||
if (nativeUserId == session.myUserId) throw Failure.NumberIsYours
|
return Result(userId = sipUserId, roomId = roomId)
|
||||||
val roomId = directRoomHelper.ensureDMExists(nativeUserId)
|
|
||||||
return Result(userId = nativeUserId, roomId = roomId)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,7 +155,7 @@ class HomeDetailFragment @Inject constructor(
|
||||||
|
|
||||||
viewModel.observeViewEvents { viewEvent ->
|
viewModel.observeViewEvents { viewEvent ->
|
||||||
when (viewEvent) {
|
when (viewEvent) {
|
||||||
HomeDetailViewEvents.CallStarted -> dismissLoadingDialog()
|
HomeDetailViewEvents.CallStarted -> handleCallStarted()
|
||||||
is HomeDetailViewEvents.FailToCall -> showFailure(viewEvent.failure)
|
is HomeDetailViewEvents.FailToCall -> showFailure(viewEvent.failure)
|
||||||
HomeDetailViewEvents.Loading -> showLoadingDialog()
|
HomeDetailViewEvents.Loading -> showLoadingDialog()
|
||||||
}
|
}
|
||||||
|
@ -190,10 +190,16 @@ class HomeDetailFragment @Inject constructor(
|
||||||
|
|
||||||
sharedCallActionViewModel
|
sharedCallActionViewModel
|
||||||
.liveKnownCalls
|
.liveKnownCalls
|
||||||
.observe(viewLifecycleOwner, {
|
.observe(viewLifecycleOwner) {
|
||||||
currentCallsViewPresenter.updateCall(callManager.getCurrentCall(), callManager.getCalls())
|
currentCallsViewPresenter.updateCall(callManager.getCurrentCall(), callManager.getCalls())
|
||||||
invalidateOptionsMenu()
|
invalidateOptionsMenu()
|
||||||
})
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun handleCallStarted() {
|
||||||
|
dismissLoadingDialog()
|
||||||
|
val fragmentTag = HomeTab.DialPad.toFragmentTag()
|
||||||
|
(childFragmentManager.findFragmentByTag(fragmentTag) as? DialPadFragment)?.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
|
@ -370,8 +376,10 @@ class HomeDetailFragment @Inject constructor(
|
||||||
invalidateOptionsMenu()
|
invalidateOptionsMenu()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun HomeTab.toFragmentTag() = "FRAGMENT_TAG_$this"
|
||||||
|
|
||||||
private fun updateSelectedFragment(tab: HomeTab) {
|
private fun updateSelectedFragment(tab: HomeTab) {
|
||||||
val fragmentTag = "FRAGMENT_TAG_$tab"
|
val fragmentTag = tab.toFragmentTag()
|
||||||
val fragmentToShow = childFragmentManager.findFragmentByTag(fragmentTag)
|
val fragmentToShow = childFragmentManager.findFragmentByTag(fragmentTag)
|
||||||
childFragmentManager.commitTransaction {
|
childFragmentManager.commitTransaction {
|
||||||
childFragmentManager.fragments
|
childFragmentManager.fragments
|
||||||
|
|
Loading…
Reference in New Issue