Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a bug #348

Merged
merged 2 commits into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure to create this issue if you haven't already done so

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes chef

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()
}
Loading