mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Migrate Movies
This commit is contained in:
parent
122c4ae600
commit
479c53eb8b
21 changed files with 1713 additions and 7 deletions
48
src/view/components/Sort.tsx
Normal file
48
src/view/components/Sort.tsx
Normal file
|
@ -0,0 +1,48 @@
|
|||
import React, { FunctionComponent, useEffect, useRef } from 'react';
|
||||
import IconButtonElement from '../../elements/IconButtonElement';
|
||||
import libraryBrowser from '../../scripts/libraryBrowser';
|
||||
import * as userSettings from '../../scripts/settings/userSettings';
|
||||
import { IQuery } from './type';
|
||||
|
||||
type SortProps = {
|
||||
SortMenuOptions: () => { name: string; id: string}[];
|
||||
query: IQuery;
|
||||
savedQueryKey: string;
|
||||
reloadItems: () => void;
|
||||
}
|
||||
|
||||
const Sort: FunctionComponent<SortProps> = ({ SortMenuOptions, query, savedQueryKey, reloadItems }: SortProps) => {
|
||||
const element = useRef<HTMLDivElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const btnSort = element.current?.querySelector('.btnSort');
|
||||
|
||||
if (btnSort) {
|
||||
btnSort.addEventListener('click', (e) => {
|
||||
libraryBrowser.showSortMenu({
|
||||
items: SortMenuOptions(),
|
||||
callback: () => {
|
||||
query.StartIndex = 0;
|
||||
userSettings.saveQuerySettings(savedQueryKey, query);
|
||||
reloadItems();
|
||||
},
|
||||
query: query,
|
||||
button: e.target
|
||||
});
|
||||
});
|
||||
}
|
||||
}, [SortMenuOptions, query, reloadItems, savedQueryKey]);
|
||||
|
||||
return (
|
||||
<div ref={element}>
|
||||
<IconButtonElement
|
||||
is='paper-icon-button-light'
|
||||
className='btnSort autoSize'
|
||||
title='Sort'
|
||||
icon='material-icons sort_by_alpha'
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Sort;
|
Loading…
Add table
Add a link
Reference in a new issue