Skip to content

Commit

Permalink
Merge pull request #348 from G12-Wanderwave/fix-bug-spotify
Browse files Browse the repository at this point in the history
Fix a bug
  • Loading branch information
IB-12 authored May 19, 2024
2 parents a24e807 + 610fcce commit e95a829
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,11 @@ class BeaconScreenViewModelTest {
assertFalse(uiStateError.isLoading)
assertEquals("Test Exception", uiStateError.error)
}

@Test
fun emptyChildrenList_clearsChildrenPlaylistTrackList() = runBlockingTest {

// Act
viewModel.emptyChildrenList()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,11 @@ class ProfileViewModelTest {
ProfileViewModel.UIState(profile = null, isLoading = false, error = "Test Exception"),
viewModel.uiState.value)
}

@Test
fun emptyChildrenList_clearsChildrenPlaylistTrackList() = runBlockingTest {

// Act
viewModel.emptyChildrenList()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,11 @@ class TrackListViewModelTest {
assertEquals(emptyList<Track>(), viewModel.uiState.value.tracks)
assertEquals(false, viewModel.uiState.value.loading)
}

@Test
fun emptyChildrenList_clearsChildrenPlaylistTrackList() = runBlockingTest {

// Act
viewModel.emptyChildrenList()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,12 @@ fun handleItemClick(
viewModel.retrieveChild(listItem)
return
}
if (listItem.id.contains("spotify:") ||
listItem.id.isBlank()) { // TODO: create an issue for handling this
viewModel.emptyChildrenList()
navActions.goBack()
return
}

viewModel.addTrackToList(
if (isTopSongsListVisible) ListType.TOP_SONGS else ListType.LIKED_SONGS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ constructor(
playlistId, _childrenPlaylistTrackList, spotifyController, viewModelScope)
}

override fun emptyChildrenList() {
_childrenPlaylistTrackList.value = (emptyList())
}

fun changeChosenSongs() {
_isTopSongsListVisible.value = !_isTopSongsListVisible.value
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ constructor(
getLikedTracksFromSpotify(this._likedSongsTrackList, spotifyController, viewModelScope)
}

override fun emptyChildrenList() {
_childrenPlaylistTrackList.value = (emptyList())
}

data class UIState(
val profile: Profile? = null,
val isLoading: Boolean = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ constructor(
playlistId, _childrenPlaylistTrackList, spotifyController, viewModelScope)
}

override fun emptyChildrenList() {
_childrenPlaylistTrackList.value = (emptyList())
}

data class UiState(
val tracks: List<Track> = listOf(),
val loading: Boolean = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,6 @@ interface SpotifySongsActions {
* @last update 3.0
*/
fun getTracksFromPlaylist(playlistId: String)

fun emptyChildrenList()
}

0 comments on commit e95a829

Please sign in to comment.