* refactor Conversation -> Convo
* extract Message and Convo mappers to core/domain module * improve reply container text
This commit is contained in:
+2
-2
@@ -53,7 +53,7 @@ class ChatMaterialsViewModelImpl(
|
||||
screenState.setValue { old ->
|
||||
old.copy(
|
||||
peerId = arguments.peerId,
|
||||
cmId = arguments.conversationMessageId
|
||||
cmId = arguments.cmId
|
||||
)
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ class ChatMaterialsViewModelImpl(
|
||||
isPaginationExhausted = paginationExhausted,
|
||||
cmId = if (loadedMaterials.size + offset > 200) {
|
||||
currentOffset.setValue { 0 }
|
||||
loadedMaterials.lastOrNull()?.conversationMessageId ?: -1
|
||||
loadedMaterials.lastOrNull()?.cmId ?: -1
|
||||
} else {
|
||||
screenState.value.cmId
|
||||
}
|
||||
|
||||
+11
-11
@@ -1,43 +1,43 @@
|
||||
package dev.meloda.fast.chatmaterials.model
|
||||
|
||||
sealed class UiChatMaterial(
|
||||
open val conversationMessageId: Long
|
||||
open val cmId: Long
|
||||
) {
|
||||
|
||||
data class Photo(
|
||||
override val conversationMessageId: Long,
|
||||
override val cmId: Long,
|
||||
val previewUrl: String
|
||||
) : UiChatMaterial(conversationMessageId)
|
||||
) : UiChatMaterial(cmId)
|
||||
|
||||
data class Video(
|
||||
override val conversationMessageId: Long,
|
||||
override val cmId: Long,
|
||||
val previewUrl: String?,
|
||||
val title: String,
|
||||
val views: Int,
|
||||
val duration: String
|
||||
) : UiChatMaterial(conversationMessageId)
|
||||
) : UiChatMaterial(cmId)
|
||||
|
||||
data class Audio(
|
||||
override val conversationMessageId: Long,
|
||||
override val cmId: Long,
|
||||
val previewUrl: String?,
|
||||
val title: String,
|
||||
val artist: String,
|
||||
val duration: String
|
||||
) : UiChatMaterial(conversationMessageId)
|
||||
) : UiChatMaterial(cmId)
|
||||
|
||||
data class File(
|
||||
override val conversationMessageId: Long,
|
||||
override val cmId: Long,
|
||||
val previewUrl: String?,
|
||||
val title: String,
|
||||
val size: String,
|
||||
val extension: String
|
||||
) : UiChatMaterial(conversationMessageId)
|
||||
) : UiChatMaterial(cmId)
|
||||
|
||||
data class Link(
|
||||
override val conversationMessageId: Long,
|
||||
override val cmId: Long,
|
||||
val previewUrl: String?,
|
||||
val title: String?,
|
||||
val url: String,
|
||||
val urlFirstChar: String
|
||||
) : UiChatMaterial(conversationMessageId)
|
||||
) : UiChatMaterial(cmId)
|
||||
}
|
||||
|
||||
+3
-3
@@ -11,7 +11,7 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
data class ChatMaterials(
|
||||
val peerId: Long,
|
||||
val conversationMessageId: Long
|
||||
val cmId: Long
|
||||
) {
|
||||
companion object {
|
||||
fun from(savedStateHandle: SavedStateHandle) =
|
||||
@@ -31,11 +31,11 @@ fun NavGraphBuilder.chatMaterialsScreen(
|
||||
}
|
||||
}
|
||||
|
||||
fun NavController.navigateToChatMaterials(peerId: Long, conversationMessageId: Long) {
|
||||
fun NavController.navigateToChatMaterials(peerId: Long, cmId: Long) {
|
||||
this.navigate(
|
||||
ChatMaterials(
|
||||
peerId = peerId,
|
||||
conversationMessageId = conversationMessageId
|
||||
cmId = cmId
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
+5
-5
@@ -17,7 +17,7 @@ fun VkAttachmentHistoryMessage.asPresentation(): UiChatMaterial? =
|
||||
AttachmentType.PHOTO -> {
|
||||
val attachment = this.attachment as VkPhotoDomain
|
||||
UiChatMaterial.Photo(
|
||||
conversationMessageId = this.conversationMessageId,
|
||||
cmId = this.cmId,
|
||||
previewUrl = attachment.getSizeOrSmaller(VkPhotoDomain.SIZE_TYPE_1080_1024)?.url.orEmpty()
|
||||
)
|
||||
}
|
||||
@@ -47,7 +47,7 @@ fun VkAttachmentHistoryMessage.asPresentation(): UiChatMaterial? =
|
||||
builder.toString().format(Locale.getDefault(), *args.toTypedArray())
|
||||
|
||||
UiChatMaterial.Video(
|
||||
conversationMessageId = this.conversationMessageId,
|
||||
cmId = this.cmId,
|
||||
previewUrl = attachment.images.maxByOrNull(VkVideoDomain.VideoImage::width)?.url.orEmpty(),
|
||||
title = attachment.title,
|
||||
views = attachment.views,
|
||||
@@ -80,7 +80,7 @@ fun VkAttachmentHistoryMessage.asPresentation(): UiChatMaterial? =
|
||||
builder.toString().format(Locale.getDefault(), *args.toTypedArray())
|
||||
|
||||
UiChatMaterial.Audio(
|
||||
conversationMessageId = this.conversationMessageId,
|
||||
cmId = this.cmId,
|
||||
previewUrl = null,
|
||||
title = attachment.title,
|
||||
artist = attachment.artist,
|
||||
@@ -112,7 +112,7 @@ fun VkAttachmentHistoryMessage.asPresentation(): UiChatMaterial? =
|
||||
}
|
||||
|
||||
UiChatMaterial.File(
|
||||
conversationMessageId = this.conversationMessageId,
|
||||
cmId = this.cmId,
|
||||
title = attachment.title,
|
||||
previewUrl = previewUrl,
|
||||
size = AndroidUtils.bytesToHumanReadableSize(attachment.size.toDouble()),
|
||||
@@ -124,7 +124,7 @@ fun VkAttachmentHistoryMessage.asPresentation(): UiChatMaterial? =
|
||||
val attachment = this.attachment as VkLinkDomain
|
||||
|
||||
UiChatMaterial.Link(
|
||||
conversationMessageId = this.conversationMessageId,
|
||||
cmId = this.cmId,
|
||||
title = attachment.title,
|
||||
previewUrl = attachment.photo?.getMaxSize()?.url,
|
||||
url = attachment.url,
|
||||
|
||||
Reference in New Issue
Block a user