File tree Expand file tree Collapse file tree 1 file changed +12
-9
lines changed
common/src/commonMain/kotlin/cz/frantisekmasa/wfrp_master/common/compendium/journal Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import dev.gitlive.firebase.firestore.FirebaseFirestore
1414import kotlinx.coroutines.flow.Flow
1515import kotlinx.coroutines.flow.combine
1616import kotlinx.coroutines.flow.distinctUntilChanged
17+ import kotlinx.coroutines.flow.filter
1718import kotlinx.coroutines.flow.map
1819
1920class JournalScreenModel (
@@ -31,15 +32,17 @@ class JournalScreenModel(
3132 .right()
3233 .map { userProvider.userId == it.gameMasterId }
3334 .distinctUntilChanged()
34- val entries =
35- items
36- .combine(isGameMaster) { items, isGameMaster ->
37- if (isGameMaster) {
38- items
39- } else {
40- items.filter { it.isVisibleToPlayers }
41- }
35+ private val visibleItems =
36+ items.combine(isGameMaster) { items, isGameMaster ->
37+ if (isGameMaster) {
38+ items
39+ } else {
40+ items.filter { it.isVisibleToPlayers }
4241 }
42+ }
43+
44+ val entries =
45+ visibleItems
4346 .map { entries ->
4447 entries.map(JournalEntryItem ::fromEntry)
4548 }
@@ -88,7 +91,7 @@ class JournalScreenModel(
8891 }
8992
9093 val entriesTree: Flow <List <TreeItem >> =
91- items .map { items ->
94+ visibleItems .map { items ->
9295 val pinned =
9396 items.filter { it.isPinned }
9497 .map {
You can’t perform that action at this time.
0 commit comments