Skip to content

Commit

Permalink
fix: 歌曲收藏到目标歌单后不可见问题
Browse files Browse the repository at this point in the history
  • Loading branch information
sigoden committed Nov 4, 2021
1 parent 866d0cc commit cb5c4ac
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/background/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export function togglePlaying () {

export function toggleMute () {
if (store.volume === 0) {
updateVolume(volumeMute)
updateVolume(volumeMute || COMMON_PROPS.volume)
} else {
volumeMute = store.volume
updateVolume(0)
Expand Down Expand Up @@ -150,9 +150,7 @@ export async function likeSong (playlistId) {
if (!playlistId) throw new Error(errMsg)
const res = await api.likeSong(playlistId, selectedSong.id, true)
if (res.code === 200) {
// 更新收藏到歌单
const playlist = store.playlists.find(v => v.id === playlistId)
await loadPlaylistDetails(playlist)
refreshPlaylistDetails(playlistId)
return { message: '收藏成功' }
} else {
throw new Error(errMsg)
Expand Down Expand Up @@ -382,6 +380,13 @@ async function loadPlaylistDetails (playlist) {
}
}

async function refreshPlaylistDetails (playlistId) {
const playlist = store.playlists.find(v => v.id === playlistId)
delete playlistDetailStore[playlistId]
await loadPlaylistDetails(playlist)
logger.debug('refreshPlaylistDetails', playlist.name)
}

async function loadSongDetail (playlistDetail, songId, retry) {
const { normalIndexes, invalidIndexes } = playlistDetail
let songsMap = songsStore[playlistDetail.id]
Expand Down

0 comments on commit cb5c4ac

Please sign in to comment.