From 715dd983b009fe42b08d3cf262e14533d0d9b203 Mon Sep 17 00:00:00 2001 From: Mary Hipp Date: Mon, 24 Jun 2024 15:07:22 -0400 Subject: [PATCH] appease the knip --- .../web/src/common/util/dateComparator.ts | 16 ---------------- .../Boards/BoardsList/BoardTotalsTooltip.tsx | 4 ++-- invokeai/frontend/web/src/services/api/types.ts | 2 -- invokeai/frontend/web/src/services/api/util.ts | 13 ------------- 4 files changed, 2 insertions(+), 33 deletions(-) delete mode 100644 invokeai/frontend/web/src/common/util/dateComparator.ts diff --git a/invokeai/frontend/web/src/common/util/dateComparator.ts b/invokeai/frontend/web/src/common/util/dateComparator.ts deleted file mode 100644 index 27af542261..0000000000 --- a/invokeai/frontend/web/src/common/util/dateComparator.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Comparator function for sorting dates in ascending order - */ -export const dateComparator = (a: string, b: string) => { - const dateA = new Date(a); - const dateB = new Date(b); - - // sort in ascending order - if (dateA > dateB) { - return 1; - } - if (dateA < dateB) { - return -1; - } - return 0; -}; diff --git a/invokeai/frontend/web/src/features/gallery/components/Boards/BoardsList/BoardTotalsTooltip.tsx b/invokeai/frontend/web/src/features/gallery/components/Boards/BoardsList/BoardTotalsTooltip.tsx index f6e301c3d3..1c865dd79d 100644 --- a/invokeai/frontend/web/src/features/gallery/components/Boards/BoardsList/BoardTotalsTooltip.tsx +++ b/invokeai/frontend/web/src/features/gallery/components/Boards/BoardsList/BoardTotalsTooltip.tsx @@ -1,5 +1,5 @@ import { useTranslation } from 'react-i18next'; -import { useGetBoardImagesTotalQuery } from 'services/api/endpoints/boards'; +import { useGetBoardAssetsTotalQuery, useGetBoardImagesTotalQuery } from 'services/api/endpoints/boards'; type Props = { board_id: string; @@ -12,7 +12,7 @@ export const BoardTotalsTooltip = ({ board_id }: Props) => { return { imagesTotal: data?.total ?? 0 }; }, }); - const { assetsTotal } = useGetBoardImagesTotalQuery(board_id, { + const { assetsTotal } = useGetBoardAssetsTotalQuery(board_id, { selectFromResult: ({ data }) => { return { assetsTotal: data?.total ?? 0 }; }, diff --git a/invokeai/frontend/web/src/services/api/types.ts b/invokeai/frontend/web/src/services/api/types.ts index 50c63fd806..5c17bf9ec3 100644 --- a/invokeai/frontend/web/src/services/api/types.ts +++ b/invokeai/frontend/web/src/services/api/types.ts @@ -4,8 +4,6 @@ import type { O } from 'ts-toolbelt'; export type S = components['schemas']; -export type ImageCache = EntityState; - export type ListImagesArgs = NonNullable; export type ListImagesResponse = paths['/api/v1/images/']['get']['responses']['200']['content']['application/json']; diff --git a/invokeai/frontend/web/src/services/api/util.ts b/invokeai/frontend/web/src/services/api/util.ts index 0db6da3ce0..3d92923f2c 100644 --- a/invokeai/frontend/web/src/services/api/util.ts +++ b/invokeai/frontend/web/src/services/api/util.ts @@ -1,4 +1,3 @@ -import { dateComparator } from 'common/util/dateComparator'; import { ASSETS_CATEGORIES, IMAGE_CATEGORIES } from 'features/gallery/store/types'; import queryString from 'query-string'; import { buildV1Url } from 'services/api'; @@ -12,18 +11,6 @@ export const getCategories = (imageDTO: ImageDTO) => { return ASSETS_CATEGORIES; }; -export const imageListDefaultSort = () => { - return (a: ImageDTO, b: ImageDTO) => { - if (a.starred && !b.starred) { - return -1; - } - if (!a.starred && b.starred) { - return 1; - } - return dateComparator(b.created_at, a.created_at); - }; -}; - // Helper to create the url for the listImages endpoint. Also we use it to create the cache key. export const getListImagesUrl = (queryArgs: ListImagesArgs) => buildV1Url(`images/?${queryString.stringify(queryArgs, { arrayFormat: 'none' })}`);