From 2a2dcaaf65a5ecd0db180715bd915e2136e5665b Mon Sep 17 00:00:00 2001 From: Dylan Jeffers Date: Mon, 26 Sep 2022 12:28:25 -0700 Subject: [PATCH] [C-1174] Fix blank listening history screen --- .../empty-tile-cta/EmptyTileCTA.tsx} | 5 +- .../src/components/empty-tile-cta/index.ts | 1 + .../screens/favorites-screen/AlbumsTab.tsx | 4 +- .../screens/favorites-screen/PlaylistsTab.tsx | 4 +- .../screens/favorites-screen/TracksTab.tsx | 4 +- .../ListeningHistoryScreen.tsx | 56 +++++++++++-------- .../settings-screen/SettingRowLabel.tsx | 7 ++- 7 files changed, 46 insertions(+), 35 deletions(-) rename packages/mobile/src/{screens/favorites-screen/EmptyTab.tsx => components/empty-tile-cta/EmptyTileCTA.tsx} (82%) create mode 100644 packages/mobile/src/components/empty-tile-cta/index.ts diff --git a/packages/mobile/src/screens/favorites-screen/EmptyTab.tsx b/packages/mobile/src/components/empty-tile-cta/EmptyTileCTA.tsx similarity index 82% rename from packages/mobile/src/screens/favorites-screen/EmptyTab.tsx rename to packages/mobile/src/components/empty-tile-cta/EmptyTileCTA.tsx index 2c2717eca9..7e91d918e5 100644 --- a/packages/mobile/src/screens/favorites-screen/EmptyTab.tsx +++ b/packages/mobile/src/components/empty-tile-cta/EmptyTileCTA.tsx @@ -3,7 +3,7 @@ import { useCallback } from 'react' import { Button, EmptyTile } from 'app/components/core' import { useNavigation } from 'app/hooks/useNavigation' -import type { AppScreenParamList } from '../app-screen' +import type { AppScreenParamList } from '../../screens/app-screen' const messages = { afterSaved: "Once you have, this is where you'll find them!", @@ -14,7 +14,8 @@ type EmptyTabProps = { message: string } -export const EmptyTab = ({ message }: EmptyTabProps) => { +export const EmptyTileCTA = (props: EmptyTabProps) => { + const { message } = props const navigation = useNavigation() const onPress = useCallback(() => { diff --git a/packages/mobile/src/components/empty-tile-cta/index.ts b/packages/mobile/src/components/empty-tile-cta/index.ts new file mode 100644 index 0000000000..262be536e3 --- /dev/null +++ b/packages/mobile/src/components/empty-tile-cta/index.ts @@ -0,0 +1 @@ +export * from './EmptyTileCTA' diff --git a/packages/mobile/src/screens/favorites-screen/AlbumsTab.tsx b/packages/mobile/src/screens/favorites-screen/AlbumsTab.tsx index 33dc078e3b..37d2a2d241 100644 --- a/packages/mobile/src/screens/favorites-screen/AlbumsTab.tsx +++ b/packages/mobile/src/screens/favorites-screen/AlbumsTab.tsx @@ -7,8 +7,8 @@ import { useEffectOnce } from 'react-use' import { CollectionList } from 'app/components/collection-list' import { VirtualizedScrollView } from 'app/components/core' +import { EmptyTileCTA } from 'app/components/empty-tile-cta' -import { EmptyTab } from './EmptyTab' import { FilterInput } from './FilterInput' import { getAccountCollections } from './selectors' @@ -39,7 +39,7 @@ export const AlbumsTab = () => { return ( {!userAlbums?.length && !filterValue ? ( - + ) : ( <> { return ( {!userPlaylists?.length && !filterValue ? ( - + ) : ( { {!isLoading && hasNoFavorites && !filterValue ? ( - + ) : ( <> { const isPlaying = useSelector(getPlaying) const playingUid = useSelector(getUid) - useEffectOnce(() => { - dispatch(historyPageTracksLineupActions.fetchLineupMetadatas()) - }) + const fetchListeningHistory = useCallback(() => { + dispatch(tracksActions.fetchLineupMetadatas()) + }, [dispatch]) - const historyTracks = useSelector(getTracks) + useFocusEffect(fetchListeningHistory) - const status = historyTracks.status + const { status, entries } = useProxySelector(getTracks, []) const togglePlay = useCallback( (uid: UID, id: ID) => { @@ -81,24 +83,30 @@ export const ListeningHistoryScreen = () => { [dispatch, isPlaying, playingUid] ) + console.log('rerender') + return ( - - - - - + {status === Status.SUCCESS && entries.length === 0 ? ( + + ) : ( + + + + + + )} ) diff --git a/packages/mobile/src/screens/settings-screen/SettingRowLabel.tsx b/packages/mobile/src/screens/settings-screen/SettingRowLabel.tsx index cbbff4f5fb..2b1117a35f 100644 --- a/packages/mobile/src/screens/settings-screen/SettingRowLabel.tsx +++ b/packages/mobile/src/screens/settings-screen/SettingRowLabel.tsx @@ -6,6 +6,7 @@ import type { SvgProps } from 'react-native-svg' import type { StylesProps } from 'app/styles' import { makeStyles } from 'app/styles' +import { useThemeColors } from 'app/utils/theme' const useStyles = makeStyles(({ typography, palette, spacing }) => ({ root: { flexDirection: 'row', alignItems: 'center' }, @@ -13,8 +14,7 @@ const useStyles = makeStyles(({ typography, palette, spacing }) => ({ icon: { height: spacing(4), width: spacing(4), - marginRight: spacing(1), - fill: palette.neutral + marginRight: spacing(1) } })) @@ -33,6 +33,7 @@ type SettingsRowLabelProps = export const SettingsRowLabel = (props: SettingsRowLabelProps) => { const { label, styles: stylesProp, style } = props + const { neutral } = useThemeColors() const styles = useStyles() const renderIcon = () => { @@ -46,7 +47,7 @@ export const SettingsRowLabel = (props: SettingsRowLabelProps) => { )