mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Merge pull request #4874 from grafixeyehero/Convert-ItemsContainer-to-react
Convert emby-ItemsContainer to react
This commit is contained in:
commit
83aec0253e
7 changed files with 568 additions and 39 deletions
|
@ -1,33 +0,0 @@
|
|||
import React, { FC, useEffect, useRef } from 'react';
|
||||
|
||||
import ItemsContainerElement from 'elements/ItemsContainerElement';
|
||||
import imageLoader from 'components/images/imageLoader';
|
||||
import 'elements/emby-itemscontainer/emby-itemscontainer';
|
||||
import { LibraryViewSettings, ViewMode } from 'types/library';
|
||||
|
||||
interface ItemsContainerI {
|
||||
libraryViewSettings: LibraryViewSettings;
|
||||
getItemsHtml: () => string
|
||||
}
|
||||
|
||||
const ItemsContainer: FC<ItemsContainerI> = ({ libraryViewSettings, getItemsHtml }) => {
|
||||
const element = useRef<HTMLDivElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const itemsContainer = element.current?.querySelector('.itemsContainer') as HTMLDivElement;
|
||||
itemsContainer.innerHTML = getItemsHtml();
|
||||
imageLoader.lazyChildren(itemsContainer);
|
||||
}, [getItemsHtml]);
|
||||
|
||||
const cssClass = libraryViewSettings.ViewMode === ViewMode.ListView ? 'vertical-list' : 'vertical-wrap';
|
||||
|
||||
return (
|
||||
<div ref={element}>
|
||||
<ItemsContainerElement
|
||||
className={`itemsContainer ${cssClass} centered padded-left padded-right padded-right-withalphapicker`}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ItemsContainer;
|
|
@ -11,9 +11,9 @@ import listview from 'components/listview/listview';
|
|||
import cardBuilder from 'components/cardbuilder/cardBuilder';
|
||||
import { playbackManager } from 'components/playback/playbackmanager';
|
||||
import globalize from 'scripts/globalize';
|
||||
import ItemsContainer from 'elements/emby-itemscontainer/ItemsContainer';
|
||||
import AlphabetPicker from './AlphabetPicker';
|
||||
import FilterButton from './filter/FilterButton';
|
||||
import ItemsContainer from './ItemsContainer';
|
||||
import NewCollectionButton from './NewCollectionButton';
|
||||
import Pagination from './Pagination';
|
||||
import PlayAllButton from './PlayAllButton';
|
||||
|
@ -67,7 +67,8 @@ const ItemsView: FC<ItemsViewProps> = ({
|
|||
const {
|
||||
isLoading,
|
||||
data: itemsResult,
|
||||
isPreviousData
|
||||
isPreviousData,
|
||||
refetch
|
||||
} = useGetItemsViewByType(
|
||||
viewType,
|
||||
parentId,
|
||||
|
@ -252,7 +253,10 @@ const ItemsView: FC<ItemsViewProps> = ({
|
|||
<Loading />
|
||||
) : (
|
||||
<ItemsContainer
|
||||
className='centered padded-left padded-right padded-right-withalphapicker'
|
||||
libraryViewSettings={libraryViewSettings}
|
||||
parentId={parentId}
|
||||
reloadItems={refetch}
|
||||
getItemsHtml={getItemsHtml}
|
||||
/>
|
||||
)}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue