Sort provider by index
This commit is contained in:
parent
7333995630
commit
21a07fda07
4 changed files with 9 additions and 3 deletions
|
|
@ -35,8 +35,7 @@ class DefaultPushService @Inject constructor(
|
|||
}
|
||||
|
||||
override fun getAvailablePushProviders(): List<PushProvider> {
|
||||
// TODO Sort by priority?
|
||||
return pushProviders.toList()
|
||||
return pushProviders.sortedBy { it.index }
|
||||
}
|
||||
|
||||
override suspend fun registerWith(matrixClient: MatrixClient, pushProvider: PushProvider, distributorName: String) {
|
||||
|
|
|
|||
|
|
@ -22,6 +22,10 @@ import io.element.android.libraries.matrix.api.MatrixClient
|
|||
* This is the main API for this module
|
||||
*/
|
||||
interface PushProvider {
|
||||
/**
|
||||
* Allow to sort provider, from lower index to higher index
|
||||
*/
|
||||
val index: Int
|
||||
fun getDistributorNames(): List<String>
|
||||
suspend fun registerWith(matrixClient: MatrixClient, distributorName: String)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ class FirebasePushProvider @Inject constructor(
|
|||
private val googleFcmHelper: GoogleFcmHelper,
|
||||
private val pusherSubscriber: PusherSubscriber,
|
||||
) : PushProvider {
|
||||
override val index = 0
|
||||
|
||||
override fun getDistributorNames(): List<String> {
|
||||
// Must return an non-empty list for now
|
||||
|
|
|
|||
|
|
@ -20,7 +20,9 @@ import io.element.android.libraries.matrix.api.MatrixClient
|
|||
import io.element.android.libraries.push.providers.api.PushProvider
|
||||
import javax.inject.Inject
|
||||
|
||||
class UnifiedPushProvider @Inject constructor(): PushProvider {
|
||||
class UnifiedPushProvider @Inject constructor() : PushProvider {
|
||||
override val index = 1
|
||||
|
||||
override fun getDistributorNames(): List<String> {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue