diff --git a/androidshared/src/main/java/org/odk/collect/androidshared/data/Data.kt b/androidshared/src/main/java/org/odk/collect/androidshared/data/Data.kt index 44a6020cd96..bb966ace614 100644 --- a/androidshared/src/main/java/org/odk/collect/androidshared/data/Data.kt +++ b/androidshared/src/main/java/org/odk/collect/androidshared/data/Data.kt @@ -32,6 +32,11 @@ abstract class DataService(private val appState: AppState, private val onUpdate: onUpdate?.invoke() } + protected fun data(key: String, default: T): DataDelegate { + val data = Data(appState, key, default) + return DataDelegate(data) + } + protected fun data(key: String, default: T, updater: () -> T): DataDelegate { val data = attachData(key, default) { updater() } return DataDelegate(data) @@ -42,11 +47,6 @@ abstract class DataService(private val appState: AppState, private val onUpdate: return DataDelegate(data) } - protected fun qualifiedData(key: String, default: T): DataDelegate { - val data = Data(appState, key, default) - return DataDelegate(data) - } - private fun attachData(key: String, default: T, updater: (String?) -> T): Data { val data = Data(appState, key, default) dataUpdaters.add(DataUpdater(data, updater)) diff --git a/collect_app/src/main/java/org/odk/collect/android/formmanagement/FormsDataService.kt b/collect_app/src/main/java/org/odk/collect/android/formmanagement/FormsDataService.kt index 17bb76240da..19e23b2eb03 100644 --- a/collect_app/src/main/java/org/odk/collect/android/formmanagement/FormsDataService.kt +++ b/collect_app/src/main/java/org/odk/collect/android/formmanagement/FormsDataService.kt @@ -32,9 +32,9 @@ class FormsDataService( projectDependencies.formsRepository.all } - private val syncing by qualifiedData(DataKeys.SYNC_STATUS_SYNCING, false) - private val serverError by qualifiedData(DataKeys.SYNC_STATUS_ERROR, null) - private val diskError by qualifiedData(DataKeys.DISK_ERROR, null) + private val syncing by data(DataKeys.SYNC_STATUS_SYNCING, false) + private val serverError by data(DataKeys.SYNC_STATUS_ERROR, null) + private val diskError by data(DataKeys.DISK_ERROR, null) fun getForms(projectId: String): Flow> { return forms.get(projectId)