Skip to content

Commit 3aaa870

Browse files
committed
Implemented sort order
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
1 parent 94ca9cd commit 3aaa870

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

app/src/main/kotlin/at/bitfire/davdroid/db/WebDavDocumentDao.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ interface WebDavDocumentDao {
2424
@Query("SELECT * FROM webdav_document WHERE parentId=:parentId")
2525
fun getChildren(parentId: Long): List<WebDavDocument>
2626

27+
@Query("SELECT * FROM webdav_document WHERE parentId=:parentId ORDER BY :orderBy")
28+
fun getChildrenOrdered(parentId: Long, orderBy: String): List<WebDavDocument>
29+
2730
@Insert(onConflict = OnConflictStrategy.REPLACE)
2831
fun insertOrReplace(document: WebDavDocument): Long
2932

app/src/main/kotlin/at/bitfire/davdroid/webdav/DavDocumentsProvider.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,8 @@ class DavDocumentsProvider(
287287
runningQueryChildren.remove(parentId)
288288

289289
// Regardless of whether the worker is done, return the children we already have
290-
for (child in documentDao.getChildren(parentId)) {
290+
val children = if (sortOrder == null) documentDao.getChildren(parentId) else documentDao.getChildrenOrdered(parentId, sortOrder)
291+
for (child in children) {
291292
val bundle = child.toBundle(parent)
292293
result.addRow(bundle)
293294
}

0 commit comments

Comments
 (0)