Merge pull request #537 from Stremio/fix/core-error-handling

Fix core error handling
This commit is contained in:
Tim 2023-12-18 13:40:10 +01:00 committed by GitHub
commit 0be5b6061b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 42 additions and 25 deletions

14
package-lock.json generated
View file

@ -36,7 +36,7 @@
"react-i18next": "^12.1.1",
"react-is": "18.2.0",
"spatial-navigation-polyfill": "git+ssh://git@github.com/Stremio/spatial-navigation.git#64871b1422466f5f45d24ebc8bbd315b2ebab6a6",
"stremio-translations": "git+ssh://git@github.com/Stremio/stremio-translations.git#8e30d9961402a7389f1a6209d9dab5592f32c9d7",
"stremio-translations": "git+ssh://git@github.com/Stremio/stremio-translations.git#847c7675a0ad4f70787aebb88e2fd6e2ed9b9ccb",
"url": "0.11.0",
"use-long-press": "^3.1.5"
},
@ -13600,9 +13600,9 @@
}
},
"node_modules/stremio-translations": {
"version": "1.44.3",
"resolved": "git+ssh://git@github.com/Stremio/stremio-translations.git#8e30d9961402a7389f1a6209d9dab5592f32c9d7",
"integrity": "sha512-E8UqbRzVQzDFQvKLTztrtA2V8xL8JeYfi+hI9IWx9kwIMQ34no2hxuualXH7A4U0s8xlM6BQW4bcQlVKwflhEg==",
"version": "1.44.4",
"resolved": "git+ssh://git@github.com/Stremio/stremio-translations.git#847c7675a0ad4f70787aebb88e2fd6e2ed9b9ccb",
"integrity": "sha512-X+RBUiq9fEmjHft6R7BZLkLJY1Km/QK3LicrUddSYOV6qPEpyjhXsVDeaqppUEZGA4sFsd7daB3vgphmwM0MmQ==",
"license": "MIT"
},
"node_modules/string_decoder": {
@ -26007,9 +26007,9 @@
"dev": true
},
"stremio-translations": {
"version": "git+ssh://git@github.com/Stremio/stremio-translations.git#8e30d9961402a7389f1a6209d9dab5592f32c9d7",
"integrity": "sha512-E8UqbRzVQzDFQvKLTztrtA2V8xL8JeYfi+hI9IWx9kwIMQ34no2hxuualXH7A4U0s8xlM6BQW4bcQlVKwflhEg==",
"from": "stremio-translations@git+ssh://git@github.com/Stremio/stremio-translations.git#8e30d9961402a7389f1a6209d9dab5592f32c9d7"
"version": "git+ssh://git@github.com/Stremio/stremio-translations.git#847c7675a0ad4f70787aebb88e2fd6e2ed9b9ccb",
"integrity": "sha512-X+RBUiq9fEmjHft6R7BZLkLJY1Km/QK3LicrUddSYOV6qPEpyjhXsVDeaqppUEZGA4sFsd7daB3vgphmwM0MmQ==",
"from": "stremio-translations@git+ssh://git@github.com/Stremio/stremio-translations.git#847c7675a0ad4f70787aebb88e2fd6e2ed9b9ccb"
},
"string_decoder": {
"version": "1.1.1",

View file

@ -39,7 +39,7 @@
"react-i18next": "^12.1.1",
"react-is": "18.2.0",
"spatial-navigation-polyfill": "git+ssh://git@github.com/Stremio/spatial-navigation.git#64871b1422466f5f45d24ebc8bbd315b2ebab6a6",
"stremio-translations": "git+ssh://git@github.com/Stremio/stremio-translations.git#8e30d9961402a7389f1a6209d9dab5592f32c9d7",
"stremio-translations": "git+ssh://git@github.com/Stremio/stremio-translations.git#847c7675a0ad4f70787aebb88e2fd6e2ed9b9ccb",
"url": "0.11.0",
"use-long-press": "^3.1.5"
},

View file

@ -146,8 +146,10 @@ const App = () => {
.catch((e) => console.error(e));
}
return () => {
window.removeEventListener('focus', onWindowFocus);
services.core.transport.off('CoreEvent', onCoreEvent);
if (services.core.active) {
window.removeEventListener('focus', onWindowFocus);
services.core.transport.off('CoreEvent', onCoreEvent);
}
};
}, [initialized]);
return (

View file

@ -1,12 +1,15 @@
// Copyright (C) 2017-2023 Smart code 203358507
const React = require('react');
const { useTranslation } = require('react-i18next');
const PropTypes = require('prop-types');
const classnames = require('classnames');
const { Button, Image } = require('stremio/common');
const styles = require('./styles');
const ErrorDialog = ({ className }) => {
const { t } = useTranslation();
const [dataCleared, setDataCleared] = React.useState(false);
const reload = React.useCallback(() => {
window.location.reload();
@ -22,13 +25,19 @@ const ErrorDialog = ({ className }) => {
src={require('/images/empty.png')}
alt={' '}
/>
<div className={styles['error-message']}>Something went wrong!</div>
<div className={styles['error-message']}>
{ t('GENERIC_ERROR_MESSAGE') }
</div>
<div className={styles['buttons-container']}>
<Button className={styles['button-container']} title={'Try again'} onClick={reload}>
<div className={styles['label']}>Try again</div>
<Button className={styles['button-container']} title={t('TRY_AGAIN')} onClick={reload}>
<div className={styles['label']}>
{ t('TRY_AGAIN') }
</div>
</Button>
<Button className={styles['button-container']} disabled={dataCleared} title={'Clear data'} onClick={clearData}>
<div className={styles['label']}>Clear data</div>
<Button className={styles['button-container']} disabled={dataCleared} title={t('CLEAR_DATA')} onClick={clearData}>
<div className={styles['label']}>
{ t('CLEAR_DATA') }
</div>
</Button>
</div>
</div>

View file

@ -7,12 +7,12 @@
flex-direction: column;
align-items: center;
justify-content: center;
gap: 1rem;
.error-image {
flex: none;
width: 12rem;
height: 12rem;
margin-bottom: 1rem;
object-fit: contain;
object-position: center;
opacity: 0.9;
@ -24,7 +24,7 @@
font-size: 2rem;
max-height: 3.6em;
text-align: center;
color: @color-surface-light5-90;
color: var(--primary-foreground-color);
}
.buttons-container {
@ -36,6 +36,8 @@
flex-wrap: wrap;
align-items: center;
justify-content: center;
gap: 1.5rem;
margin-top: 1rem;
.button-container {
flex-grow: 0;
@ -45,18 +47,23 @@
flex-direction: row;
align-items: center;
justify-content: center;
margin: 2rem 1rem 0;
padding: 0 1rem;
padding: 0 2.5rem;
min-width: 8rem;
height: 3rem;
background-color: @color-accent3;
height: 3.5rem;
border-radius: 3.5rem;
background-color: var(--overlay-color);
&:hover {
background-color: @color-accent3-light1;
outline: var(--focus-outline-size) solid var(--primary-foreground-color);
background-color: transparent;
}
&:active {
outline: none;
}
&:global(.disabled) {
background-color: @color-surface-dark5;
opacity: 0.3;
}
.label {
@ -67,7 +74,7 @@
font-size: 1.1rem;
font-weight: 500;
text-align: center;
color: @color-surface-light5-90;
color: var(--primary-foreground-color);
}
}
}

View file

@ -144,7 +144,6 @@ html {
.loader-container, .error-container {
width: 100%;
height: 100%;
background-color: @color-background-dark2;
}
}
}