start adding of posts view
This commit is contained in:
parent
709e7a8583
commit
787f8d7526
@ -81,4 +81,8 @@ class BinaryServerContentStorage(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override suspend fun getContentPreview(id: ContentId): RegisteredContent? {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package dev.inmo.postssystem.features.content.server.storage
|
package dev.inmo.postssystem.features.content.server.storage
|
||||||
|
|
||||||
import dev.inmo.micro_utils.repos.ReadCRUDRepo
|
import dev.inmo.micro_utils.repos.ReadCRUDRepo
|
||||||
import dev.inmo.postssystem.features.content.common.ContentId
|
import dev.inmo.postssystem.features.content.common.*
|
||||||
import dev.inmo.postssystem.features.content.common.RegisteredContent
|
|
||||||
|
|
||||||
interface ServerReadContentStorage : ReadCRUDRepo<RegisteredContent, ContentId>
|
interface ServerReadContentStorage : ReadCRUDRepo<RegisteredContent, ContentId> {
|
||||||
|
suspend fun getContentPreview(id: ContentId): RegisteredContent?
|
||||||
|
}
|
||||||
|
@ -3,13 +3,13 @@ package dev.inmo.postssystem.features.content.text.server
|
|||||||
import com.benasher44.uuid.uuid4
|
import com.benasher44.uuid.uuid4
|
||||||
import dev.inmo.micro_utils.repos.exposed.AbstractExposedCRUDRepo
|
import dev.inmo.micro_utils.repos.exposed.AbstractExposedCRUDRepo
|
||||||
import dev.inmo.micro_utils.repos.exposed.initTable
|
import dev.inmo.micro_utils.repos.exposed.initTable
|
||||||
import dev.inmo.postssystem.features.content.common.ContentId
|
import dev.inmo.postssystem.features.content.common.*
|
||||||
import dev.inmo.postssystem.features.content.common.RegisteredContent
|
|
||||||
import dev.inmo.postssystem.features.content.server.storage.ServerContentStorage
|
import dev.inmo.postssystem.features.content.server.storage.ServerContentStorage
|
||||||
import dev.inmo.postssystem.features.content.text.common.TextContent
|
import dev.inmo.postssystem.features.content.text.common.TextContent
|
||||||
import org.jetbrains.exposed.sql.*
|
import org.jetbrains.exposed.sql.*
|
||||||
import org.jetbrains.exposed.sql.statements.InsertStatement
|
import org.jetbrains.exposed.sql.statements.InsertStatement
|
||||||
import org.jetbrains.exposed.sql.statements.UpdateStatement
|
import org.jetbrains.exposed.sql.statements.UpdateStatement
|
||||||
|
import org.jetbrains.exposed.sql.transactions.transaction
|
||||||
|
|
||||||
class TextServerContentStorage(
|
class TextServerContentStorage(
|
||||||
override val database: Database
|
override val database: Database
|
||||||
@ -50,4 +50,19 @@ class TextServerContentStorage(
|
|||||||
TextContent(get(textColumn))
|
TextContent(get(textColumn))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override suspend fun getContentPreview(id: ContentId): RegisteredContent? = transaction(database) {
|
||||||
|
select { selectById(id) }.limit(1).firstOrNull() ?.let {
|
||||||
|
val text = it[textColumn]
|
||||||
|
val postfix = if (text.length > 1024) {
|
||||||
|
"..."
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
RegisteredContent(
|
||||||
|
id,
|
||||||
|
TextContent(text.take(1024) + postfix)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
package dev.inmo.postssystem.services.posts.client.ui.posts_list
|
||||||
|
|
||||||
|
import dev.inmo.postssystem.features.posts.common.Post
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
sealed class PostsListUIState {
|
||||||
|
@Serializable
|
||||||
|
object Loading : PostsListUIState()
|
||||||
|
@Serializable
|
||||||
|
data class Show(
|
||||||
|
val posts: List<Post>
|
||||||
|
) : PostsListUIState()
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user