simpliest version of content upload

This commit is contained in:
2022-03-10 21:35:32 +06:00
parent d15ace3c49
commit a06324568e
12 changed files with 190 additions and 60 deletions

View File

@@ -48,7 +48,7 @@ class ClientWritePostsService(
removeRoute
)
private val tempUploadFullPath = buildStandardUrl(
baseUrl,
root,
postsCreateTempPathPart
)
@@ -60,6 +60,7 @@ class ClientWritePostsService(
tempUploadFullPath,
provider.file
)
println(fileId)
it.copy(inputProvider = TempFileIdentifierInputProvider(fileId))
}
is TempFileIdentifierInputProvider -> it

View File

@@ -0,0 +1,15 @@
package dev.inmo.postssystem.services.posts.client.ui.create
import dev.inmo.postssystem.features.common.common.*
import dev.inmo.postssystem.features.content.common.Content
import kotlinx.coroutines.flow.StateFlow
class PostCreateUIViewModel(
private val model: PostCreateUIModel
) : UIViewModel<PostCreateUIState> {
override val currentState: StateFlow<PostCreateUIState>
get() = model.currentState
suspend fun create(content: List<Content>) {
model.create(content)
}
}

View File

@@ -3,9 +3,8 @@ package dev.inmo.postssystem.services.posts.client
import dev.inmo.micro_utils.common.MPPFile
import dev.inmo.micro_utils.ktor.client.UnifiedRequester
import dev.inmo.postssystem.features.files.common.FileId
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.*
import kotlinx.coroutines.GlobalScope.coroutineContext
import kotlinx.coroutines.job
import org.w3c.xhr.*
internal actual suspend fun UnifiedRequester.tempUpload(
@@ -39,7 +38,7 @@ internal actual suspend fun UnifiedRequester.tempUpload(
request.open("POST", fullTempUploadDraftPath, true)
request.send(formData)
coroutineContext.job.invokeOnCompletion {
currentCoroutineContext().job.invokeOnCompletion {
runCatching {
request.abort()
}