refactor: improve library page, fix playbutton issues, improve overall app performance
This commit is contained in:
12 files changed
+1867
-2017
No files matched your search
@@ -109,180 +109,4 @@ function Library() {
|
||||
</Suspense>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
// const genres = useQuery({
|
||||
// queryKey: ["library", "genreItem", id],
|
||||
// queryFn: async () => {
|
||||
// if (!api) return null;
|
||||
// if (currentLib.data?.CollectionType === "music") {
|
||||
// const result = await getMusicGenresApi(api).getMusicGenres({
|
||||
// parentId: id,
|
||||
// userId: user?.Id,
|
||||
// });
|
||||
// return result.data;
|
||||
// }
|
||||
// const result = await getGenresApi(api).getGenres({
|
||||
// parentId: id,
|
||||
// userId: user?.Id,
|
||||
// });
|
||||
// return result.data;
|
||||
// },
|
||||
// });
|
||||
|
||||
// const [genreFilter, setGenreFilter] = useState<string[]>(() => {
|
||||
// const cachedVal = sessionStorage.getItem(
|
||||
// `library-${currentLib.data?.Id}-config_genreFilter`,
|
||||
// );
|
||||
// if (cachedVal) {
|
||||
// return JSON.parse(cachedVal);
|
||||
// }
|
||||
// return [];
|
||||
// });
|
||||
// const _handleGenreFilter = useCallback(
|
||||
// (e: ChangeEvent<HTMLInputElement>, genre: BaseItemDto) => {
|
||||
// if (e.target.checked) {
|
||||
// const genreFilterTemp = [...genreFilter, genre.Id];
|
||||
// setGenreFilter((s) => (genre.Id ? [...s, genre.Id] : s));
|
||||
// sessionStorage.setItem(
|
||||
// `library-${currentLib.data?.Id}-config_genreFilter`,
|
||||
// JSON.stringify(genreFilterTemp),
|
||||
// );
|
||||
// } else {
|
||||
// const genreFilterTemp = genreFilter.filter((id) => id !== genre.Id);
|
||||
// setGenreFilter((s) => s.filter((id) => id !== genre.Id));
|
||||
// sessionStorage.setItem(
|
||||
// `library-${currentLib.data?.Id}-config_genreFilter`,
|
||||
// JSON.stringify(genreFilterTemp),
|
||||
// );
|
||||
// }
|
||||
// },
|
||||
// [genres.data?.Items?.length, id],
|
||||
// );
|
||||
|
||||
// const [currentViewType, setCurrentViewType] = useState<
|
||||
// BaseItemKind | "Artist"
|
||||
// >(undefined!);
|
||||
|
||||
// // DONE
|
||||
// const _availableViewTypes: ViewObject[] = useMemo(() => {
|
||||
// const result: ViewObject[] = undefined!;
|
||||
|
||||
// if (
|
||||
// sessionStorage.getItem(
|
||||
// `library-${currentLib.data?.Id}-config_currentViewType`,
|
||||
// )
|
||||
// ) {
|
||||
// setCurrentViewType(
|
||||
// sessionStorage.getItem(
|
||||
// `library-${currentLib.data?.Id}-config_currentViewType`,
|
||||
// ) as BaseItemKind | "Artist",
|
||||
// );
|
||||
// } else {
|
||||
// setCurrentViewType(result?.[0]?.value);
|
||||
// }
|
||||
// return result;
|
||||
// }, [currentLib.data?.CollectionType]);
|
||||
|
||||
// const [_videoTypesState, _setVideoTypesState] = useState<
|
||||
// Record<VideoType, boolean | undefined>
|
||||
// >({
|
||||
// VideoFile: undefined,
|
||||
// Iso: undefined,
|
||||
// BluRay: undefined,
|
||||
// Dvd: undefined,
|
||||
// });
|
||||
|
||||
// const [_sortBy, setSortBy] = useState<string>("Name");
|
||||
// const [_sortAscending, setSortAscending] = useState(
|
||||
// () =>
|
||||
// JSON.parse(
|
||||
// sessionStorage.getItem(
|
||||
// `library-${currentLib.data?.Id}-config_sort`,
|
||||
// ) as string,
|
||||
// )?.sortAscending ?? true,
|
||||
// );
|
||||
// useEffect(() => {
|
||||
// // I don't know why this works, don't ask...
|
||||
// const cachedVal = sessionStorage.getItem(
|
||||
// `library-${currentLib.data?.Id}-config_sort`,
|
||||
// ) as unknown as {
|
||||
// sortAscending?: boolean;
|
||||
// sortBy?: ItemSortBy;
|
||||
// };
|
||||
// if (cachedVal?.sortAscending) {
|
||||
// console.log(cachedVal.sortAscending);
|
||||
// setSortAscending(cachedVal.sortAscending);
|
||||
// }
|
||||
// }, [currentLib.data?.Id]);
|
||||
// const _sortByOptions: SortByObject[] = useMemo(() => {
|
||||
// const result: SortByObject[] = undefined!;
|
||||
|
||||
// const cachedVal = JSON.parse(
|
||||
// sessionStorage.getItem(
|
||||
// `library-${currentLib.data?.Id}-config_sort`,
|
||||
// ) as string,
|
||||
// );
|
||||
// if (cachedVal) {
|
||||
// setSortBy(cachedVal.sortBy);
|
||||
// } else {
|
||||
// setSortBy(result?.[0]?.value);
|
||||
// }
|
||||
// return result;
|
||||
// }, [currentLib.data?.CollectionType, currentViewType]);
|
||||
|
||||
// const [filters, _setFilters] = useState<Record<string, undefined | boolean>>(
|
||||
// () => {
|
||||
// const cachedVal = sessionStorage.getItem(
|
||||
// `library-${currentLib.data?.Id}-config_fliters`,
|
||||
// );
|
||||
// if (cachedVal !== null) {
|
||||
// return JSON.parse(cachedVal);
|
||||
// }
|
||||
// return {
|
||||
// isPlayed: false,
|
||||
// isUnPlayed: false,
|
||||
// isResumable: false,
|
||||
// isFavorite: false,
|
||||
// isLiked: false,
|
||||
// isUnliked: false,
|
||||
// hasSubtitles: false,
|
||||
// hasTrailer: false,
|
||||
// hasSpecialFeature: false,
|
||||
// hasThemeSong: false,
|
||||
// hasThemeVideo: false,
|
||||
// isBluRay: false,
|
||||
// isDVD: false,
|
||||
// isHD: undefined,
|
||||
// isSD: false,
|
||||
// is4K: false,
|
||||
// is3D: false,
|
||||
// };
|
||||
// },
|
||||
// );
|
||||
// useEffect(() => {
|
||||
// sessionStorage.setItem(
|
||||
// `library-${currentLib.data?.Id}-config_fliters`,
|
||||
// JSON.stringify(filters),
|
||||
// );
|
||||
// }, [filters, currentLib.data?.Id]);
|
||||
|
||||
// // const _rowVirtualizer = useWindowVirtualizer({
|
||||
// // count: items.data?.TotalRecordCount ?? 1,
|
||||
// // estimateSize: () => 80,
|
||||
// // overscan: 4,
|
||||
// // });
|
||||
// // const onlyStatusFilterViews = ["books", "music"];
|
||||
|
||||
// const [filterButtonAnchorEl, setFilterButtonAnchorEl] =
|
||||
// useState<HTMLButtonElement | null>(null);
|
||||
// const _filterMenuOpen = useMemo(
|
||||
// () => Boolean(filterButtonAnchorEl),
|
||||
// [filterButtonAnchorEl],
|
||||
// );
|
||||
// const _handleFilterDropdown = useCallback(
|
||||
// (e: MouseEvent<HTMLButtonElement>) => {
|
||||
// setFilterButtonAnchorEl(e.currentTarget);
|
||||
// },
|
||||
// [currentViewType, filterButtonAnchorEl],
|
||||
// );
|
||||
}
|
||||
Reference in new issue
Block a user