From 3f1f9ad19659b593c169bb30f6800c0769ae11b7 Mon Sep 17 00:00:00 2001 From: Yuichiro Kinoshita Date: Tue, 28 Nov 2023 10:28:14 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=84=A1=E9=A7=84=E3=81=AB=E3=83=A1?= =?UTF-8?q?=E3=83=A2=E3=83=AA=E3=82=92=E7=A2=BA=E4=BF=9D=E3=81=97=E3=81=A6?= =?UTF-8?q?=E3=81=97=E3=81=BE=E3=82=8F=E3=81=AA=E3=81=84=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/converters/NoteDTOEntityConverter.kt | 3 ++- .../data/converters/TootDTOEntityConverter.kt | 12 +++++++----- .../data/infrastructure/note/impl/db/NoteRecord.kt | 14 ++++++++------ .../net/pantasystem/milktea/model/note/Note.kt | 10 +++++----- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/modules/data/src/main/java/net/pantasystem/milktea/data/converters/NoteDTOEntityConverter.kt b/modules/data/src/main/java/net/pantasystem/milktea/data/converters/NoteDTOEntityConverter.kt index dd89fa6f33..7b182f3764 100644 --- a/modules/data/src/main/java/net/pantasystem/milktea/data/converters/NoteDTOEntityConverter.kt +++ b/modules/data/src/main/java/net/pantasystem/milktea/data/converters/NoteDTOEntityConverter.kt @@ -216,7 +216,8 @@ class NoteDTOEntityConverter @Inject constructor( }, isRequireNyaize = isRequireNyaize, ), - maxReactionsPerAccount = 1 + maxReactionsPerAccount = 1, + emojiNameMap = emojiNameMap, ) } } diff --git a/modules/data/src/main/java/net/pantasystem/milktea/data/converters/TootDTOEntityConverter.kt b/modules/data/src/main/java/net/pantasystem/milktea/data/converters/TootDTOEntityConverter.kt index 260499c173..f0446488e5 100644 --- a/modules/data/src/main/java/net/pantasystem/milktea/data/converters/TootDTOEntityConverter.kt +++ b/modules/data/src/main/java/net/pantasystem/milktea/data/converters/TootDTOEntityConverter.kt @@ -86,6 +86,11 @@ class TootDTOEntityConverter @Inject constructor( imageCaches: Map, ): Note { return with(statusDTO) { + val emojis = emojis.map { + it.toEmoji(imageCaches[it.url]?.cachePath) + } + (emojiReactions?.mapNotNull { + it.getEmoji(imageCaches[it.url]?.cachePath) + } ?: emptyList()) Note( id = Note.Id(account.accountId, id), text = this.content, @@ -103,11 +108,7 @@ class TootDTOEntityConverter @Inject constructor( visibilityEx ), localOnly = null, - emojis = emojis.map { - it.toEmoji(imageCaches[it.url]?.cachePath) - } + (emojiReactions?.mapNotNull { - it.getEmoji(imageCaches[it.url]?.cachePath) - } ?: emptyList()), + emojis = emojis, app = null, reactionCounts = emojiReactions?.map { ReactionCount( @@ -149,6 +150,7 @@ class TootDTOEntityConverter @Inject constructor( pureText = text, isReactionAvailable = isReactionAvailable ), + emojiNameMap = emojis.associateBy { it.name } ) } } diff --git a/modules/data/src/main/java/net/pantasystem/milktea/data/infrastructure/note/impl/db/NoteRecord.kt b/modules/data/src/main/java/net/pantasystem/milktea/data/infrastructure/note/impl/db/NoteRecord.kt index e119c5f358..0b116ee1ae 100644 --- a/modules/data/src/main/java/net/pantasystem/milktea/data/infrastructure/note/impl/db/NoteRecord.kt +++ b/modules/data/src/main/java/net/pantasystem/milktea/data/infrastructure/note/impl/db/NoteRecord.kt @@ -198,6 +198,12 @@ data class NoteRecord( fun toModel(): Note { + val emojis = emojis?.map { CustomEmoji( + name = it.key, + url = it.value, + aspectRatio = customEmojiAspectRatioMap?.get(it.value)?.toFloatOrNull(), + cachePath = customEmojiUrlAndCachePathMap?.get(it.value) + ) } return Note( id = Note.Id(accountId, noteId), createdAt = createdAt.toInstant(), @@ -221,12 +227,7 @@ data class NoteRecord( it == entry.key } ?: false ) }, - emojis = emojis?.map { CustomEmoji( - name = it.key, - url = it.value, - aspectRatio = customEmojiAspectRatioMap?.get(it.value)?.toFloatOrNull(), - cachePath = customEmojiUrlAndCachePathMap?.get(it.value) - ) }, + emojis = emojis, repliesCount = repliesCount, fileIds = fileIds?.map { FileProperty.Id(accountId, it) }, poll = getPoll(), @@ -266,6 +267,7 @@ data class NoteRecord( else -> throw IllegalArgumentException() }, app = null, + emojiNameMap = emojis?.associateBy { it.name } ) } diff --git a/modules/model/src/main/java/net/pantasystem/milktea/model/note/Note.kt b/modules/model/src/main/java/net/pantasystem/milktea/model/note/Note.kt index 66284fa5a7..0967afe417 100644 --- a/modules/model/src/main/java/net/pantasystem/milktea/model/note/Note.kt +++ b/modules/model/src/main/java/net/pantasystem/milktea/model/note/Note.kt @@ -44,7 +44,9 @@ data class Note( val app: AppType.Misskey?, val channelId: Channel.Id?, val type: Type, - val maxReactionsPerAccount: Int) : Entity { + val maxReactionsPerAccount: Int, + val emojiNameMap: Map?, +) : Entity { class Id( val accountId: Long, val noteId: String, @@ -131,9 +133,6 @@ data class Note( val isAcceptingOnlyLikeReaction: Boolean = type is Type.Misskey && type.isAcceptingOnlyLikeReaction - val emojiNameMap = emojis?.associateBy { - it.name - } val isReacted: Boolean = reactionCounts.any { it.me @@ -303,6 +302,7 @@ fun Note.Companion.make( app = app, channelId = channelId, type = type, - maxReactionsPerAccount = maxReactionsPerAccount + maxReactionsPerAccount = maxReactionsPerAccount, + emojiNameMap = emojis?.associateBy { it.name }, ) } \ No newline at end of file