[APIv2] Update Feature shouldSync method.

This commit is contained in:
Kuba Szczodrzyński 2019-10-13 19:40:56 +02:00
parent 0e17a70193
commit 6b80d7cbd0
5 changed files with 6 additions and 9 deletions

View File

@ -69,7 +69,7 @@ class Librus(val app: App, val profile: Profile?, val loginStore: LoginStore, va
LibrusFeatures.filter {
it.featureId == featureId // feature ID matches
&& possibleLoginMethods.containsAll(it.requiredLoginMethods) // is possible to login
&& it.shouldSync?.invoke(profile, loginStore) ?: true // is necessary/possible to sync
&& it.shouldSync?.invoke(data) ?: true // is necessary/possible to sync
}.let {
endpointList.addAll(it)
}

View File

@ -70,7 +70,7 @@ class Mobidziennik(val app: App, val profile: Profile?, val loginStore: LoginSto
MobidziennikFeatures.filter {
it.featureId == featureId // feature ID matches
&& possibleLoginMethods.containsAll(it.requiredLoginMethods) // is possible to login
&& it.shouldSync?.invoke(profile, loginStore) ?: true // is necessary/possible to sync
&& it.shouldSync?.invoke(data) ?: true // is necessary/possible to sync
}.let {
endpointList.addAll(it)
}

View File

@ -1,8 +1,5 @@
package pl.szczodrzynski.edziennik.api.v2.models
import pl.szczodrzynski.edziennik.data.db.modules.login.LoginStore
import pl.szczodrzynski.edziennik.data.db.modules.profiles.Profile
/**
* A Endpoint descriptor class.
*
@ -28,8 +25,8 @@ data class Feature(
return this
}
var shouldSync: ((Profile?, LoginStore) -> Boolean)? = null
fun withShouldSync(shouldSync: ((Profile?, LoginStore) -> Boolean)?): Feature {
var shouldSync: ((Data) -> Boolean)? = null
fun withShouldSync(shouldSync: ((Data) -> Boolean)?): Feature {
this.shouldSync = shouldSync
return this
}

View File

@ -73,7 +73,7 @@ class Template(val app: App, val profile: Profile?, val loginStore: LoginStore,
VulcanFeatures.filter {
it.featureId == featureId // feature ID matches
&& possibleLoginMethods.containsAll(it.requiredLoginMethods) // is possible to login
&& it.shouldSync?.invoke(profile, loginStore) ?: true // is necessary/possible to sync
&& it.shouldSync?.invoke(data) ?: true // is necessary/possible to sync
}.let {
endpointList.addAll(it)
}

View File

@ -72,7 +72,7 @@ class Vulcan(val app: App, val profile: Profile?, val loginStore: LoginStore, va
VulcanFeatures.filter {
it.featureId == featureId // feature ID matches
&& possibleLoginMethods.containsAll(it.requiredLoginMethods) // is possible to login
&& it.shouldSync?.invoke(profile, loginStore) ?: true // is necessary/possible to sync
&& it.shouldSync?.invoke(data) ?: true // is necessary/possible to sync
}.let {
endpointList.addAll(it)
}