This commit is contained in:
Benoit Marty 2021-02-17 10:25:06 +01:00
parent 754dec949b
commit 373586c23e
5 changed files with 13 additions and 10 deletions

View File

@ -26,6 +26,7 @@
<w>pkcs</w> <w>pkcs</w>
<w>previewable</w> <w>previewable</w>
<w>previewables</w> <w>previewables</w>
<w>pstn</w>
<w>riotx</w> <w>riotx</w>
<w>signin</w> <w>signin</w>
<w>signout</w> <w>signout</w>

View File

@ -45,7 +45,7 @@ class PSTNProtocolChecker @Inject internal constructor(private val taskExecutor:
private var alreadyChecked = AtomicBoolean(false) private var alreadyChecked = AtomicBoolean(false)
private val pstnSupportListeners = emptyList<Listener>().toMutableList() private val pstnSupportListeners = mutableListOf<Listener>()
fun addListener(listener: Listener) { fun addListener(listener: Listener) {
pstnSupportListeners.add(listener) pstnSupportListeners.add(listener)

View File

@ -22,20 +22,22 @@ import org.matrix.android.sdk.api.extensions.tryOrNull
import org.matrix.android.sdk.api.session.Session import org.matrix.android.sdk.api.session.Session
import javax.inject.Inject import javax.inject.Inject
class DialPadLookup @Inject constructor(val session: Session, class DialPadLookup @Inject constructor(
val directRoomHelper: DirectRoomHelper, private val session: Session,
val callManager: WebRtcCallManager private val directRoomHelper: DirectRoomHelper,
private val callManager: WebRtcCallManager
) { ) {
class Failure : Throwable() class Failure : Throwable()
data class Result(val userId: String, val roomId: String) data class Result(val userId: String, val roomId: String)
suspend fun lookupPhoneNumber(phoneNumber: String): Result { suspend fun lookupPhoneNumber(phoneNumber: String): Result {
val supportedProtocolKey = callManager.supportedPSTNProtocol ?: throw Failure() val supportedProtocolKey = callManager.supportedPSTNProtocol ?: throw Failure()
val thirdPartyUser = tryOrNull { val thirdPartyUser = tryOrNull {
session.thirdPartyService().getThirdPartyUser(supportedProtocolKey, fields = mapOf( session.thirdPartyService().getThirdPartyUser(
"m.id.phone" to phoneNumber protocol = supportedProtocolKey,
)).firstOrNull() fields = mapOf("m.id.phone" to phoneNumber)
).firstOrNull()
} ?: throw Failure() } ?: throw Failure()
val roomId = directRoomHelper.ensureDMExists(thirdPartyUser.userId) val roomId = directRoomHelper.ensureDMExists(thirdPartyUser.userId)

View File

@ -48,7 +48,7 @@ class ScrollOnNewMessageCallback(private val layoutManager: LinearLayoutManager,
return return
} }
val firstNewItem = timelineEventController.adapter.getModelAtPosition(position) as? IsEventItem ?: return val firstNewItem = timelineEventController.adapter.getModelAtPosition(position) as? IsEventItem ?: return
val firstNewItemIds = firstNewItem.getEventIds().firstOrNull() val firstNewItemIds = firstNewItem.getEventIds().firstOrNull() ?: return
val indexOfFirstNewItem = newTimelineEventIds.indexOf(firstNewItemIds) val indexOfFirstNewItem = newTimelineEventIds.indexOf(firstNewItemIds)
if (indexOfFirstNewItem != -1) { if (indexOfFirstNewItem != -1) {
Timber.v("Should scroll to position: $position") Timber.v("Should scroll to position: $position")

View File

@ -19,7 +19,7 @@ package im.vector.app.features.home.room.detail.timeline.item
interface IsEventItem { interface IsEventItem {
/** /**
* Returns the eventIds associated with the EventItem. * Returns the eventIds associated with the EventItem.
* Will generally get only one, but it handles the merging items. * Will generally get only one, but it handles the merged items.
*/ */
fun getEventIds(): List<String> fun getEventIds(): List<String>
} }