Skip to content

Commit

Permalink
Initialize with 'All' filter (#854)
Browse files Browse the repository at this point in the history
  • Loading branch information
jocmp authored Feb 12, 2025
1 parent e496504 commit 09631e4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ fun ArticleScreen(
article = viewModel.article,
statusCount = statusCount,
refreshInterval = appPreferences.refreshInterval.get(),
onInitialized = viewModel::initialize,
onInitialized = { completion ->
viewModel.initialize(onComplete = completion)
},
onFeedRefresh = viewModel::refreshFeed,
drawerState = drawerState,
onSelectFolder = viewModel::selectFolder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,14 @@ class ArticleScreenViewModel(
}
}

fun initialize(onComplete: () -> Unit) {
fun initialize(
filter: ArticleFilter = ArticleFilter.default(),
onComplete: () -> Unit,
) {
refreshJob?.cancel()

refreshJob = viewModelScope.launch(Dispatchers.IO) {
account.refresh(latestFilter).onFailure { throwable ->
account.refresh(filter).onFailure { throwable ->
if (throwable is UnauthorizedError && _showUnauthorizedMessage == UnauthorizedMessageState.HIDE) {
_showUnauthorizedMessage = UnauthorizedMessageState.SHOW
}
Expand All @@ -266,7 +269,7 @@ class ArticleScreenViewModel(
}

fun refreshFeed(onComplete: () -> Unit) {
initialize {
initialize(latestFilter) {
updateArticlesSince()
onComplete()
}
Expand Down

0 comments on commit 09631e4

Please sign in to comment.