fix: 修复了当`listPosition`未初始化时错误的删除操作 (#2178)

* feat: 新增了 当`列表歌曲位置`未初始化时删除列表时的判断

* fix

---------

Co-authored-by: lyswhut <lyswhut@qq.com>
pull/2179/head
14K 2024-12-17 17:32:49 +08:00 committed by GitHub
parent d0090abd01
commit 9644163dc5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 4 deletions

View File

@ -166,8 +166,8 @@ export const userListsRemove = (ids: string[]) => {
const changedIds = []
for (const id of ids) {
removeUserList(id)
removeListPosition(id)
removeListUpdateInfo(id)
void removeListPosition(id)
void removeListUpdateInfo(id)
if (!allMusicList.has(id)) continue
removeMusicList(id)
changedIds.push(id)

View File

@ -56,7 +56,9 @@ export const setListPosition = async(id: string, position?: number) => {
listPosition[id] = position ?? 0
saveListPositionThrottle()
}
export const removeListPosition = (id: string) => {
export const removeListPosition = async(id: string) => {
await initPosition()
if (listPosition[id] == null) return
delete listPosition[id]
saveListPositionThrottle()
}
@ -124,7 +126,9 @@ export const setListUpdateTime = async(id: string, time: number) => {
// listUpdateInfo[id] = { updateTime, isAutoUpdate }
// saveListUpdateInfo()
// }
export const removeListUpdateInfo = (id: string) => {
export const removeListUpdateInfo = async(id: string) => {
await initListUpdateInfo()
if (listUpdateInfo[id] == null) return
delete listUpdateInfo[id]
saveListUpdateInfo()
}