Skip to content

Commit

Permalink
feat: aspectsとファイルのキャッシュ位置を取得するように
Browse files Browse the repository at this point in the history
  • Loading branch information
pantasystem committed Nov 28, 2023
1 parent d071289 commit 8ad3f19
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,22 @@ internal class CustomEmojiRepositoryImpl @Inject constructor(

override suspend fun findByNames(host: String, names: List<String>): Result<List<CustomEmoji>> = runCancellableCatching {
withContext(ioDispatcher) {
customEmojiDAO.findByNames(host, names).map {
it.toModel()
val records = customEmojiDAO.findByNames(host, names)
val aspects = aspectRatioDataSource.findIn(records.mapNotNull {
it.url ?: it.uri
}).getOrElse { emptyList() }.associateBy {
it.uri
}
val fileCaches = imageCacheRepository.findBySourceUrls(records.mapNotNull {
it.url ?: it.uri
}).associateBy {
it.sourceUrl
}
records.map { record ->
record.toModel(
aspects[record.url ?: record.uri]?.aspectRatio,
fileCaches[record.url ?: record.uri]?.cachePath,
)
}
}
}
Expand Down

0 comments on commit 8ad3f19

Please sign in to comment.