Skip to content

Commit 5baf371

Browse files
committed
Pass refreshing to the ui state
1 parent 0d90ed6 commit 5baf371

File tree

3 files changed

+6
-15
lines changed

3 files changed

+6
-15
lines changed

Jetcaster/core/data/src/main/java/com/example/jetcaster/core/data/repository/PodcastsRepository.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ import com.example.jetcaster.core.data.database.dao.TransactionRunner
2222
import com.example.jetcaster.core.data.network.PodcastRssResponse
2323
import com.example.jetcaster.core.data.network.PodcastsFetcher
2424
import com.example.jetcaster.core.data.network.SampleFeeds
25+
import javax.inject.Inject
2526
import kotlinx.coroutines.CoroutineDispatcher
2627
import kotlinx.coroutines.CoroutineScope
2728
import kotlinx.coroutines.Job
2829
import kotlinx.coroutines.flow.filter
2930
import kotlinx.coroutines.flow.map
3031
import kotlinx.coroutines.launch
31-
import javax.inject.Inject
3232

3333
/**
3434
* Data repository for Podcasts.

Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/home/Home.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,12 @@ import com.example.jetcaster.util.fullWidthItem
125125
import com.example.jetcaster.util.isCompact
126126
import com.example.jetcaster.util.quantityStringResource
127127
import com.example.jetcaster.util.radialGradientScrim
128-
import kotlinx.collections.immutable.PersistentList
129-
import kotlinx.collections.immutable.toPersistentList
130-
import kotlinx.coroutines.launch
131128
import java.time.Duration
132129
import java.time.LocalDateTime
133130
import java.time.OffsetDateTime
131+
import kotlinx.collections.immutable.PersistentList
132+
import kotlinx.collections.immutable.toPersistentList
133+
import kotlinx.coroutines.launch
134134

135135
data class HomeState(
136136
val windowSizeClass: WindowSizeClass,

Jetcaster/mobile/src/main/java/com/example/jetcaster/ui/home/HomeViewModel.kt

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package com.example.jetcaster.ui.home
1818

19-
import android.util.Log
2019
import androidx.compose.runtime.Immutable
2120
import androidx.lifecycle.ViewModel
2221
import androidx.lifecycle.viewModelScope
@@ -36,6 +35,7 @@ import com.example.jetcaster.core.model.asPodcastToEpisodeInfo
3635
import com.example.jetcaster.core.player.EpisodePlayer
3736
import com.example.jetcaster.core.player.model.PlayerEpisode
3837
import dagger.hilt.android.lifecycle.HiltViewModel
38+
import javax.inject.Inject
3939
import kotlinx.collections.immutable.PersistentList
4040
import kotlinx.collections.immutable.persistentListOf
4141
import kotlinx.collections.immutable.toPersistentList
@@ -47,7 +47,6 @@ import kotlinx.coroutines.flow.catch
4747
import kotlinx.coroutines.flow.flatMapLatest
4848
import kotlinx.coroutines.flow.shareIn
4949
import kotlinx.coroutines.launch
50-
import javax.inject.Inject
5150

5251
@OptIn(ExperimentalCoroutinesApi::class)
5352
@HiltViewModel
@@ -112,12 +111,6 @@ class HomeViewModel @Inject constructor(
112111
podcastCategoryFilterResult,
113112
libraryEpisodes ->
114113

115-
if (refreshing) {
116-
Log.d("Jetcaster", "refreshing: $refreshing, podcasts $podcasts")
117-
// TODO(mlykotom): this is equivalent of what we had before
118-
return@combine HomeScreenUiState(isLoading = true)
119-
}
120-
121114
_selectedCategory.value = filterableCategories.selectedCategory
122115

123116
// Override selected home category to show 'DISCOVER' if there are no
@@ -126,7 +119,7 @@ class HomeViewModel @Inject constructor(
126119
if (podcasts.isEmpty()) HomeCategory.Discover else homeCategory
127120

128121
HomeScreenUiState(
129-
isLoading = false,
122+
isLoading = refreshing,
130123
homeCategories = homeCategories,
131124
selectedHomeCategory = homeCategory,
132125
featuredPodcasts = podcasts.map { it.asExternalModel() }.toPersistentList(),
@@ -144,7 +137,6 @@ class HomeViewModel @Inject constructor(
144137
}.collect {
145138
_state.value = it
146139
}
147-
148140
}
149141

150142
refresh(force = false)
@@ -162,7 +154,6 @@ class HomeViewModel @Inject constructor(
162154
}
163155
}
164156

165-
166157
fun onCategorySelected(category: CategoryInfo) {
167158
_selectedCategory.value = category
168159
}

0 commit comments

Comments
 (0)