mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-20 19:02:15 +00:00
filter models that actually updated
This commit is contained in:
parent
11be6d8f8c
commit
5889b422c3
1 changed files with 9 additions and 5 deletions
|
|
@ -81,18 +81,22 @@ const useModelState = ({ action, ...args }) => {
|
|||
}
|
||||
}
|
||||
);
|
||||
React.useLayoutEffect(() => {
|
||||
React.useInsertionEffect(() => {
|
||||
if (action) {
|
||||
core.transport.dispatch(action, model);
|
||||
}
|
||||
}, [action]);
|
||||
React.useLayoutEffect(() => {
|
||||
React.useInsertionEffect(() => {
|
||||
return () => {
|
||||
core.transport.dispatch({ action: 'Unload' }, model);
|
||||
};
|
||||
}, []);
|
||||
React.useLayoutEffect(() => {
|
||||
const onNewStateThrottled = throttle(async () => {
|
||||
React.useInsertionEffect(() => {
|
||||
const onNewStateThrottled = throttle(async (models) => {
|
||||
if (models.indexOf(model) === -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
const state = await core.transport.getState(model);
|
||||
if (typeof map === 'function') {
|
||||
setState(map(state));
|
||||
|
|
@ -111,7 +115,7 @@ const useModelState = ({ action, ...args }) => {
|
|||
core.transport.off('NewState', onNewStateThrottled);
|
||||
};
|
||||
}, [routeFocused]);
|
||||
React.useLayoutEffect(() => {
|
||||
React.useInsertionEffect(() => {
|
||||
mountedRef.current = true;
|
||||
}, []);
|
||||
return state;
|
||||
|
|
|
|||
Loading…
Reference in a new issue