From eeaecf2d79b84ab5d99f8226d8045d1cac8761ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Sat, 26 Oct 2024 17:44:29 +0200 Subject: [PATCH] pl-hooks: Improve typings, update deps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- .../pl-hooks/lib/hooks/statuses/use-status.ts | 9 +++------ packages/pl-hooks/lib/main.ts | 1 + packages/pl-hooks/package.json | 2 +- packages/pl-hooks/yarn.lock | 18 +++++++++--------- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/packages/pl-hooks/lib/hooks/statuses/use-status.ts b/packages/pl-hooks/lib/hooks/statuses/use-status.ts index 626cf3662..f123e2821 100644 --- a/packages/pl-hooks/lib/hooks/statuses/use-status.ts +++ b/packages/pl-hooks/lib/hooks/statuses/use-status.ts @@ -1,10 +1,10 @@ -import { useQueries, useQuery, type UseQueryResult } from '@tanstack/react-query'; +import { useQueries, useQuery, UseQueryOptions, type UseQueryResult } from '@tanstack/react-query'; import { usePlHooksApiClient } from 'pl-hooks/contexts/api-client'; import { queryClient, usePlHooksQueryClient } from 'pl-hooks/contexts/query-client'; import { importEntities } from 'pl-hooks/importer'; import { usePoll } from 'pl-hooks/main'; -import { normalizeAccount, type NormalizedAccount } from 'pl-hooks/normalizers/account'; +import { type NormalizedAccount } from 'pl-hooks/normalizers/account'; import { type NormalizedStatus, normalizeStatus } from 'pl-hooks/normalizers/status'; import type { Poll } from 'pl-api'; @@ -123,12 +123,9 @@ const useStatus = (statusId?: string, opts: UseStatusOpts = { withReblog: true } reblogQuery = useStatus(status?.reblog_id || undefined, { ...opts, withReblog: false }); } - const accountsQuery = useQueries({ + const accountsQuery = useQueries[]>({ queries: status?.account_ids.map(accountId => ({ queryKey: ['accounts', 'entities', accountId], - queryFn: () => client.accounts.getAccount(accountId!) - .then(account => (importEntities({ accounts: [account] }, { withParents: false }), account)) - .then(normalizeAccount), })) || [], }, queryClient); diff --git a/packages/pl-hooks/lib/main.ts b/packages/pl-hooks/lib/main.ts index db232ea0b..3c93843e3 100644 --- a/packages/pl-hooks/lib/main.ts +++ b/packages/pl-hooks/lib/main.ts @@ -17,3 +17,4 @@ export * from './hooks/statuses/use-status-translation'; export * from './importer'; export type { NormalizedAccount } from './normalizers/account'; +export type { NormalizedStatus } from './normalizers/status'; diff --git a/packages/pl-hooks/package.json b/packages/pl-hooks/package.json index 7f85af158..0e130793b 100644 --- a/packages/pl-hooks/package.json +++ b/packages/pl-hooks/package.json @@ -33,7 +33,7 @@ "vite-plugin-dts": "^4.2.1" }, "dependencies": { - "@tanstack/react-query": "^5.56.2", + "@tanstack/react-query": "^5.59.16", "lodash": "^4.17.21", "pl-api": "^0.1.1", "react": "^18.3.1", diff --git a/packages/pl-hooks/yarn.lock b/packages/pl-hooks/yarn.lock index c2bcb1ec3..a926ede4c 100644 --- a/packages/pl-hooks/yarn.lock +++ b/packages/pl-hooks/yarn.lock @@ -381,17 +381,17 @@ argparse "~1.0.9" string-argv "~0.3.1" -"@tanstack/query-core@5.56.2": - version "5.56.2" - resolved "https://registry.yarnpkg.com/@tanstack/query-core/-/query-core-5.56.2.tgz#2def2fb0290cd2836bbb08afb0c175595bb8109b" - integrity sha512-gor0RI3/R5rVV3gXfddh1MM+hgl0Z4G7tj6Xxpq6p2I03NGPaJ8dITY9Gz05zYYb/EJq9vPas/T4wn9EaDPd4Q== +"@tanstack/query-core@5.59.16": + version "5.59.16" + resolved "https://registry.yarnpkg.com/@tanstack/query-core/-/query-core-5.59.16.tgz#aa4616e8a9c12afeef4cfbf3ed0f55f404d66e67" + integrity sha512-crHn+G3ltqb5JG0oUv6q+PMz1m1YkjpASrXTU+sYWW9pLk0t2GybUHNRqYPZWhxgjPaVGC4yp92gSFEJgYEsPw== -"@tanstack/react-query@^5.56.2": - version "5.56.2" - resolved "https://registry.yarnpkg.com/@tanstack/react-query/-/react-query-5.56.2.tgz#3a0241b9d010910905382f5e99160997b8795f91" - integrity sha512-SR0GzHVo6yzhN72pnRhkEFRAHMsUo5ZPzAxfTMvUxFIDVS6W9LYUp6nXW3fcHVdg0ZJl8opSH85jqahvm6DSVg== +"@tanstack/react-query@^5.59.16": + version "5.59.16" + resolved "https://registry.yarnpkg.com/@tanstack/react-query/-/react-query-5.59.16.tgz#1e701c6e6681965c04aa426df9da54b8edc6db1b" + integrity sha512-MuyWheG47h6ERd4PKQ6V8gDyBu3ThNG22e1fRVwvq6ap3EqsFhyuxCAwhNP/03m/mLg+DAb0upgbPaX6VB+CkQ== dependencies: - "@tanstack/query-core" "5.56.2" + "@tanstack/query-core" "5.59.16" "@types/argparse@1.0.38": version "1.0.38"