mirror of
https://github.com/element-hq/element-android
synced 2024-11-23 18:05:36 +03:00
Cleanup
This commit is contained in:
parent
754dec949b
commit
373586c23e
5 changed files with 13 additions and 10 deletions
|
@ -26,6 +26,7 @@
|
|||
<w>pkcs</w>
|
||||
<w>previewable</w>
|
||||
<w>previewables</w>
|
||||
<w>pstn</w>
|
||||
<w>riotx</w>
|
||||
<w>signin</w>
|
||||
<w>signout</w>
|
||||
|
|
|
@ -45,7 +45,7 @@ class PSTNProtocolChecker @Inject internal constructor(private val taskExecutor:
|
|||
|
||||
private var alreadyChecked = AtomicBoolean(false)
|
||||
|
||||
private val pstnSupportListeners = emptyList<Listener>().toMutableList()
|
||||
private val pstnSupportListeners = mutableListOf<Listener>()
|
||||
|
||||
fun addListener(listener: Listener) {
|
||||
pstnSupportListeners.add(listener)
|
||||
|
|
|
@ -22,20 +22,22 @@ import org.matrix.android.sdk.api.extensions.tryOrNull
|
|||
import org.matrix.android.sdk.api.session.Session
|
||||
import javax.inject.Inject
|
||||
|
||||
class DialPadLookup @Inject constructor(val session: Session,
|
||||
val directRoomHelper: DirectRoomHelper,
|
||||
val callManager: WebRtcCallManager
|
||||
class DialPadLookup @Inject constructor(
|
||||
private val session: Session,
|
||||
private val directRoomHelper: DirectRoomHelper,
|
||||
private val callManager: WebRtcCallManager
|
||||
) {
|
||||
|
||||
class Failure : Throwable()
|
||||
|
||||
data class Result(val userId: String, val roomId: String)
|
||||
|
||||
suspend fun lookupPhoneNumber(phoneNumber: String): Result {
|
||||
val supportedProtocolKey = callManager.supportedPSTNProtocol ?: throw Failure()
|
||||
val thirdPartyUser = tryOrNull {
|
||||
session.thirdPartyService().getThirdPartyUser(supportedProtocolKey, fields = mapOf(
|
||||
"m.id.phone" to phoneNumber
|
||||
)).firstOrNull()
|
||||
session.thirdPartyService().getThirdPartyUser(
|
||||
protocol = supportedProtocolKey,
|
||||
fields = mapOf("m.id.phone" to phoneNumber)
|
||||
).firstOrNull()
|
||||
} ?: throw Failure()
|
||||
|
||||
val roomId = directRoomHelper.ensureDMExists(thirdPartyUser.userId)
|
||||
|
|
|
@ -48,7 +48,7 @@ class ScrollOnNewMessageCallback(private val layoutManager: LinearLayoutManager,
|
|||
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)
|
||||
if (indexOfFirstNewItem != -1) {
|
||||
Timber.v("Should scroll to position: $position")
|
||||
|
|
|
@ -19,7 +19,7 @@ package im.vector.app.features.home.room.detail.timeline.item
|
|||
interface IsEventItem {
|
||||
/**
|
||||
* 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>
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue