1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Refactoring duplicates onViewStyleChange

This commit is contained in:
grafixeyehero 2022-08-10 22:08:49 +03:00
parent 7543e494c9
commit 111cc430db
9 changed files with 19 additions and 111 deletions

View file

@ -9,11 +9,10 @@ type SelectViewProps = {
getCurrentViewStyle: () => string;
query: IQuery;
savedViewKey: string;
onViewStyleChange: () => void;
reloadItems: () => void;
}
const SelectView: FunctionComponent<SelectViewProps> = ({ getCurrentViewStyle, savedViewKey, query, onViewStyleChange, reloadItems }: SelectViewProps) => {
const SelectView: FunctionComponent<SelectViewProps> = ({ getCurrentViewStyle, savedViewKey, query, reloadItems }: SelectViewProps) => {
const element = useRef<HTMLDivElement>(null);
useEffect(() => {
@ -25,10 +24,9 @@ const SelectView: FunctionComponent<SelectViewProps> = ({ getCurrentViewStyle, s
const viewStyle = (e as CustomEvent).detail.viewStyle;
userSettings.set(savedViewKey, viewStyle, false);
query.StartIndex = 0;
onViewStyleChange();
reloadItems();
});
}, [getCurrentViewStyle, onViewStyleChange, query, reloadItems, savedViewKey]);
}, [getCurrentViewStyle, query, reloadItems, savedViewKey]);
return (
<div ref={element}>