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