mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-22 09:25:49 +03:00
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
4 changed files with 31 additions and 14 deletions
1
changelog.d/4176.bugfix
Normal file
1
changelog.d/4176.bugfix
Normal file
|
@ -0,0 +1 @@
|
|||
SIP user to native user mapping is wrong
|
|
@ -170,8 +170,10 @@ class DialPadFragment : Fragment(), TextWatcher {
|
|||
}
|
||||
}
|
||||
|
||||
private fun clear() {
|
||||
digits.setText("")
|
||||
fun clear() {
|
||||
if (::digits.isInitialized) {
|
||||
digits.setText("")
|
||||
}
|
||||
}
|
||||
|
||||
private fun formatNumber(dialString: String): String {
|
||||
|
|
|
@ -39,15 +39,21 @@ class DialPadLookup @Inject constructor(
|
|||
suspend fun lookupPhoneNumber(phoneNumber: String): Result {
|
||||
session.vectorCallService.protocolChecker.awaitCheckProtocols()
|
||||
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 nativeUserId = if (webRtcCallManager.supportsVirtualRooms) {
|
||||
val nativeLookupResults = session.sipNativeLookup(thirdPartyUser.userId)
|
||||
nativeLookupResults.firstOrNull()?.userId ?: thirdPartyUser.userId
|
||||
val sipUserId = thirdPartyUser.userId
|
||||
val nativeLookupResults = session.sipNativeLookup(thirdPartyUser.userId)
|
||||
// If I have a native user I check for an existing native room with him...
|
||||
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 {
|
||||
thirdPartyUser.userId
|
||||
// do the same if there is no corresponding native user.
|
||||
directRoomHelper.ensureDMExists(sipUserId)
|
||||
}
|
||||
if (nativeUserId == session.myUserId) throw Failure.NumberIsYours
|
||||
val roomId = directRoomHelper.ensureDMExists(nativeUserId)
|
||||
return Result(userId = nativeUserId, roomId = roomId)
|
||||
return Result(userId = sipUserId, roomId = roomId)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ class HomeDetailFragment @Inject constructor(
|
|||
|
||||
viewModel.observeViewEvents { viewEvent ->
|
||||
when (viewEvent) {
|
||||
HomeDetailViewEvents.CallStarted -> dismissLoadingDialog()
|
||||
HomeDetailViewEvents.CallStarted -> handleCallStarted()
|
||||
is HomeDetailViewEvents.FailToCall -> showFailure(viewEvent.failure)
|
||||
HomeDetailViewEvents.Loading -> showLoadingDialog()
|
||||
}
|
||||
|
@ -190,10 +190,16 @@ class HomeDetailFragment @Inject constructor(
|
|||
|
||||
sharedCallActionViewModel
|
||||
.liveKnownCalls
|
||||
.observe(viewLifecycleOwner, {
|
||||
.observe(viewLifecycleOwner) {
|
||||
currentCallsViewPresenter.updateCall(callManager.getCurrentCall(), callManager.getCalls())
|
||||
invalidateOptionsMenu()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleCallStarted() {
|
||||
dismissLoadingDialog()
|
||||
val fragmentTag = HomeTab.DialPad.toFragmentTag()
|
||||
(childFragmentManager.findFragmentByTag(fragmentTag) as? DialPadFragment)?.clear()
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
|
@ -370,8 +376,10 @@ class HomeDetailFragment @Inject constructor(
|
|||
invalidateOptionsMenu()
|
||||
}
|
||||
|
||||
private fun HomeTab.toFragmentTag() = "FRAGMENT_TAG_$this"
|
||||
|
||||
private fun updateSelectedFragment(tab: HomeTab) {
|
||||
val fragmentTag = "FRAGMENT_TAG_$tab"
|
||||
val fragmentTag = tab.toFragmentTag()
|
||||
val fragmentToShow = childFragmentManager.findFragmentByTag(fragmentTag)
|
||||
childFragmentManager.commitTransaction {
|
||||
childFragmentManager.fragments
|
||||
|
|
Loading…
Reference in a new issue