fix(creator): 오디오 탭 owner reload를 보정한다
This commit is contained in:
@@ -10,7 +10,7 @@ import kr.co.vividnext.sodalive.common.ApiResponse
|
|||||||
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
|
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
|
||||||
import kr.co.vividnext.sodalive.v2.common.data.ContentSort
|
import kr.co.vividnext.sodalive.v2.common.data.ContentSort
|
||||||
import kr.co.vividnext.sodalive.v2.creator.channel.audio.data.CreatorChannelAudioTabResponse
|
import kr.co.vividnext.sodalive.v2.creator.channel.audio.data.CreatorChannelAudioTabResponse
|
||||||
import kr.co.vividnext.sodalive.v2.creator.channel.audio.model.CreatorChannelAudioContentUiModel
|
import kr.co.vividnext.sodalive.v2.creator.channel.model.CreatorChannelAudioContentUiModel
|
||||||
import kr.co.vividnext.sodalive.v2.creator.channel.audio.model.CreatorChannelAudioRateUiModel
|
import kr.co.vividnext.sodalive.v2.creator.channel.audio.model.CreatorChannelAudioRateUiModel
|
||||||
import kr.co.vividnext.sodalive.v2.creator.channel.audio.model.CreatorChannelAudioThemeUiModel
|
import kr.co.vividnext.sodalive.v2.creator.channel.audio.model.CreatorChannelAudioThemeUiModel
|
||||||
import kr.co.vividnext.sodalive.v2.creator.channel.audio.model.effectiveSelectedThemeId
|
import kr.co.vividnext.sodalive.v2.creator.channel.audio.model.effectiveSelectedThemeId
|
||||||
@@ -35,7 +35,8 @@ class CreatorChannelAudioViewModel(
|
|||||||
|
|
||||||
fun loadAudio(creatorId: Long, isOwner: Boolean) {
|
fun loadAudio(creatorId: Long, isOwner: Boolean) {
|
||||||
if (creatorId <= 0) return
|
if (creatorId <= 0) return
|
||||||
if (this.creatorId == creatorId && _audioStateLiveData.value != null) return
|
val shouldSkipReload = this.creatorId == creatorId && this.isOwner == isOwner && _audioStateLiveData.value != null
|
||||||
|
if (shouldSkipReload) return
|
||||||
|
|
||||||
this.creatorId = creatorId
|
this.creatorId = creatorId
|
||||||
this.isOwner = isOwner
|
this.isOwner = isOwner
|
||||||
|
|||||||
@@ -210,6 +210,34 @@ class CreatorChannelAudioViewModelTest {
|
|||||||
verifyGetAudio(sort = ContentSort.POPULAR, themeId = null)
|
verifyGetAudio(sort = ContentSort.POPULAR, themeId = null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `같은 creatorId라도 owner 상태가 바뀌면 첫 페이지를 다시 조회하고 소장률을 갱신한다`() {
|
||||||
|
whenever(
|
||||||
|
repository.getAudio(
|
||||||
|
100L,
|
||||||
|
0,
|
||||||
|
CreatorChannelAudioViewModel.DEFAULT_PAGE_SIZE,
|
||||||
|
ContentSort.LATEST,
|
||||||
|
null,
|
||||||
|
"Bearer test-token"
|
||||||
|
)
|
||||||
|
).thenReturn(
|
||||||
|
Single.just(ApiResponse(true, audioResponse(themeId = null, ids = listOf(1L)), null)),
|
||||||
|
Single.just(ApiResponse(true, audioResponse(themeId = null, ids = listOf(2L)), null))
|
||||||
|
)
|
||||||
|
|
||||||
|
viewModel.loadAudio(100L, isOwner = false)
|
||||||
|
val guestState = viewModel.audioStateLiveData.requireValue() as CreatorChannelAudioUiState.Content
|
||||||
|
assertEquals(CreatorChannelAudioRateUiModel(75.0, 3, 4), guestState.rate)
|
||||||
|
|
||||||
|
viewModel.loadAudio(100L, isOwner = true)
|
||||||
|
|
||||||
|
val ownerState = viewModel.audioStateLiveData.requireValue() as CreatorChannelAudioUiState.Content
|
||||||
|
assertNull(ownerState.rate)
|
||||||
|
assertEquals(listOf(2L), ownerState.audioContents.map { it.audioContentId })
|
||||||
|
verifyGetAudio(themeId = null, times = 2)
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `같은 정렬 또는 같은 테마를 다시 선택하면 API를 재호출하지 않는다`() {
|
fun `같은 정렬 또는 같은 테마를 다시 선택하면 API를 재호출하지 않는다`() {
|
||||||
stubGetAudio(response = Single.just(ApiResponse(true, audioResponse(), null)))
|
stubGetAudio(response = Single.just(ApiResponse(true, audioResponse(), null)))
|
||||||
|
|||||||
Reference in New Issue
Block a user