Skip to content

Commit 20136d8

Browse files
authored
fix: sort identifiers with active first and ascending order (#2504)
1 parent a1b91e5 commit 20136d8

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

feature/client/src/commonMain/kotlin/com/mifos/feature/client/clientIdentitiesList/ClientIdentitiesListViewModel.kt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,22 @@ class ClientIdentitiesListViewModel(
117117
}
118118

119119
is DataState.Success -> {
120+
val sortedList = dataState.data.sortedWith(
121+
compareBy(
122+
{ identifier ->
123+
val s = identifier.status?.lowercase() ?: ""
124+
if (s.contains("active") && !s.contains("inactive")) 0 else 1
125+
},
126+
{ identifier ->
127+
identifier.description?.lowercase() ?: ""
128+
},
129+
),
130+
)
131+
120132
mutableStateFlow.update {
121133
it.copy(
122134
dialogState = null,
123-
clientIdentitiesList = dataState.data,
135+
clientIdentitiesList = sortedList,
124136
)
125137
}
126138
}

0 commit comments

Comments
 (0)