Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit 00361a5

Browse files
Fix crash when using type independent sort (#734)
1 parent 9c1cc86 commit 00361a5

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

app/src/main/java/com/zeapo/pwdstore/SearchableRepositoryViewModel.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ private fun PasswordItem.Companion.makeComparator(
9292
): Comparator<PasswordItem> {
9393
return when (typeSortOrder) {
9494
PasswordRepository.PasswordSortOrder.FOLDER_FIRST -> compareBy { it.type }
95-
PasswordRepository.PasswordSortOrder.INDEPENDENT -> compareBy<PasswordItem>()
95+
// In order to let INDEPENDENT not distinguish between items based on their type, we simply
96+
// declare them all equal at this stage.
97+
PasswordRepository.PasswordSortOrder.INDEPENDENT -> Comparator<PasswordItem> { _, _ -> 0 }
9698
PasswordRepository.PasswordSortOrder.FILE_FIRST -> compareByDescending { it.type }
9799
}
98100
.then(compareBy(nullsLast(CaseInsensitiveComparator)) {

0 commit comments

Comments
 (0)