diff --git a/songfinder-app/src/main/kotlin/mikufan/cx/songfinder/backend/db/entity/Pv.kt b/songfinder-app/src/main/kotlin/mikufan/cx/songfinder/backend/db/entity/Pv.kt index c27000b..a5f2ea0 100644 --- a/songfinder-app/src/main/kotlin/mikufan/cx/songfinder/backend/db/entity/Pv.kt +++ b/songfinder-app/src/main/kotlin/mikufan/cx/songfinder/backend/db/entity/Pv.kt @@ -40,4 +40,13 @@ enum class PvService { Bandcamp; fun isOnlineService() = this != File && this != LocalFile + + companion object { + val currentlyRenderableEntries = listOf( + NicoNicoDouga, + Youtube, + SoundCloud, + Bilibili, + ) + } } \ No newline at end of file diff --git a/songfinder-app/src/main/kotlin/mikufan/cx/songfinder/backend/db/repository/PvRepository.kt b/songfinder-app/src/main/kotlin/mikufan/cx/songfinder/backend/db/repository/PvRepository.kt index 4e4640d..dcdcde4 100644 --- a/songfinder-app/src/main/kotlin/mikufan/cx/songfinder/backend/db/repository/PvRepository.kt +++ b/songfinder-app/src/main/kotlin/mikufan/cx/songfinder/backend/db/repository/PvRepository.kt @@ -1,9 +1,13 @@ package mikufan.cx.songfinder.backend.db.repository import mikufan.cx.songfinder.backend.db.entity.Pv +import mikufan.cx.songfinder.backend.db.entity.PvService import org.springframework.stereotype.Repository @Repository interface PvRepository : VocaDbRepository { - fun findAllBySongIdIn(songIds: List): List + fun findAllBySongIdInAndPvServiceIn( + songIds: List, + pvServices: List = PvService.currentlyRenderableEntries + ): List } \ No newline at end of file diff --git a/songfinder-app/src/main/kotlin/mikufan/cx/songfinder/backend/service/SongSearchService.kt b/songfinder-app/src/main/kotlin/mikufan/cx/songfinder/backend/service/SongSearchService.kt index e29d50c..7e18013 100644 --- a/songfinder-app/src/main/kotlin/mikufan/cx/songfinder/backend/service/SongSearchService.kt +++ b/songfinder-app/src/main/kotlin/mikufan/cx/songfinder/backend/service/SongSearchService.kt @@ -80,7 +80,7 @@ class SongSearchService( // 3. search all PVs val songIdToPv: Map> = withContext(ioDispatcher) { - pvRepo.findAllBySongIdIn(songIds) + pvRepo.findAllBySongIdInAndPvServiceIn(songIds) } .groupBy { it.songId } log.debug { "found $songIdToPv PVs" } @@ -166,8 +166,7 @@ class SongSearchService( songId: SongId, songIdToPvs: Map> ): List = songIdToPvs[songId]?.let { pvs -> - pvs.filter { it.pvService.isOnlineService() } - .map { PVInfo(it.pvId, it.pvService, it.pvType, it.extendedMetadata) } + pvs.map { PVInfo(it.pvId, it.pvService, it.pvType, it.extendedMetadata) } } ?: emptyList().also { log.warn { "No PV found for song $songId" } } diff --git a/songfinder-app/src/main/kotlin/mikufan/cx/songfinder/ui/component/main/ResultGridCell.kt b/songfinder-app/src/main/kotlin/mikufan/cx/songfinder/ui/component/main/ResultGridCell.kt index e95c6cc..05f787a 100644 --- a/songfinder-app/src/main/kotlin/mikufan/cx/songfinder/ui/component/main/ResultGridCell.kt +++ b/songfinder-app/src/main/kotlin/mikufan/cx/songfinder/ui/component/main/ResultGridCell.kt @@ -79,25 +79,16 @@ fun LazyGridItemScope.RealResultGridCell( callbacks: ResultCellCallbacks, modifier: Modifier = Modifier ) { - val filteredPvs: List by produceState(listOf()) { - value = result.pvs.filter { - it.pvService in listOf( - PvService.Youtube, - PvService.NicoNicoDouga, - PvService.SoundCloud, - PvService.Bilibili - ) - } - } + val pvs = result.pvs MusicCardTemplate( onCardClicked = { callbacks.onCardClicked(result) }, modifier.animateItemPlacement() ) { LazilyFetchedThumbnail( - filteredPvs, + pvs, provideThumbnailInfoCallback = callbacks.provideThumbnailInfo, ) - MusicInfo(result, filteredPvs) + MusicInfo(result, pvs) } }