Skip to content

Commit

Permalink
Update project
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbel committed Jul 16, 2024
1 parent 5baf077 commit 7af9c10
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
6 changes: 3 additions & 3 deletions desktopApp/user_preferences.preferences_pb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@


feed_view
*FeedList
*FeedGrid

palette


seed_color ���������

theme *NightNo
(
%

movie_list*TopRated(name=top_rated)
movie_list*Popular(name=popular)
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
@file:OptIn(ExperimentalCoroutinesApi::class)

package org.michaelbel.movies.feed

import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import org.michaelbel.movies.common.appearance.FeedView
import org.michaelbel.movies.common.list.MovieList
Expand All @@ -34,12 +36,11 @@ class FeedViewModel(
initialValue = runBlocking { interactor.currentMovieList.first() }
)

private val _pagingDataFlow = MutableStateFlow<List<MoviePojo>>(emptyList())
val pagingDataFlow = _pagingDataFlow.asStateFlow()

init {
viewModelScope.launch {
_pagingDataFlow.value = interactor.moviesResult(currentMovieList.value.nameOrLocalList)
}
}
val pagingDataFlow: StateFlow<List<MoviePojo>> = currentMovieList.flatMapLatest { movieList ->
flowOf(interactor.moviesResult(movieList.nameOrLocalList))
}.stateIn(
scope = viewModelScope,
started = SharingStarted.Lazily,
initialValue = emptyList()
)
}

0 comments on commit 7af9c10

Please sign in to comment.