修复打开歌单失败时会导致应用崩溃的问题

This commit is contained in:
lyswhut 2021-06-03 14:52:24 +08:00
parent 5f3a0b569a
commit 991feb953f
3 changed files with 27 additions and 18 deletions

View File

@ -14,7 +14,7 @@ const Header = memo(() => {
}
return (
<View style={{ ...styles.container }}>
<View style={{ ...styles.container, backgroundColor: theme.primary }}>
<Text style={{ ...styles.text, color: theme.normal20 }}>{t('load_failed')}</Text>
<Button onPress={back} style={{ ...styles.controlBtn, backgroundColor: theme.secondary40 }}>
<Text style={{ ...styles.controlBtnText, color: theme.secondary }}>{t('back')}</Text>
@ -25,7 +25,11 @@ const Header = memo(() => {
const styles = StyleSheet.create({
container: {
flex: 1,
position: 'absolute',
left: 0,
top: 0,
height: '100%',
width: '100%',
alignItems: 'center',
justifyContent: 'center',
},

View File

@ -16,7 +16,6 @@ export default ({ animatePlayed }) => {
const getListDetail = useDispatch('songList', 'getListDetail')
const handleListLoadMore = useCallback(() => {
// console.log(listDetailData)
if (listDetailData.isLoading || listDetailData.isEnd) return
getListDetail({ id: selectListInfoRef.current.id, page: listDetailData.page + 1 })
}, [getListDetail, listDetailData])
@ -29,9 +28,8 @@ export default ({ animatePlayed }) => {
}, [getListDetail])
return (
isGetListDetailFailed
? <Failed />
: <OnlineList
<>
<OnlineList
list={animatePlayed ? listDetailData.list : []}
page={-1}
// isEnd={listDetailData.isEnd}
@ -41,5 +39,8 @@ export default ({ animatePlayed }) => {
isLoading={listDetailData.isLoading}
ListHeaderComponent={<ListDetailHeader />}
/>
{ isGetListDetailFailed ? <Failed /> : null }
</>
)
}

View File

@ -16,6 +16,7 @@ export const TYPES = {
setListEnd: null,
setListDetailEnd: null,
setGetListDetailFailed: null,
clearListDetail: null,
}
for (const key of Object.keys(TYPES)) {
@ -169,11 +170,14 @@ export const setVisibleListDetail = isShow => {
payload: isShow,
}
}
export const setSelectListInfo = info => {
return {
export const setSelectListInfo = info => (dispatch, getState) => {
dispatch({
type: TYPES.setSelectListInfo,
payload: info,
}
})
dispatch({
type: TYPES.clearListDetail,
})
}
export const setGetListDetailFailed = isFailed => {
return {