Skip to content

[wip] Clear articles on drawer open #1003

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ fun ArticleLayout(
onSelectArticleFilter: () -> Unit,
onSelectStatus: (status: ArticleStatus) -> Unit,
onSelectArticle: (articleID: String) -> Unit,
onDrawerOpen: () -> Unit,
onNavigateToSettings: () -> Unit,
onRequestClearArticle: () -> Unit,
onToggleArticleRead: () -> Unit,
Expand Down Expand Up @@ -252,6 +253,7 @@ fun ArticleLayout(
fun openDrawer() {
coroutineScope.launchUI {
drawerState.open()
onDrawerOpen()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import com.capyreader.app.ui.collectChangesWithDefault
import com.capyreader.app.ui.components.ArticleSearch
import com.capyreader.app.ui.components.SearchState
import com.capyreader.app.ui.rememberLocalConnectivity
import com.jocmp.capy.ArticleStatus
import com.jocmp.capy.common.launchUI
import org.koin.androidx.compose.koinViewModel
import org.koin.compose.koinInject
Expand Down Expand Up @@ -89,6 +90,11 @@ fun ArticleScreen(
onRefresh = { filter, completion ->
viewModel.refresh(filter, completion)
},
onDrawerOpen = {
if (filter.status == ArticleStatus.UNREAD) {
viewModel.updateArticleTimeSince()
}
},
drawerState = drawerState,
onSelectFolder = viewModel::selectFolder,
onSelectFeed = viewModel::selectFeed,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ class ArticleScreenViewModel(

fun refresh(filter: ArticleFilter, onComplete: () -> Unit) {
initialize(filter) {
updateArticlesSince()
updateArticleTimeSince()
onComplete()
}
}
Expand Down Expand Up @@ -476,10 +476,10 @@ class ArticleScreenViewModel(

clearArticle()

updateArticlesSince()
updateArticleTimeSince()
}

private fun updateArticlesSince() {
fun updateArticleTimeSince() {
articlesSince.value = OffsetDateTime.now().plusSeconds(1)
}

Expand Down Expand Up @@ -597,7 +597,7 @@ class ArticleScreenViewModel(
private fun clearArticlesOnAllRead(
onArticlesCleared: () -> Unit,
) {
updateArticlesSince()
updateArticleTimeSince()
onArticlesCleared()
}

Expand Down