修复同一首歌的URL、歌词等同时需要换源时的处理问题

This commit is contained in:
lyswhut 2021-10-09 14:22:07 +08:00
parent dcd95a976c
commit 5a97c81540
2 changed files with 10 additions and 1 deletions

View File

@ -1,3 +1,4 @@
### 修复
- 修复kg源的歌单链接无法打开的问题
- 修复同一首歌的URL、歌词等同时需要换源时的处理问题

View File

@ -292,8 +292,13 @@ export const removeUserList = ({ id, isSync }) => async(dispatch, getState) => {
dispatch(playerAction.checkPlayList([id]))
}
const getOtherSourcePromises = new Map()
export const getOtherSource = ({ musicInfo, id }) => (dispatch, getState) => {
return (musicInfo.otherSource && musicInfo.otherSource.length ? Promise.resolve(musicInfo.otherSource) : findMusic(musicInfo)).then(otherSource => {
if (musicInfo.otherSource?.length) return Promise.resolve(musicInfo.otherSource)
let key = `${musicInfo.source}_${musicInfo.songmid}`
if (getOtherSourcePromises.has(key)) return getOtherSourcePromises.get(key)
const promise = findMusic(musicInfo).then(otherSource => {
const targetList = global.allList[id]
if (targetList) {
const index = targetList.indexOf(musicInfo)
@ -304,8 +309,11 @@ export const getOtherSource = ({ musicInfo, id }) => (dispatch, getState) => {
})
}
}
if (getOtherSourcePromises.has(key)) getOtherSourcePromises.delete(key)
return otherSource
})
getOtherSourcePromises.set(key, promise)
return promise
}
export const setUserListName = ({ id, name, isSync }) => async(dispatch, getState) => {