git.iko.soy/parseable-android
on master help sign in
Sort all datasets deterministically to ensure constant ordering (#21)
d49d52diko
app/src/main/java/com/parseable/android/data/local/FavoriteStreamDao.kt+1−1
@@ -12,7 +12,7 @@ interface FavoriteStreamDao {
12 @Query("SELECT * FROM favorite_streams ORDER BY addedAt DESC")
12 @Query("SELECT * FROM favorite_streams ORDER BY addedAt DESC")
13 fun getAll(): Flow<List<FavoriteStream>>
13 fun getAll(): Flow<List<FavoriteStream>>
14
14
15− @Query("SELECT streamName FROM favorite_streams")
15+ @Query("SELECT streamName FROM favorite_streams ORDER BY addedAt DESC")
16 fun getAllNames(): Flow<List<String>>
16 fun getAllNames(): Flow<List<String>>
17
17
18 @Insert(onConflict = OnConflictStrategy.REPLACE)
18 @Insert(onConflict = OnConflictStrategy.REPLACE)
app/src/main/java/com/parseable/android/ui/screens/alerts/AlertsViewModel.kt+4−1
@@ -33,7 +33,10 @@ class AlertsViewModel @Inject constructor(
33 _state.update { it.copy(isLoading = true, error = null) }
33 _state.update { it.copy(isLoading = true, error = null) }
34 when (val result = repository.listAlerts()) {
34 when (val result = repository.listAlerts()) {
35 is ApiResult.Success -> {
35 is ApiResult.Success -> {
36+ val sorted = result.data.sortedBy { a ->
37+ (a.name ?: a.title ?: "").lowercase()
38+ }
36− _state.update { it.copy(alerts = result.data, isLoading = false) }
39+ _state.update { it.copy(alerts = sorted, isLoading = false) }
37 }
40 }
38 is ApiResult.Error -> {
41 is ApiResult.Error -> {
39 _state.update { it.copy(isLoading = false, error = result.userMessage) }
42 _state.update { it.copy(isLoading = false, error = result.userMessage) }
app/src/main/java/com/parseable/android/ui/screens/logviewer/LogViewerViewModel.kt+4−2
@@ -123,7 +123,7 @@ class LogViewerViewModel @Inject constructor(
123 schemaJob = viewModelScope.launch {
123 schemaJob = viewModelScope.launch {
124 when (val result = repository.getStreamSchema(streamName)) {
124 when (val result = repository.getStreamSchema(streamName)) {
125 is ApiResult.Success -> {
125 is ApiResult.Success -> {
126− val columns = result.data.fields.map { it.name }
126+ val columns = result.data.fields.map { it.name }.sorted()
127 _state.update { it.copy(columns = columns) }
127 _state.update { it.copy(columns = columns) }
128 }
128 }
129 is ApiResult.Error -> { /* Schema loading failure is non-fatal */ }
129 is ApiResult.Error -> { /* Schema loading failure is non-fatal */ }
@@ -486,7 +486,9 @@ class LogViewerViewModel @Inject constructor(
486 _state.update { it.copy(savedFilters = it.savedFilters.copy(isLoading = true, error = null)) }
486 _state.update { it.copy(savedFilters = it.savedFilters.copy(isLoading = true, error = null)) }
487 when (val result = repository.listFilters()) {
487 when (val result = repository.listFilters()) {
488 is ApiResult.Success -> {
488 is ApiResult.Success -> {
489+ val streamFilters = result.data
489− val streamFilters = result.data.filter { it.streamName == _state.value.streamName }
490+ .filter { it.streamName == _state.value.streamName }
491+ .sortedBy { it.filterName.lowercase() }
490 _state.update {
492 _state.update {
491 it.copy(savedFilters = it.savedFilters.copy(filters = streamFilters, isLoading = false))
493 it.copy(savedFilters = it.savedFilters.copy(filters = streamFilters, isLoading = false))
492 }
494 }
app/src/main/java/com/parseable/android/ui/screens/streams/StreamsViewModel.kt+1−1
@@ -95,7 +95,7 @@ class StreamsViewModel @Inject constructor(
95 is ApiResult.Success -> {
95 is ApiResult.Success -> {
96 _state.update {
96 _state.update {
97 it.copy(
97 it.copy(
98− streams = streamsResult.data,
98+ streams = streamsResult.data.sortedBy { s -> s.name.lowercase() },
99 isLoading = false,
99 isLoading = false,
100 )
100 )
101 }
101 }