mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-05-04 22:19:03 +00:00
New loaded state
This commit is contained in:
parent
0c62d79312
commit
b1f917e3a9
2 changed files with 17 additions and 11 deletions
|
|
@ -180,7 +180,7 @@ const SectionsList = React.forwardRef(({ className, sections, preferences, onPre
|
||||||
<div key={'server_available'} className={classnames(styles['input-container'], styles['text-container'])}>
|
<div key={'server_available'} className={classnames(styles['input-container'], styles['text-container'])}>
|
||||||
<div className={styles['text']}>
|
<div className={styles['text']}>
|
||||||
<Icon className={classnames(styles['icon'], { [styles['x-icon']]: preferences.streaming_error })} icon={preferences.streaming_error ? 'ic_x' : 'ic_check'} />
|
<Icon className={classnames(styles['icon'], { [styles['x-icon']]: preferences.streaming_error })} icon={preferences.streaming_error ? 'ic_x' : 'ic_check'} />
|
||||||
<div className={styles['label']}>{'Streaming server is ' + (preferences.streaming_error ? 'not ' : '') + 'available. Reason: ' + preferences.streaming_error}</div>
|
<div className={styles['label']}>{'Streaming server is ' + (preferences.streaming_error ? 'not ' : '') + 'available.'}{preferences.streaming_error && ' Reason: ' + preferences.streaming_error}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,35 @@
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const { useServices } = require('stremio/services');
|
const { useServices } = require('stremio/services');
|
||||||
|
|
||||||
module.exports = () => {
|
const IGNORED_SETTINGS = Object.freeze(['user', 'streaming']);
|
||||||
const IGNORED_SETTINGS = Object.freeze(['user', 'streaming']);
|
|
||||||
|
|
||||||
|
module.exports = () => {
|
||||||
const { core } = useServices();
|
const { core } = useServices();
|
||||||
const [settings, setSettings] = React.useState({ streaming: {} });
|
|
||||||
|
const [settings, setSettings] = React.useState({
|
||||||
|
user: null,
|
||||||
|
streaming: {},
|
||||||
|
streaming_loaded: false,
|
||||||
|
streaming_error: ""
|
||||||
|
});
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
const onNewState = () => {
|
const onNewState = () => {
|
||||||
const state = core.getState()
|
const { ctx, streaming_server_settings } = core.getState()
|
||||||
try {
|
try {
|
||||||
const newSettings = {
|
const newSettings = {
|
||||||
...settings,
|
...settings,
|
||||||
...state.ctx.content.settings,
|
...ctx.content.settings,
|
||||||
user: state.ctx.content.auth ? state.ctx.content.auth.user : null,
|
user: ctx.content.auth ? ctx.content.auth.user : null,
|
||||||
streaming: state.streaming_server_settings && state.streaming_server_settings.ready || {},
|
streaming: streaming_server_settings && streaming_server_settings.ready || {},
|
||||||
streaming_loaded: state.streaming_server_settings && (state.streaming_server_settings.error || state.streaming_server_settings.ready),
|
streaming_loaded: streaming_server_settings && !!(streaming_server_settings.error || streaming_server_settings.ready),
|
||||||
streaming_error: state.streaming_server_settings && state.streaming_server_settings.error || "",
|
streaming_error: streaming_server_settings && streaming_server_settings.error || "",
|
||||||
};
|
};
|
||||||
setSettings(newSettings);
|
setSettings(newSettings);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Cannot update settings state', e);
|
console.log('Cannot update settings state', e);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
const onStoreError = ({ event, args }) => {
|
const onStoreError = ({ event, args }) => {
|
||||||
if (event !== "SettingsStoreError") return;
|
if (event !== "SettingsStoreError") return;
|
||||||
// TODO: Notify with maybe a toast?
|
// TODO: Notify with maybe a toast?
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue