Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix - showing empty recent streams screen after deleting all streams #120

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/screens/recentStreams/RecentStreams.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Layout, Button } from '@dolbyio/uikit-react-native';
import { useIsFocused } from '@react-navigation/native';
import React, { useEffect } from 'react';
import { useIntl } from 'react-intl';
import { ScrollView, View, Pressable, LogBox } from 'react-native';
Expand All @@ -20,6 +21,7 @@ export const RecentStreams = ({ navigation }) => {
const dispatch = useDispatch();

const streamsList: StreamInfo[] = useSelector((state) => state.persistedSavedStreamsReducer.streams);
const isFocused = useIsFocused();

const playNewStreamTitle = intl.formatMessage({
id: 'playNewStream',
Expand Down Expand Up @@ -48,10 +50,18 @@ export const RecentStreams = ({ navigation }) => {
};

useEffect(() => {
if (streamsList.length === 0) {
navigateToUserInputIfRequired();
const unsubscribe = navigation.addListener('focus', () => {
navigateToUserInputIfRequired();
});
return unsubscribe;
}, [streamsList, isFocused]);

const navigateToUserInputIfRequired = () => {
if (streamsList.length === 0 && isFocused) {
navigation.navigate(Routes.UserInput);
}
}, [streamsList]);
};

useEffect(() => {
LogBox.ignoreLogs(['VirtualizedLists should never be nested']);
Expand Down
2 changes: 1 addition & 1 deletion src/screens/savedStreams/SavedStreams.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const SavedStreams = ({ navigation }) => {
</ScrollView>
) : (
<View style={styles.noStreamsMessageWrapper}>
<Text id="noSavedStreamsTitleText" type="h1" align="center" numberOfLines={2} />
<Text id="noSavedStreamsTitleText" type="h2" align="center" numberOfLines={2} />
<Text id="noSavedStreamssubtitleText" type="bodyDefault" color="secondary.200" />
</View>
)}
Expand Down
4 changes: 2 additions & 2 deletions src/screens/userInput/UserInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Layout, Input, Button, Icon, ValidationType } from '@dolbyio/uikit-reac
import useTheme from '@dolbyio/uikit-react-native/hooks/useAppTheme';
import React, { useState } from 'react';
import { useIntl } from 'react-intl';
import { Pressable, ScrollView, View } from 'react-native';
import { Pressable, ScrollView, View, Platform } from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import { useDispatch } from 'react-redux';

Expand Down Expand Up @@ -107,7 +107,7 @@ export const UserInput = ({ navigation }) => {
textColor="white"
onChangeText={onChangeStreamName}
validation={validation}
autoFocus
autoFocus={!Platform.isTV}
/>
<Input
value={accountId}
Expand Down
Loading