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