feat: 回复成功全局事件
This commit is contained in:
parent
117c401bf5
commit
a5e365a9d9
|
|
@ -26,6 +26,12 @@ sealed interface GlobalEvent {
|
|||
val id: String,
|
||||
val images: List<Uri>
|
||||
) : GlobalEvent
|
||||
|
||||
data class ReplySuccess(
|
||||
val threadId: String,
|
||||
val postId: String? = null,
|
||||
val subPostId: String? = null,
|
||||
) : GlobalEvent
|
||||
}
|
||||
|
||||
private val globalEventChannel: Channel<GlobalEvent> = Channel()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
package com.huanchengfly.tieba.post.repository
|
||||
|
||||
import com.huanchengfly.tieba.post.api.TiebaApi
|
||||
import com.huanchengfly.tieba.post.api.models.protos.addPost.AddPostResponse
|
||||
import com.huanchengfly.tieba.post.arch.GlobalEvent
|
||||
import com.huanchengfly.tieba.post.arch.emitGlobalEvent
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
|
||||
object AddPostRepository {
|
||||
fun addPost(
|
||||
content: String,
|
||||
forumId: String,
|
||||
forumName: String,
|
||||
threadId: String,
|
||||
tbs: String? = null,
|
||||
nameShow: String? = null,
|
||||
postId: String? = null,
|
||||
subPostId: String? = null,
|
||||
replyUserId: String? = null
|
||||
): Flow<AddPostResponse> =
|
||||
TiebaApi.getInstance()
|
||||
.addPostFlow(
|
||||
content,
|
||||
forumId,
|
||||
forumName,
|
||||
threadId,
|
||||
tbs,
|
||||
nameShow,
|
||||
postId,
|
||||
subPostId,
|
||||
replyUserId
|
||||
)
|
||||
.onEach {
|
||||
emitGlobalEvent(GlobalEvent.ReplySuccess(threadId, postId, subPostId))
|
||||
}
|
||||
}
|
||||
|
|
@ -5,7 +5,6 @@ import android.util.Log
|
|||
import androidx.compose.runtime.Stable
|
||||
import com.huanchengfly.tieba.post.App
|
||||
import com.huanchengfly.tieba.post.R
|
||||
import com.huanchengfly.tieba.post.api.TiebaApi
|
||||
import com.huanchengfly.tieba.post.api.models.UploadPictureResultBean
|
||||
import com.huanchengfly.tieba.post.api.models.protos.addPost.AddPostResponse
|
||||
import com.huanchengfly.tieba.post.api.retrofit.exception.TiebaUnknownException
|
||||
|
|
@ -19,6 +18,7 @@ import com.huanchengfly.tieba.post.arch.UiEvent
|
|||
import com.huanchengfly.tieba.post.arch.UiIntent
|
||||
import com.huanchengfly.tieba.post.arch.UiState
|
||||
import com.huanchengfly.tieba.post.components.ImageUploader
|
||||
import com.huanchengfly.tieba.post.repository.AddPostRepository
|
||||
import com.huanchengfly.tieba.post.utils.FileUtil
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
|
|
@ -98,8 +98,8 @@ class ReplyViewModel @Inject constructor() :
|
|||
)
|
||||
|
||||
private fun ReplyUiIntent.Send.producePartialChange(): Flow<ReplyPartialChange.Send> {
|
||||
return TiebaApi.getInstance()
|
||||
.addPostFlow(
|
||||
return AddPostRepository
|
||||
.addPost(
|
||||
content,
|
||||
forumId.toString(),
|
||||
forumName,
|
||||
|
|
|
|||
Loading…
Reference in New Issue