From dd4d55dd4fdfa181407eb48537d09a5d74d6abc3 Mon Sep 17 00:00:00 2001 From: F0x1d Date: Sat, 9 Nov 2024 15:27:07 +0300 Subject: [PATCH] [fix]: filters loglevel crash --- .../feature/filters/edit/presentation/EditFilterState.kt | 3 ++- .../feature/filters/edit/presentation/EditFilterViewModel.kt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/feature/filters/edit/src/main/kotlin/com/f0x1d/logfox/feature/filters/edit/presentation/EditFilterState.kt b/feature/filters/edit/src/main/kotlin/com/f0x1d/logfox/feature/filters/edit/presentation/EditFilterState.kt index ed3d3ce5..8b51953e 100644 --- a/feature/filters/edit/src/main/kotlin/com/f0x1d/logfox/feature/filters/edit/presentation/EditFilterState.kt +++ b/feature/filters/edit/src/main/kotlin/com/f0x1d/logfox/feature/filters/edit/presentation/EditFilterState.kt @@ -1,9 +1,10 @@ package com.f0x1d.logfox.feature.filters.edit.presentation import com.f0x1d.logfox.database.entity.UserFilter +import com.f0x1d.logfox.model.logline.LogLevel data class EditFilterState( val filter: UserFilter? = null, val including: Boolean = true, - val enabledLogLevels: List = emptyList(), + val enabledLogLevels: List = List(LogLevel.entries.size) { false }, ) diff --git a/feature/filters/edit/src/main/kotlin/com/f0x1d/logfox/feature/filters/edit/presentation/EditFilterViewModel.kt b/feature/filters/edit/src/main/kotlin/com/f0x1d/logfox/feature/filters/edit/presentation/EditFilterViewModel.kt index c1319cfc..25b107b8 100644 --- a/feature/filters/edit/src/main/kotlin/com/f0x1d/logfox/feature/filters/edit/presentation/EditFilterViewModel.kt +++ b/feature/filters/edit/src/main/kotlin/com/f0x1d/logfox/feature/filters/edit/presentation/EditFilterViewModel.kt @@ -47,7 +47,7 @@ class EditFilterViewModel @Inject constructor( .collect { filter -> if (filter == null) return@collect - val enabledLogLevels = List(7) { false }.toMutableList() + val enabledLogLevels = List(LogLevel.entries.size) { false }.toMutableList() val allowedLevels = filter.allowedLevels.map { it.ordinal } for (i in 0 until enabledLogLevels.size) { enabledLogLevels[i] = allowedLevels.contains(i)