Merge pull request #185 from thornbill/add-invalid-server-screen

Add error screen when saved server is invalid
This commit is contained in:
Bill Thornton 2020-12-15 16:38:06 -05:00 committed by GitHub
commit 26f3583927
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 9 deletions

View File

@ -40,12 +40,14 @@ const ErrorView = ({
<Text key={`errorview-details-${index}`} style={styles.details}>{detailText}</Text>
))}
</View>
<Button
containerStyle={styles.footer}
icon={buttonIcon}
title={buttonTitle}
onPress={onPress}
/>
{buttonTitle && (
<Button
containerStyle={styles.footer}
icon={buttonIcon}
title={buttonTitle}
onPress={onPress}
/>
)}
</View>
);
};
@ -62,8 +64,8 @@ ErrorView.propTypes = {
name: PropTypes.string,
type: PropTypes.string
}),
buttonTitle: PropTypes.string.isRequired,
onPress: PropTypes.func.isRequired
buttonTitle: PropTypes.string,
onPress: PropTypes.func
};
const styles = StyleSheet.create({

View File

@ -31,6 +31,10 @@
"heading": "Something went wrong!",
"description": "The Jellyfin server returned an error."
},
"invalidServer": {
"heading": "Server is invalid",
"description": "Something has happened and the saved server information is invalid. Try removing the server from Settings and add it again."
},
"offline": {
"heading": "Server offline?",
"description": "Error contacting Jellyfin server."

View File

@ -89,7 +89,7 @@ const HomeScreen = observer(() => {
{Platform.OS === 'ios' && !rootStore.isFullscreen && (
<View style={styles.statusBarSpacer} />
)}
{server && server.urlString && (
{server && server.urlString ? (
<NativeShellWebView
ref={webview}
style={webviewStyle}
@ -142,6 +142,11 @@ const HomeScreen = observer(() => {
setIsLoading(false);
}}
/>
) : (
<ErrorView
heading={t('home.errors.invalidServer.heading')}
message={t('home.errors.invalidServer.description')}
/>
)}
</SafeAreaView>
);