fix: 阅读楼层判断错误
This commit is contained in:
parent
7460a0cd29
commit
bb83341335
|
|
@ -541,20 +541,18 @@ fun ThreadPage(
|
||||||
initialValue = ModalBottomSheetValue.Hidden,
|
initialValue = ModalBottomSheetValue.Hidden,
|
||||||
skipHalfExpanded = true
|
skipHalfExpanded = true
|
||||||
)
|
)
|
||||||
val getLastVisibilityPost = {
|
|
||||||
data.firstOrNull { (post) ->
|
|
||||||
lazyListState.layoutInfo.visibleItemsInfo.lastOrNull { info -> info.key is Long }?.key as Long? == post.get { id }
|
|
||||||
}?.post ?: firstPost
|
|
||||||
}
|
|
||||||
val lastVisibilityPost by remember {
|
val lastVisibilityPost by remember {
|
||||||
derivedStateOf {
|
derivedStateOf {
|
||||||
data.firstOrNull { (post) ->
|
data.firstOrNull { (post) ->
|
||||||
lazyListState.layoutInfo.visibleItemsInfo.lastOrNull { info -> info.key is Long }?.key as Long? == post.get { id }
|
val lastPostKey = lazyListState.layoutInfo.visibleItemsInfo.lastOrNull { info ->
|
||||||
|
info.key is String && (info.key as String).startsWith("Post")
|
||||||
|
}?.key as String?
|
||||||
|
lastPostKey?.endsWith(post.get { id }.toString()) == true
|
||||||
}?.post ?: firstPost
|
}?.post ?: firstPost
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val lastVisibilityPostId = remember(lastVisibilityPost) {
|
val lastVisibilityPostId by remember {
|
||||||
lastVisibilityPost?.get { id } ?: 0L
|
derivedStateOf { lastVisibilityPost?.get { id } ?: 0L }
|
||||||
}
|
}
|
||||||
val coroutineScope = rememberCoroutineScope()
|
val coroutineScope = rememberCoroutineScope()
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
|
@ -630,11 +628,10 @@ fun ThreadPage(
|
||||||
dialogState = updateCollectMarkDialogState,
|
dialogState = updateCollectMarkDialogState,
|
||||||
onConfirm = {
|
onConfirm = {
|
||||||
coroutineScope.launch {
|
coroutineScope.launch {
|
||||||
val readPostId = getLastVisibilityPost()?.get { id } ?: 0L
|
|
||||||
navigator.navigateUp()
|
navigator.navigateUp()
|
||||||
if (readPostId != 0L) {
|
if (lastVisibilityPostId != 0L) {
|
||||||
TiebaApi.getInstance()
|
TiebaApi.getInstance()
|
||||||
.addStoreFlow(threadId, postId)
|
.addStoreFlow(threadId, lastVisibilityPostId)
|
||||||
.catch {
|
.catch {
|
||||||
context.toastShort(
|
context.toastShort(
|
||||||
R.string.message_update_collect_mark_failed,
|
R.string.message_update_collect_mark_failed,
|
||||||
|
|
@ -657,7 +654,7 @@ fun ThreadPage(
|
||||||
enabled = isCollected && !bottomSheetState.isVisible,
|
enabled = isCollected && !bottomSheetState.isVisible,
|
||||||
currentScreen = ThreadPageDestination
|
currentScreen = ThreadPageDestination
|
||||||
) {
|
) {
|
||||||
readFloorBeforeBack = getLastVisibilityPost()?.get { floor } ?: 0
|
readFloorBeforeBack = lastVisibilityPost?.get { floor } ?: 0
|
||||||
if (readFloorBeforeBack != 0) {
|
if (readFloorBeforeBack != 0) {
|
||||||
updateCollectMarkDialogState.show()
|
updateCollectMarkDialogState.show()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue