mirror of
https://github.com/Ashinch/ReadYou.git
synced 2025-02-01 20:07:24 +01:00
fix(ui): remember swipe actions to avoid recomposition
This commit is contained in:
parent
4c7bea918d
commit
733c8d040b
@ -80,35 +80,43 @@ fun FlowPage(
|
||||
}
|
||||
|
||||
|
||||
val onToggleStarred: State<(ArticleWithFeed) -> Unit> = rememberUpdatedState {
|
||||
flowViewModel.updateStarredStatus(
|
||||
articleId = it.article.id,
|
||||
isStarred = !it.article.isStarred,
|
||||
withDelay = 300
|
||||
)
|
||||
val onToggleStarred: (ArticleWithFeed) -> Unit = remember {
|
||||
{
|
||||
flowViewModel.updateStarredStatus(
|
||||
articleId = it.article.id,
|
||||
isStarred = !it.article.isStarred,
|
||||
withDelay = 300
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
val onToggleRead: State<(ArticleWithFeed) -> Unit> = rememberUpdatedState {
|
||||
flowViewModel.updateReadStatus(
|
||||
groupId = null,
|
||||
feedId = null,
|
||||
articleId = it.article.id,
|
||||
conditions = MarkAsReadConditions.All,
|
||||
isUnread = !it.article.isUnread,
|
||||
withDelay = 300
|
||||
)
|
||||
val onToggleRead: (ArticleWithFeed) -> Unit = remember {
|
||||
{
|
||||
flowViewModel.updateReadStatus(
|
||||
groupId = null,
|
||||
feedId = null,
|
||||
articleId = it.article.id,
|
||||
conditions = MarkAsReadConditions.All,
|
||||
isUnread = !it.article.isUnread,
|
||||
withDelay = 300
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
val onSwipeEndToStart = when (swipeToStartAction) {
|
||||
SwipeStartActionPreference.None -> null
|
||||
SwipeStartActionPreference.ToggleRead -> onToggleRead.value
|
||||
SwipeStartActionPreference.ToggleStarred -> onToggleStarred.value
|
||||
val onSwipeEndToStart = remember(swipeToStartAction) {
|
||||
when (swipeToStartAction) {
|
||||
SwipeStartActionPreference.None -> null
|
||||
SwipeStartActionPreference.ToggleRead -> onToggleRead
|
||||
SwipeStartActionPreference.ToggleStarred -> onToggleStarred
|
||||
}
|
||||
}
|
||||
|
||||
val onSwipeStartToEnd = when (swipeToEndAction) {
|
||||
SwipeEndActionPreference.None -> null
|
||||
SwipeEndActionPreference.ToggleRead -> onToggleRead.value
|
||||
SwipeEndActionPreference.ToggleStarred -> onToggleStarred.value
|
||||
val onSwipeStartToEnd = remember(swipeToEndAction) {
|
||||
when (swipeToEndAction) {
|
||||
SwipeEndActionPreference.None -> null
|
||||
SwipeEndActionPreference.ToggleRead -> onToggleRead
|
||||
SwipeEndActionPreference.ToggleStarred -> onToggleStarred
|
||||
}
|
||||
}
|
||||
|
||||
LaunchedEffect(onSearch) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user