Handle paged collection results

pull/1244/head
Alex Baker 5 years ago
parent 2bef1b41ef
commit 3a837dab6e

@ -29,15 +29,17 @@ class EtebaseClient(
@Throws(Exceptions.HttpException::class)
suspend fun getCollections(): List<Collection> {
val collectionManager = etebase.collectionManager
val response = withContext(Dispatchers.IO) {
collectionManager.list(TYPE_TASKS)
}
response.data.forEach {
cache.collectionSet(collectionManager, it)
}
response.removedMemberships.forEach {
cache.collectionUnset(collectionManager, it)
}
do {
val response = withContext(Dispatchers.IO) {
collectionManager.list(TYPE_TASKS)
}
response.data.forEach {
cache.collectionSet(collectionManager, it)
}
response.removedMemberships.forEach {
cache.collectionUnset(collectionManager, it)
}
} while (!response.isDone)
return cache.collectionList(collectionManager)
}

Loading…
Cancel
Save