diff --git a/packages/pl-fe/package.json b/packages/pl-fe/package.json index 0f70a3d527..583511b497 100644 --- a/packages/pl-fe/package.json +++ b/packages/pl-fe/package.json @@ -144,7 +144,6 @@ "vite-plugin-html": "^3.2.2", "vite-plugin-require": "^1.2.14", "vite-plugin-static-copy": "^1.0.6", - "wicg-inert": "^3.1.3", "zustand": "^5.0.0-rc.2" }, "devDependencies": { diff --git a/packages/pl-fe/yarn.lock b/packages/pl-fe/yarn.lock index a2635fa838..ed2e237501 100644 --- a/packages/pl-fe/yarn.lock +++ b/packages/pl-fe/yarn.lock @@ -10172,11 +10172,6 @@ why-is-node-running@^2.3.0: siginfo "^2.0.0" stackback "0.0.2" -wicg-inert@^3.1.3: - version "3.1.3" - resolved "https://registry.yarnpkg.com/wicg-inert/-/wicg-inert-3.1.3.tgz#e53dbc9ac1e0d7f8c60f25e707614a835986272a" - integrity sha512-5L0PKK7iP+0Q/jv2ccgmkz/pfXbumZtlEyWS/xnX+L+Og3f7WjL4+iEs18k4IuldOX3PgGpza3qGndL9xUBjCQ== - word-wrap@^1.2.5: version "1.2.5" resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.5.tgz#d2c45c6dd4fbce621a66f136cbe328afd0410b34" diff --git a/packages/pl-hooks/lib/hooks/accounts/useAccount.ts b/packages/pl-hooks/lib/hooks/accounts/useAccount.ts index 660c3e8a1f..0616fe0c63 100644 --- a/packages/pl-hooks/lib/hooks/accounts/useAccount.ts +++ b/packages/pl-hooks/lib/hooks/accounts/useAccount.ts @@ -1,11 +1,14 @@ import { useQuery } from '@tanstack/react-query'; import { usePlHooksApiClient } from 'pl-hooks/contexts/api-client'; -import { usePlHooksQueryClient } from 'pl-hooks/contexts/query-client'; +import { queryClient, usePlHooksQueryClient } from 'pl-hooks/contexts/query-client'; +import { importEntities } from 'pl-hooks/importer'; import { type Account, normalizeAccount } from 'pl-hooks/normalizers/normalizeAccount'; import { useAccountRelationship } from './useAccountRelationship'; +import type { PlApiClient } from 'pl-api'; + interface UseAccountOpts { withRelationship?: boolean; withScrobble?: boolean; @@ -38,4 +41,15 @@ const useAccount = (accountId?: string, opts: UseAccountOpts = {}) => { return { ...accountQuery, data }; }; -export { useAccount, type UseAccountOpts }; +const prefetchAccount = (client: PlApiClient, accountId: string) => + queryClient.prefetchQuery({ + queryKey: ['accounts', 'entities', accountId], + queryFn: () => client.accounts.getAccount(accountId!) + .then(account => { + importEntities({ accounts: [account] }, { withParents: false }); + + return normalizeAccount(account); + }), + }); + +export { useAccount, prefetchAccount, type UseAccountOpts }; diff --git a/packages/pl-hooks/lib/importer.ts b/packages/pl-hooks/lib/importer.ts index 5795d5b3ac..3e62249974 100644 --- a/packages/pl-hooks/lib/importer.ts +++ b/packages/pl-hooks/lib/importer.ts @@ -12,7 +12,6 @@ import type { } from 'pl-api'; const importAccount = (account: BaseAccount) => { - queryClient.setQueryData(['accounts', 'byAcct', account.acct.toLocaleLowerCase()], account.id); return queryClient.setQueryData(['accounts', 'entities', account.id], account); }; @@ -58,6 +57,8 @@ const importEntities = (entities: { const statuses: Record = {}; const processAccount = (account: BaseAccount) => { + queryClient.setQueryData(['accounts', 'byAcct', account.acct.toLocaleLowerCase()], account.id); + if (account.moved) processAccount(account.moved); if (account.relationship) relationships[account.relationship.id] = account.relationship; }; diff --git a/packages/pl-hooks/lib/main.ts b/packages/pl-hooks/lib/main.ts index 9a763be5be..9223d8d298 100644 --- a/packages/pl-hooks/lib/main.ts +++ b/packages/pl-hooks/lib/main.ts @@ -8,6 +8,7 @@ export * from './hooks/markers/useMarkers'; export * from './hooks/markers/useUpdateMarkerMutation'; export * from './hooks/notifications/useNotification'; export * from './hooks/notifications/useNotificationList'; +export * from './hooks/polls/usePoll'; export * from './hooks/statuses/useStatus'; export * from './importer'; diff --git a/packages/pl-hooks/vite.config.ts b/packages/pl-hooks/vite.config.ts index 2d3fb004e2..92b263f3ad 100644 --- a/packages/pl-hooks/vite.config.ts +++ b/packages/pl-hooks/vite.config.ts @@ -4,6 +4,8 @@ import { resolve } from 'path'; import { defineConfig } from 'vite'; import dts from 'vite-plugin-dts'; +import pkg from './package.json'; + export default defineConfig({ plugins: [dts({ include: ['lib'], insertTypesEntry: true })], build: { @@ -16,6 +18,9 @@ export default defineConfig({ }, target: 'esnext', sourcemap: true, + rollupOptions: { + external: Object.keys(pkg.dependencies), + }, }, resolve: { alias: [