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

Refactoring duplicates code

This commit is contained in:
grafixeyehero 2022-08-21 03:09:22 +03:00
parent 368a6064c2
commit cf137497a0
20 changed files with 491 additions and 513 deletions

View file

@ -8,11 +8,11 @@ import { IQuery } from './type';
type SelectViewProps = {
getCurrentViewStyle: () => string;
query: IQuery;
savedViewKey: string;
getViewSettings: () => string;
reloadItems: () => void;
}
const SelectView: FunctionComponent<SelectViewProps> = ({ getCurrentViewStyle, savedViewKey, query, reloadItems }: SelectViewProps) => {
const SelectView: FunctionComponent<SelectViewProps> = ({ getCurrentViewStyle, getViewSettings, query, reloadItems }: SelectViewProps) => {
const element = useRef<HTMLDivElement>(null);
useEffect(() => {
@ -22,11 +22,11 @@ const SelectView: FunctionComponent<SelectViewProps> = ({ getCurrentViewStyle, s
});
btnSelectView.addEventListener('layoutchange', (e) => {
const viewStyle = (e as CustomEvent).detail.viewStyle;
userSettings.set(savedViewKey, viewStyle, false);
userSettings.set(getViewSettings(), viewStyle, false);
query.StartIndex = 0;
reloadItems();
});
}, [getCurrentViewStyle, query, reloadItems, savedViewKey]);
}, [getCurrentViewStyle, query, reloadItems, getViewSettings]);
return (
<div ref={element}>