mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2025-01-18 12:56:45 -06:00
[APIv2] Update Feature shouldSync method.
This commit is contained in:
parent
0e17a70193
commit
6b80d7cbd0
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user