Skip to content

Commit

Permalink
尝试修复软件启动时恢复上一次播放的歌曲可能导致软件崩溃的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
lyswhut committed May 24, 2021
1 parent 4322a21 commit f8b2966
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 9 deletions.
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,14 @@ const init = () => {
initMusicTools()
getPlayInfo().then(info => {
if (!info) return
global.restorePlayInfo = info
if (info.listId != LIST_ID_PLAY_TEMP) {
info.list = global.allList[info.listId]
if (info.list) info.list = info.list.list
}

if (!info.list || !info.list[info.index]) return
global.restorePlayInfo = info

store.dispatch(playerAction.setList({
list: {
list: info.list,
Expand Down
4 changes: 1 addition & 3 deletions publish/changeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
### 修复

- 修复手机分享的wy歌单、某些tx、kg歌单无法打开的问题
- 修复打开空的歌单时,点击播放全部会导致应用崩溃的问题
- 修复企鹅音乐搜索歌曲没有结果的问题
- 尝试修复软件启动时恢复上一次播放的歌曲可能导致软件崩溃的问题
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default memo(() => {
const handlePlayAll = useCallback(async() => {
if (!listDetailData.info.name) return
const list = await getListDetailAll(selectListInfo.id)
if (!list.length) return
// if (!list.length) return
setPlayList({
list: {
list,
Expand Down
2 changes: 1 addition & 1 deletion src/screens/Home/SongList/ListDetail/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { memo } from 'react'
import { View, Text, StyleSheet, ImageBackground } from 'react-native'
import { AppColors, BorderWidths } from '@/theme'
import { useGetter } from '@/store'
import ButtonBar from './ButtonBar'
import ButtonBar from './ActionBar'

const Header = memo(() => {
const selectListInfo = useGetter('songList', 'selectListInfo')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default () => {
}, [playMusicInfo, setJumpPosition, setNavActiveIndex, setPrevSelectListId])

useEffect(() => {
const url = playMusicInfo ? playMusicInfo.musicInfo.img : null
const url = playMusicInfo && playMusicInfo.musicInfo ? playMusicInfo.musicInfo.img : null
if (imgUrl == url) return
setImgUrl(url)
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default () => {
const downloadFileName = useGetter('common', 'downloadFileName')
const playMusicInfo = useGetter('player', 'playMusicInfo')
let title = '^-^'
if (playMusicInfo) {
if (playMusicInfo && playMusicInfo.musicInfo) {
title = downloadFileName.replace('歌手', playMusicInfo.musicInfo.singer).replace('歌名', playMusicInfo.musicInfo.name)
}
// console.log(playMusicInfo)
Expand Down
1 change: 1 addition & 0 deletions src/store/modules/player/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ export const getLrc = musicInfo => async(dispatch, getState) => {
}

export const setList = ({ list, index }) => (dispatch, getState) => {
if (!(list && list.list && list.list[index])) return
dispatch(setListInfo(list))

const state = getState()
Expand Down
2 changes: 1 addition & 1 deletion src/store/modules/player/getter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createSelector } from 'reselect'
import { LIST_ID_PLAY_TEMP, LIST_ID_PLAY_LATER } from '@/config/constant'
import { LIST_ID_PLAY_LATER } from '@/config/constant'


// sourceInfo(state, getters, rootState, { sourceNames }) {
Expand Down

0 comments on commit f8b2966

Please sign in to comment.