force Local source at LangSelect
This commit is contained in:
@@ -28,16 +28,31 @@ const useStyles = makeStyles(() => createStyles({
|
|||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
function removeAll(firstList: any[], secondList: any[]) {
|
||||||
|
console.log(secondList);
|
||||||
|
secondList.forEach((item) => {
|
||||||
|
const index = firstList.indexOf(item);
|
||||||
|
if (index !== -1) {
|
||||||
|
firstList.splice(index, 1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return firstList;
|
||||||
|
}
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
shownLangs: string[]
|
shownLangs: string[]
|
||||||
setShownLangs: (arg0: string[]) => void
|
setShownLangs: (arg0: string[]) => void
|
||||||
allLangs: string[]
|
allLangs: string[]
|
||||||
|
forcedLangs?: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ExtensionLangSelect(props: IProps) {
|
export default function ExtensionLangSelect(props: IProps) {
|
||||||
const { shownLangs, setShownLangs, allLangs } = props;
|
const {
|
||||||
|
shownLangs, setShownLangs, allLangs, forcedLangs,
|
||||||
|
} = props;
|
||||||
// hold a copy and only sate state on parent when OK pressed, improves performance
|
// hold a copy and only sate state on parent when OK pressed, improves performance
|
||||||
const [mShownLangs, setMShownLangs] = useState(shownLangs);
|
const [mShownLangs, setMShownLangs] = useState(removeAll(shownLangs, forcedLangs!));
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
const [open, setOpen] = useState<boolean>(false);
|
const [open, setOpen] = useState<boolean>(false);
|
||||||
|
|
||||||
@@ -109,3 +124,7 @@ export default function ExtensionLangSelect(props: IProps) {
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ExtensionLangSelect.defaultProps = {
|
||||||
|
forcedLangs: [] as string[],
|
||||||
|
};
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ export default function MangaSources() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, [shownLangs]);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setTitle('Sources');
|
setTitle('Sources');
|
||||||
@@ -68,6 +68,7 @@ export default function MangaSources() {
|
|||||||
shownLangs={shownLangs}
|
shownLangs={shownLangs}
|
||||||
setShownLangs={setShownLangs}
|
setShownLangs={setShownLangs}
|
||||||
allLangs={sourceToLangList(sources)}
|
allLangs={sourceToLangList(sources)}
|
||||||
|
forcedLangs={sourceForcedDefaultLangs()}
|
||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
}, [shownLangs, sources]);
|
}, [shownLangs, sources]);
|
||||||
|
|||||||
Reference in New Issue
Block a user