fix: 收藏 SnackBar 不显示
This commit is contained in:
parent
9f6d854572
commit
c4f9ad8718
|
|
@ -293,7 +293,7 @@ val Post.contentRenders: ImmutableList<PbContentRender>
|
|||
get() {
|
||||
val renders = content.renders
|
||||
|
||||
renders.map {
|
||||
return renders.map {
|
||||
if (it is PicContentRender) {
|
||||
val data = getPhotoViewData(
|
||||
this,
|
||||
|
|
@ -305,7 +305,5 @@ val Post.contentRenders: ImmutableList<PbContentRender>
|
|||
)
|
||||
if (data != null) it.copy(photoViewData = wrapImmutable(data)) else it
|
||||
} else it
|
||||
}
|
||||
|
||||
return renders.toImmutableList()
|
||||
}.toImmutableList()
|
||||
}
|
||||
|
|
@ -3,9 +3,12 @@ package com.huanchengfly.tieba.post.arch
|
|||
import android.util.Log
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.DisposableEffect
|
||||
import androidx.compose.runtime.InternalComposeApi
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.State
|
||||
import androidx.compose.runtime.currentComposer
|
||||
import androidx.compose.runtime.produceState
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
|
|
@ -14,6 +17,7 @@ import androidx.lifecycle.LifecycleOwner
|
|||
import androidx.lifecycle.flowWithLifecycle
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
|
@ -79,19 +83,20 @@ inline fun <reified Event : UiEvent> Flow<UiEvent>.onEvent(
|
|||
}
|
||||
}
|
||||
|
||||
@OptIn(InternalComposeApi::class)
|
||||
@Composable
|
||||
inline fun <reified Event : UiEvent> BaseViewModel<*, *, *, *>.onEvent(
|
||||
noinline listener: suspend (Event) -> Unit
|
||||
) {
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
val applyContext = currentComposer.applyCoroutineContext
|
||||
val coroutineScope = remember(applyContext) { CoroutineScope(applyContext) }
|
||||
DisposableEffect(key1 = listener, key2 = this) {
|
||||
with(coroutineScope) {
|
||||
val job = launch {
|
||||
val job = coroutineScope.launch {
|
||||
uiEventFlow
|
||||
.filterIsInstance<Event>()
|
||||
.cancellable()
|
||||
.collect {
|
||||
launch {
|
||||
coroutineScope.launch {
|
||||
listener(it)
|
||||
}
|
||||
}
|
||||
|
|
@ -100,7 +105,6 @@ inline fun <reified Event : UiEvent> BaseViewModel<*, *, *, *>.onEvent(
|
|||
onDispose { job.cancel() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
inline fun <reified VM : BaseViewModel<*, *, *, *>> pageViewModel(): VM {
|
||||
|
|
|
|||
|
|
@ -58,7 +58,11 @@ object PbPageRepository {
|
|||
)
|
||||
}
|
||||
val firstPost = postList.firstOrNull { it.floor == 1 }
|
||||
?: response.data_.first_floor_post?.copy(author = response.data_.thread.author)
|
||||
?: response.data_.first_floor_post?.copy(
|
||||
author = response.data_.thread.author,
|
||||
from_forum = response.data_.forum,
|
||||
tid = response.data_.thread.id,
|
||||
)
|
||||
|
||||
response.copy(
|
||||
data_ = response.data_.copy(
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@ fun getPhotoViewData(
|
|||
picUrl: String,
|
||||
originUrl: String,
|
||||
showOriginBtn: Boolean,
|
||||
originSize: Int
|
||||
originSize: Int,
|
||||
seeLz: Boolean = false
|
||||
): PhotoViewData? {
|
||||
if (post.from_forum == null) return null
|
||||
return PhotoViewData(
|
||||
|
|
@ -28,7 +29,8 @@ fun getPhotoViewData(
|
|||
postId = post.id,
|
||||
objType = "pb",
|
||||
picId = picId,
|
||||
picIndex = 1
|
||||
picIndex = 1,
|
||||
seeLz = seeLz
|
||||
),
|
||||
picItems = listOf(
|
||||
PicItem(
|
||||
|
|
@ -51,6 +53,7 @@ fun getImmutablePhotoViewData(
|
|||
return wrapImmutable(getPhotoViewData(threadInfo, index))
|
||||
}
|
||||
|
||||
|
||||
fun getPhotoViewData(
|
||||
threadInfo: ThreadInfo,
|
||||
index: Int
|
||||
|
|
|
|||
Loading…
Reference in New Issue