mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-05 04:19:55 +00:00
reload streaming server if not initialized
This commit is contained in:
parent
6ef88f0609
commit
ac46d0ebdb
1 changed files with 17 additions and 0 deletions
|
|
@ -1,3 +1,5 @@
|
|||
const React = require('react');
|
||||
const { useServices } = require('stremio/services');
|
||||
const { useModelState } = require('stremio/common');
|
||||
|
||||
const initStreamingServer = () => ({
|
||||
|
|
@ -6,9 +8,24 @@ const initStreamingServer = () => ({
|
|||
});
|
||||
|
||||
const useStreamingServer = () => {
|
||||
const { core } = useServices();
|
||||
const loadStreamingServerAction = React.useMemo(() => {
|
||||
const streamingServer = core.getState('streaming_server');
|
||||
if (streamingServer.selected === null) {
|
||||
return {
|
||||
action: 'StreamingServer',
|
||||
args: {
|
||||
action: 'Reload'
|
||||
}
|
||||
};
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}, []);
|
||||
const streamingServer = useModelState({
|
||||
model: 'streaming_server',
|
||||
init: initStreamingServer,
|
||||
action: loadStreamingServerAction
|
||||
});
|
||||
return streamingServer;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue