@@ -136,7 +136,6 @@ class SubscriptionsViewModel @Inject constructor(
136136 isLoading = true ,
137137 isLoadingMore = false ,
138138 isServerRefreshing = false ,
139- hasPendingRefresh = false ,
140139 errorMessage = null ,
141140 errorRequestId = null ,
142141 loadMoreError = false ,
@@ -161,7 +160,6 @@ class SubscriptionsViewModel @Inject constructor(
161160 videos = page.videos.distinctBy { video -> video.url },
162161 hasMore = page.hasMore,
163162 isServerRefreshing = page.refreshing,
164- hasPendingRefresh = false ,
165163 generatedAtMillis = page.generatedAtMillis,
166164 errorMessage = null ,
167165 errorRequestId = null ,
@@ -197,7 +195,7 @@ class SubscriptionsViewModel @Inject constructor(
197195 onFailure = { failure ->
198196 if (failure.requiresSubscriptionsPaginationRestart()) {
199197 refreshMonitorJob?.cancel()
200- offerRefresh()
198+ requestJob = viewModelScope.launch { loadFirstPage() }
201199 } else {
202200 networkRecovery.schedule(failure, SubscriptionsRecoveryRequest .Pagination )
203201 val details = errorMapper.details(failure, R .string.subscriptions_failed)
@@ -251,12 +249,13 @@ class SubscriptionsViewModel @Inject constructor(
251249 showRefreshFailure(failure)
252250 return @launch
253251 }
254- if (generation != expectedGeneration) return @launch
255- if (page.generation != expectedGeneration) {
256- offerRefresh()
257- return @launch
258- } else {
259- _state .update {
252+ when (subscriptionsGenerationAction(generation, expectedGeneration, page.generation)) {
253+ SubscriptionsGenerationAction .Stop -> return @launch
254+ SubscriptionsGenerationAction .Replace -> {
255+ viewModelScope.launch { acceptFirstPage(page, hadCachedContent = true ) }
256+ return @launch
257+ }
258+ SubscriptionsGenerationAction .Continue -> _state .update {
260259 it.copy(
261260 isServerRefreshing = page.refreshing,
262261 generatedAtMillis = page.generatedAtMillis,
@@ -268,19 +267,6 @@ class SubscriptionsViewModel @Inject constructor(
268267 }
269268 }
270269
271- private fun offerRefresh () {
272- nextCursor = null
273- _state .update {
274- it.copy(
275- isLoadingMore = false ,
276- isServerRefreshing = false ,
277- hasPendingRefresh = true ,
278- hasMore = false ,
279- loadMoreError = false ,
280- )
281- }
282- }
283-
284270 private suspend fun persistPage (page : SubscriptionsPage , append : Boolean ) {
285271 try {
286272 videoMetaRepository.cacheVideos(page.videos)
0 commit comments