diff --git a/src/tags/TagsList.tsx b/src/tags/TagsList.tsx index 4f32f9bb..6b5656fc 100644 --- a/src/tags/TagsList.tsx +++ b/src/tags/TagsList.tsx @@ -1,8 +1,6 @@ import { FC, useEffect, useMemo, useState } from 'react'; import { Row } from 'reactstrap'; import { pipe } from 'ramda'; -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import { faCaretDown as caretDownIcon, faCaretUp as caretUpIcon } from '@fortawesome/free-solid-svg-icons'; import Message from '../utils/Message'; import SearchField from '../utils/SearchField'; import { SelectedServer } from '../servers/data'; @@ -54,8 +52,6 @@ const TagsList = (TagsCards: FC, TagsTable: FC () => setOrder({ field, dir: determineOrderDir(field, order.field, order.dir) }); - const renderOrderIcon = (field: OrderableFields) => order.dir && order.field === field && - ; const renderContent = () => { if (tagsList.error) { @@ -76,8 +72,8 @@ const TagsList = (TagsCards: FC, TagsTable: FC ); }; diff --git a/src/tags/TagsTable.tsx b/src/tags/TagsTable.tsx index 5ed1d861..e313ebd4 100644 --- a/src/tags/TagsTable.tsx +++ b/src/tags/TagsTable.tsx @@ -1,23 +1,25 @@ -import { FC, ReactNode, useEffect, useRef } from 'react'; +import { FC, useEffect, useRef } from 'react'; import { splitEvery } from 'ramda'; +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { faCaretDown as caretDownIcon, faCaretUp as caretUpIcon } from '@fortawesome/free-solid-svg-icons'; import { RouteChildrenProps } from 'react-router'; import { SimpleCard } from '../utils/SimpleCard'; import SimplePaginator from '../common/SimplePaginator'; import { useQueryState } from '../utils/helpers/hooks'; import { parseQuery } from '../utils/helpers/query'; -import { OrderableFields, TagsListChildrenProps } from './data/TagsListChildrenProps'; +import { OrderableFields, TagsListChildrenProps, TagsOrder } from './data/TagsListChildrenProps'; import { TagsTableRowProps } from './TagsTableRow'; import './TagsTable.scss'; export interface TagsTableProps extends TagsListChildrenProps { orderByColumn: (field: OrderableFields) => () => void; - renderOrderIcon: (field: OrderableFields) => ReactNode; + currentOrder: TagsOrder; } const TAGS_PER_PAGE = 20; // TODO Allow customizing this value in settings export const TagsTable = (TagsTableRow: FC) => ( - { sortedTags, selectedServer, location, orderByColumn, renderOrderIcon }: TagsTableProps & RouteChildrenProps, + { sortedTags, selectedServer, location, orderByColumn, currentOrder }: TagsTableProps & RouteChildrenProps, ) => { const isFirstLoad = useRef(true); const { page: pageFromQuery = 1 } = parseQuery<{ page?: number | string }>(location.search); @@ -25,6 +27,8 @@ export const TagsTable = (TagsTableRow: FC) => ( const pages = splitEvery(TAGS_PER_PAGE, sortedTags); const showPaginator = pages.length > 1; const currentPage = pages[page - 1] ?? []; + const renderOrderIcon = (field: OrderableFields) => currentOrder.dir && currentOrder.field === field && + ; useEffect(() => { !isFirstLoad.current && setPage(1);