From 373586c23e92bdd8b8619b2e28bac44642515ff3 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 17 Feb 2021 10:25:06 +0100 Subject: [PATCH] Cleanup --- .idea/dictionaries/bmarty.xml | 1 + .../sdk/api/session/call/PSTNProtocolChecker.kt | 2 +- .../app/features/call/dialpad/DialPadLookup.kt | 16 +++++++++------- .../room/detail/ScrollOnNewMessageCallback.kt | 2 +- .../room/detail/timeline/item/IsEventItem.kt | 2 +- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/.idea/dictionaries/bmarty.xml b/.idea/dictionaries/bmarty.xml index 16cc35cebe..4de90e9405 100644 --- a/.idea/dictionaries/bmarty.xml +++ b/.idea/dictionaries/bmarty.xml @@ -26,6 +26,7 @@ pkcs previewable previewables + pstn riotx signin signout diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/call/PSTNProtocolChecker.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/call/PSTNProtocolChecker.kt index db26090730..6627f62e24 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/call/PSTNProtocolChecker.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/call/PSTNProtocolChecker.kt @@ -45,7 +45,7 @@ class PSTNProtocolChecker @Inject internal constructor(private val taskExecutor: private var alreadyChecked = AtomicBoolean(false) - private val pstnSupportListeners = emptyList().toMutableList() + private val pstnSupportListeners = mutableListOf() fun addListener(listener: Listener) { pstnSupportListeners.add(listener) diff --git a/vector/src/main/java/im/vector/app/features/call/dialpad/DialPadLookup.kt b/vector/src/main/java/im/vector/app/features/call/dialpad/DialPadLookup.kt index 1c5caee2cd..6fccea6c8c 100644 --- a/vector/src/main/java/im/vector/app/features/call/dialpad/DialPadLookup.kt +++ b/vector/src/main/java/im/vector/app/features/call/dialpad/DialPadLookup.kt @@ -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) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/ScrollOnNewMessageCallback.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/ScrollOnNewMessageCallback.kt index e7543278ab..1ab8762895 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/ScrollOnNewMessageCallback.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/ScrollOnNewMessageCallback.kt @@ -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") diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/IsEventItem.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/IsEventItem.kt index 059bdbea43..4c2eeea48b 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/IsEventItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/IsEventItem.kt @@ -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 }