first fully ready for trying system

This commit is contained in:
2022-03-11 22:26:06 +06:00
parent 559545438a
commit 369dcb12f5
24 changed files with 199 additions and 13 deletions

View File

@@ -2,20 +2,25 @@ package dev.inmo.postssystem.services.posts.client.ui.create
import dev.inmo.postssystem.features.common.common.AbstractUIModel
import dev.inmo.postssystem.features.content.common.Content
import dev.inmo.postssystem.publicators.simple.client.SimplePublicatorService
import dev.inmo.postssystem.services.posts.common.FullNewPost
import dev.inmo.postssystem.services.posts.common.WritePostsService
import kotlinx.coroutines.delay
class DefaultPostCreateUIModel(
private val postCreationService: WritePostsService
private val postCreationService: WritePostsService,
private val publicationService: SimplePublicatorService
) : PostCreateUIModel, AbstractUIModel<PostCreateUIState>(
PostCreateUIState.Init
) {
override suspend fun create(content: List<Content>) {
runCatching {
_currentState.value = PostCreateUIState.Uploading
postCreationService.create(
val post = postCreationService.create(
FullNewPost(content)
)
) ?: return@runCatching
delay(1000L)
publicationService.publish(post.id)
}.onFailure {
_currentState.value = PostCreateUIState.Fail
}.onSuccess {