nicolium: account scrobble query changes
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
@ -1,5 +1,4 @@
|
||||
import { autoUpdate, flip, shift, useFloating, useTransitionStyles } from '@floating-ui/react';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { useRouter } from '@tanstack/react-router';
|
||||
import clsx from 'clsx';
|
||||
import React, { useEffect } from 'react';
|
||||
@ -18,7 +17,7 @@ import { isTimezoneLabel } from '@/features/ui/components/profile-field';
|
||||
import { UserPanel } from '@/features/ui/util/async-components';
|
||||
import { useAppDispatch } from '@/hooks/use-app-dispatch';
|
||||
import { useAppSelector } from '@/hooks/use-app-selector';
|
||||
import { accountScrobbleQueryOptions } from '@/queries/accounts/account-scrobble';
|
||||
import { useAccountScrobbleQuery } from '@/queries/accounts/account-scrobble';
|
||||
import { useAccountHoverCardActions, useAccountHoverCardStore } from '@/stores/account-hover-card';
|
||||
|
||||
import AccountLocalTime from './account-local-time';
|
||||
@ -79,7 +78,7 @@ const AccountHoverCard: React.FC<IAccountHoverCard> = ({ visible = true }) => {
|
||||
|
||||
const me = useAppSelector((state) => state.me);
|
||||
const { account } = useAccount(accountId ?? undefined, { withRelationship: true });
|
||||
const { data: scrobble } = useQuery(accountScrobbleQueryOptions(account?.id));
|
||||
const { data: scrobble } = useAccountScrobbleQuery(account?.id);
|
||||
const badges = getBadges(account);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import React from 'react';
|
||||
import { defineMessages, useIntl, FormattedMessage } from 'react-intl';
|
||||
|
||||
@ -14,7 +13,7 @@ import Text from '@/components/ui/text';
|
||||
import Emojify from '@/features/emoji/emojify';
|
||||
import { useAcct } from '@/hooks/use-acct';
|
||||
import { useAppSelector } from '@/hooks/use-app-selector';
|
||||
import { accountScrobbleQueryOptions } from '@/queries/accounts/account-scrobble';
|
||||
import { useAccountScrobbleQuery } from '@/queries/accounts/account-scrobble';
|
||||
import { capitalize } from '@/utils/strings';
|
||||
|
||||
import { ProfileField } from '../../util/async-components';
|
||||
@ -51,7 +50,7 @@ const ProfileInfoPanel: React.FC<IProfileInfoPanel> = ({ account, username }) =>
|
||||
const me = useAppSelector((state) => state.me);
|
||||
const ownAccount = account?.id === me;
|
||||
|
||||
const { data: scrobble } = useQuery(accountScrobbleQueryOptions(account?.id));
|
||||
const { data: scrobble } = useAccountScrobbleQuery(account?.id);
|
||||
|
||||
const getStaffBadge = (): React.ReactNode => {
|
||||
if (account?.is_admin) {
|
||||
|
||||
@ -1,15 +1,20 @@
|
||||
import { queryOptions } from '@tanstack/react-query';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
|
||||
import { getClient } from '@/api';
|
||||
import { useClient } from '@/hooks/use-client';
|
||||
import { useFeatures } from '@/hooks/use-features';
|
||||
|
||||
const accountScrobbleQueryOptions = (accountId?: string) =>
|
||||
queryOptions({
|
||||
const useAccountScrobbleQuery = (accountId?: string) => {
|
||||
const client = useClient();
|
||||
const features = useFeatures();
|
||||
|
||||
return useQuery({
|
||||
queryKey: ['scrobbles', accountId!],
|
||||
queryFn: async () =>
|
||||
(await getClient().accounts.getScrobbles(accountId!, { limit: 1 })).items[0] || null,
|
||||
(await client.accounts.getScrobbles(accountId!, { limit: 1 })).items[0] || null,
|
||||
placeholderData: undefined,
|
||||
enabled: () => !!accountId && getClient().features.scrobbles,
|
||||
enabled: () => !!accountId && features.scrobbles,
|
||||
staleTime: 3 * 60 * 1000,
|
||||
});
|
||||
};
|
||||
|
||||
export { accountScrobbleQueryOptions };
|
||||
export { useAccountScrobbleQuery };
|
||||
|
||||
Reference in New Issue
Block a user