[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 { LibrusFeatures.filter {
it.featureId == featureId // feature ID matches it.featureId == featureId // feature ID matches
&& possibleLoginMethods.containsAll(it.requiredLoginMethods) // is possible to login && 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 { }.let {
endpointList.addAll(it) endpointList.addAll(it)
} }

View File

@ -70,7 +70,7 @@ class Mobidziennik(val app: App, val profile: Profile?, val loginStore: LoginSto
MobidziennikFeatures.filter { MobidziennikFeatures.filter {
it.featureId == featureId // feature ID matches it.featureId == featureId // feature ID matches
&& possibleLoginMethods.containsAll(it.requiredLoginMethods) // is possible to login && 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 { }.let {
endpointList.addAll(it) endpointList.addAll(it)
} }

View File

@ -1,8 +1,5 @@
package pl.szczodrzynski.edziennik.api.v2.models 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. * A Endpoint descriptor class.
* *
@ -28,8 +25,8 @@ data class Feature(
return this return this
} }
var shouldSync: ((Profile?, LoginStore) -> Boolean)? = null var shouldSync: ((Data) -> Boolean)? = null
fun withShouldSync(shouldSync: ((Profile?, LoginStore) -> Boolean)?): Feature { fun withShouldSync(shouldSync: ((Data) -> Boolean)?): Feature {
this.shouldSync = shouldSync this.shouldSync = shouldSync
return this return this
} }

View File

@ -73,7 +73,7 @@ class Template(val app: App, val profile: Profile?, val loginStore: LoginStore,
VulcanFeatures.filter { VulcanFeatures.filter {
it.featureId == featureId // feature ID matches it.featureId == featureId // feature ID matches
&& possibleLoginMethods.containsAll(it.requiredLoginMethods) // is possible to login && 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 { }.let {
endpointList.addAll(it) endpointList.addAll(it)
} }

View File

@ -72,7 +72,7 @@ class Vulcan(val app: App, val profile: Profile?, val loginStore: LoginStore, va
VulcanFeatures.filter { VulcanFeatures.filter {
it.featureId == featureId // feature ID matches it.featureId == featureId // feature ID matches
&& possibleLoginMethods.containsAll(it.requiredLoginMethods) // is possible to login && 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 { }.let {
endpointList.addAll(it) endpointList.addAll(it)
} }