Compare commits
2 Commits
0f983d9286
...
5bbe0b8a0e
| Author | SHA1 | Date | |
|---|---|---|---|
| 5bbe0b8a0e | |||
| 9216c013ec |
@@ -8,7 +8,6 @@ import dev.inmo.postssystem.features.auth.client.ui.*
|
||||
import dev.inmo.postssystem.features.common.common.baseKoin
|
||||
import dev.inmo.postssystem.features.common.common.getAllDistinct
|
||||
import dev.inmo.postssystem.features.common.common.ui.fsm.UIFSMHandler
|
||||
import dev.inmo.postssystem.features.common.common.ui.fsm.UIFSMStateSerializer
|
||||
import dev.inmo.postssystem.services.posts.client.ui.list.PostsListUIFSMState
|
||||
import dev.inmo.postssystem.services.posts.client.ui.list.PostsListUIState
|
||||
import kotlinx.browser.*
|
||||
@@ -29,8 +28,7 @@ val defaultTypedSerializer = TypedSerializer<Any>(
|
||||
"Short" to Short.serializer(),
|
||||
"Byte" to Byte.serializer(),
|
||||
"Float" to Float.serializer(),
|
||||
"Double" to Double.serializer(),
|
||||
"UIFSMState" to UIFSMStateSerializer
|
||||
"Double" to Double.serializer()
|
||||
)
|
||||
val defaultSerialFormat = Json {
|
||||
ignoreUnknownKeys = true
|
||||
|
||||
@@ -4,9 +4,9 @@ import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
sealed interface AuthUIError {
|
||||
@Serializable
|
||||
// @Serializable
|
||||
object ServerUnavailable : AuthUIError
|
||||
@Serializable
|
||||
// @Serializable
|
||||
object AuthIncorrect : AuthUIError
|
||||
}
|
||||
|
||||
@@ -14,9 +14,9 @@ sealed interface AuthUIError {
|
||||
sealed interface AuthUIState {
|
||||
@Serializable
|
||||
data class Init(val showError: AuthUIError? = null) : AuthUIState
|
||||
@Serializable
|
||||
// @Serializable
|
||||
object Loading : AuthUIState
|
||||
@Serializable
|
||||
// @Serializable
|
||||
object Authorized : AuthUIState
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -25,8 +25,8 @@ typealias ContentIds = List<ContentId>
|
||||
* @see RegisteredPost
|
||||
*/
|
||||
@Serializable
|
||||
sealed class Post {
|
||||
abstract val content: ContentIds
|
||||
sealed interface Post {
|
||||
val content: ContentIds
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -35,7 +35,7 @@ sealed class Post {
|
||||
@Serializable
|
||||
data class NewPost(
|
||||
override val content: ContentIds
|
||||
) : Post()
|
||||
) : Post
|
||||
|
||||
/**
|
||||
* Registered [Post]
|
||||
@@ -46,12 +46,12 @@ data class RegisteredPost(
|
||||
override val content: ContentIds,
|
||||
@Serializable(DateTimeSerializer::class)
|
||||
val creationDate: DateTime
|
||||
) : Post()
|
||||
) : Post
|
||||
|
||||
@Serializable
|
||||
data class PostWithContent(
|
||||
val post: Post,
|
||||
val content: List<Content>
|
||||
val content: List<@Polymorphic Content>
|
||||
)
|
||||
|
||||
@Serializable
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
package dev.inmo.postssystem.server
|
||||
|
||||
import dev.inmo.micro_utils.ktor.server.configurators.ApplicationRoutingConfigurator
|
||||
import io.ktor.application.call
|
||||
import io.ktor.http.content.*
|
||||
import io.ktor.response.respondRedirect
|
||||
import io.ktor.routing.Route
|
||||
import io.ktor.routing.get
|
||||
import io.ktor.server.http.content.defaultResource
|
||||
import io.ktor.server.http.content.resources
|
||||
import io.ktor.server.routing.Route
|
||||
import java.io.File
|
||||
|
||||
class ClientStaticRoutingConfiguration(
|
||||
private val clientStatic: String?
|
||||
) : ApplicationRoutingConfigurator.Element {
|
||||
override fun Route.invoke() {
|
||||
resources("web")
|
||||
defaultResource("/web/index.html")
|
||||
resources(clientStatic)
|
||||
defaultResource("${clientStatic ?.let { "/$it" } ?: ""}/index.html")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,10 +32,10 @@ import dev.inmo.postssystem.features.content.server.storage.*
|
||||
import dev.inmo.postssystem.features.posts.server.*
|
||||
import dev.inmo.postssystem.features.publication.server.PublicationManager
|
||||
import dev.inmo.postssystem.services.posts.server.*
|
||||
import io.ktor.application.featureOrNull
|
||||
import io.ktor.application.log
|
||||
import io.ktor.routing.Route
|
||||
import io.ktor.routing.Routing
|
||||
import io.ktor.server.application.pluginOrNull
|
||||
import io.ktor.server.application.log
|
||||
import io.ktor.server.routing.Route
|
||||
import io.ktor.server.routing.Routing
|
||||
import io.ktor.server.engine.ApplicationEngine
|
||||
import io.ktor.server.netty.Netty
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
@@ -194,7 +194,7 @@ fun getDIModule(
|
||||
it.apply { configure() }
|
||||
}
|
||||
if (config.debugMode) {
|
||||
featureOrNull(Routing) ?.print()
|
||||
pluginOrNull(Routing) ?.print()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package dev.inmo.postssystem.server
|
||||
|
||||
import dev.inmo.micro_utils.ktor.server.configurators.StatusPagesConfigurator
|
||||
import io.ktor.application.call
|
||||
import io.ktor.features.StatusPages
|
||||
import io.ktor.server.application.call
|
||||
import io.ktor.http.HttpStatusCode
|
||||
import io.ktor.response.respondRedirect
|
||||
import io.ktor.server.plugins.statuspages.StatusPagesConfig
|
||||
import io.ktor.server.response.respondRedirect
|
||||
|
||||
data class NotFoundStatusPageRedirectToIndex(
|
||||
val redirectTo: String
|
||||
) : StatusPagesConfigurator.Element {
|
||||
override fun StatusPages.Configuration.invoke() {
|
||||
status(HttpStatusCode.NotFound) {
|
||||
override fun StatusPagesConfig.invoke() {
|
||||
status(HttpStatusCode.NotFound) { _ ->
|
||||
call.respondRedirect(redirectTo)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package dev.inmo.postssystem.server
|
||||
|
||||
import dev.inmo.micro_utils.ktor.server.configurators.KtorApplicationConfigurator
|
||||
import io.ktor.application.Application
|
||||
import io.ktor.application.install
|
||||
import io.ktor.websocket.WebSockets
|
||||
import io.ktor.server.application.Application
|
||||
import io.ktor.server.application.install
|
||||
import io.ktor.server.websocket.WebSockets
|
||||
|
||||
object WebSocketsConfigurator : KtorApplicationConfigurator {
|
||||
override fun Application.configure() {
|
||||
|
||||
@@ -3,14 +3,14 @@ package dev.inmo.postssystem.services.posts.client.ui.create
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
sealed class PostCreateUIState {
|
||||
@Serializable
|
||||
object Init : PostCreateUIState()
|
||||
@Serializable
|
||||
object Uploading : PostCreateUIState()
|
||||
@Serializable
|
||||
object Fail : PostCreateUIState()
|
||||
@Serializable
|
||||
object Completed : PostCreateUIState()
|
||||
sealed interface PostCreateUIState {
|
||||
// @Serializable
|
||||
object Init : PostCreateUIState
|
||||
// @Serializable
|
||||
object Uploading : PostCreateUIState
|
||||
// @Serializable
|
||||
object Fail : PostCreateUIState
|
||||
// @Serializable
|
||||
object Completed : PostCreateUIState
|
||||
|
||||
}
|
||||
|
||||
@@ -4,13 +4,13 @@ import dev.inmo.postssystem.features.posts.common.RegisteredPostWithContent
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
sealed class PostsListUIState {
|
||||
@Serializable
|
||||
object Loading : PostsListUIState()
|
||||
sealed interface PostsListUIState {
|
||||
// @Serializable
|
||||
object Loading : PostsListUIState
|
||||
|
||||
@Serializable
|
||||
data class Show(
|
||||
val posts: List<RegisteredPostWithContent>
|
||||
) : PostsListUIState()
|
||||
) : PostsListUIState
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user