mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-19 22:12:13 +00:00
initialize metaState using the metaStateReducer
This commit is contained in:
parent
455be7ead1
commit
391167c26f
1 changed files with 12 additions and 7 deletions
|
|
@ -56,14 +56,19 @@ const Detail = ({ urlParams }) => {
|
|||
const [metaState, metaStateDispatch] = React.useReducer(
|
||||
metaStateReducer,
|
||||
[metaResourceRef, metaGroups],
|
||||
([resourceRef, groups]) => {
|
||||
const readyGroup = groups.find((group) => group.content.type === 'Ready');
|
||||
const selectedGroup = readyGroup ? readyGroup : null;
|
||||
return {
|
||||
resourceRef,
|
||||
groups,
|
||||
selectedGroup
|
||||
([metaResourceRef, metaGroups]) => {
|
||||
const initialState = {
|
||||
resourceRef: null,
|
||||
groups: [],
|
||||
selectedGroup: null
|
||||
};
|
||||
const initAction = {
|
||||
type: 'groups-changed',
|
||||
resourceRef: metaResourceRef,
|
||||
groups: metaGroups
|
||||
};
|
||||
|
||||
return metaStateReducer(initialState, initAction);
|
||||
}
|
||||
);
|
||||
React.useEffect(() => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue