mirror of
https://github.com/LiveFastEatTrashRaccoon/RaccoonForLemmy.git
synced 2025-02-10 07:10:39 +01:00
chore: avoid showing read post after "clear read" option
This commit is contained in:
parent
e4ec9e6606
commit
6c8d335394
@ -38,6 +38,7 @@ class CommunityDetailViewModel(
|
|||||||
|
|
||||||
private var currentPage: Int = 1
|
private var currentPage: Int = 1
|
||||||
private var pageCursor: String? = null
|
private var pageCursor: String? = null
|
||||||
|
private var hideReadPosts = false
|
||||||
|
|
||||||
override fun onStarted() {
|
override fun onStarted() {
|
||||||
mvi.onStarted()
|
mvi.onStarted()
|
||||||
@ -120,6 +121,7 @@ class CommunityDetailViewModel(
|
|||||||
private fun refresh() {
|
private fun refresh() {
|
||||||
currentPage = 1
|
currentPage = 1
|
||||||
pageCursor = null
|
pageCursor = null
|
||||||
|
hideReadPosts = false
|
||||||
mvi.updateState { it.copy(canFetchMore = true, refreshing = true) }
|
mvi.updateState { it.copy(canFetchMore = true, refreshing = true) }
|
||||||
val auth = identityRepository.authToken.value
|
val auth = identityRepository.authToken.value
|
||||||
mvi.scope?.launch(Dispatchers.IO) {
|
mvi.scope?.launch(Dispatchers.IO) {
|
||||||
@ -177,6 +179,12 @@ class CommunityDetailViewModel(
|
|||||||
pageCursor = pageCursor,
|
pageCursor = pageCursor,
|
||||||
sort = sort,
|
sort = sort,
|
||||||
)
|
)
|
||||||
|
}?.let {
|
||||||
|
if (hideReadPosts) {
|
||||||
|
it.copy(first = it.first.filter { p -> !p.read })
|
||||||
|
} else {
|
||||||
|
it
|
||||||
|
}
|
||||||
}?.let {
|
}?.let {
|
||||||
if (refreshing) {
|
if (refreshing) {
|
||||||
it
|
it
|
||||||
@ -470,6 +478,7 @@ class CommunityDetailViewModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun clearRead() {
|
private fun clearRead() {
|
||||||
|
hideReadPosts = true
|
||||||
mvi.updateState {
|
mvi.updateState {
|
||||||
val newPosts = it.posts.filter { e -> !e.read }
|
val newPosts = it.posts.filter { e -> !e.read }
|
||||||
it.copy(
|
it.copy(
|
||||||
|
@ -42,6 +42,7 @@ class PostListViewModel(
|
|||||||
private var currentPage: Int = 1
|
private var currentPage: Int = 1
|
||||||
private var pageCursor: String? = null
|
private var pageCursor: String? = null
|
||||||
private var firstLoad = true
|
private var firstLoad = true
|
||||||
|
private var hideReadPosts = false
|
||||||
|
|
||||||
init {
|
init {
|
||||||
notificationCenter.addObserver({
|
notificationCenter.addObserver({
|
||||||
@ -158,6 +159,7 @@ class PostListViewModel(
|
|||||||
private fun refresh() {
|
private fun refresh() {
|
||||||
currentPage = 1
|
currentPage = 1
|
||||||
pageCursor = null
|
pageCursor = null
|
||||||
|
hideReadPosts = false
|
||||||
mvi.updateState { it.copy(canFetchMore = true, refreshing = true) }
|
mvi.updateState { it.copy(canFetchMore = true, refreshing = true) }
|
||||||
loadNextPage()
|
loadNextPage()
|
||||||
}
|
}
|
||||||
@ -183,6 +185,12 @@ class PostListViewModel(
|
|||||||
type = type,
|
type = type,
|
||||||
sort = sort,
|
sort = sort,
|
||||||
)?.let {
|
)?.let {
|
||||||
|
if (hideReadPosts) {
|
||||||
|
it.copy(first = it.first.filter { p -> !p.read })
|
||||||
|
} else {
|
||||||
|
it
|
||||||
|
}
|
||||||
|
}?.let {
|
||||||
if (refreshing) {
|
if (refreshing) {
|
||||||
it
|
it
|
||||||
} else {
|
} else {
|
||||||
@ -459,6 +467,7 @@ class PostListViewModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun clearRead() {
|
private fun clearRead() {
|
||||||
|
hideReadPosts = true
|
||||||
mvi.updateState {
|
mvi.updateState {
|
||||||
val newPosts = it.posts.filter { e -> !e.read }
|
val newPosts = it.posts.filter { e -> !e.read }
|
||||||
it.copy(
|
it.copy(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user