From d286c34ae0a3ba30a60e297d196b25c7b263f471 Mon Sep 17 00:00:00 2001 From: mkljczk Date: Thu, 5 Dec 2024 01:24:12 +0100 Subject: [PATCH 01/46] pl-fe: migrate more to tanstack query Signed-off-by: mkljczk --- packages/pl-fe/src/actions/accounts.ts | 41 ------------ .../pl-fe/src/actions/familiar-followers.ts | 63 ------------------- .../account-lists/use-endorsed-accounts.ts | 20 ++++++ .../account-lists/use-familiar-followers.ts | 28 +++++++++ .../modals/familiar-followers-modal.tsx | 3 +- .../panels/pinned-accounts-panel.tsx | 13 +--- .../components/profile-familiar-followers.tsx | 17 +---- .../pl-fe/src/reducers/user-lists.test.ts | 13 +--- packages/pl-fe/src/reducers/user-lists.ts | 12 +--- 9 files changed, 59 insertions(+), 151 deletions(-) delete mode 100644 packages/pl-fe/src/actions/familiar-followers.ts create mode 100644 packages/pl-fe/src/api/hooks/account-lists/use-endorsed-accounts.ts create mode 100644 packages/pl-fe/src/api/hooks/account-lists/use-familiar-followers.ts diff --git a/packages/pl-fe/src/actions/accounts.ts b/packages/pl-fe/src/actions/accounts.ts index 4da5c5ee7..d20c14b46 100644 --- a/packages/pl-fe/src/actions/accounts.ts +++ b/packages/pl-fe/src/actions/accounts.ts @@ -38,10 +38,6 @@ const ACCOUNT_MUTE_REQUEST = 'ACCOUNT_MUTE_REQUEST' as const; const ACCOUNT_MUTE_SUCCESS = 'ACCOUNT_MUTE_SUCCESS' as const; const ACCOUNT_MUTE_FAIL = 'ACCOUNT_MUTE_FAIL' as const; -const PINNED_ACCOUNTS_FETCH_REQUEST = 'PINNED_ACCOUNTS_FETCH_REQUEST' as const; -const PINNED_ACCOUNTS_FETCH_SUCCESS = 'PINNED_ACCOUNTS_FETCH_SUCCESS' as const; -const PINNED_ACCOUNTS_FETCH_FAIL = 'PINNED_ACCOUNTS_FETCH_FAIL' as const; - const ACCOUNT_SEARCH_REQUEST = 'ACCOUNT_SEARCH_REQUEST' as const; const ACCOUNT_SEARCH_SUCCESS = 'ACCOUNT_SEARCH_SUCCESS' as const; const ACCOUNT_SEARCH_FAIL = 'ACCOUNT_SEARCH_FAIL' as const; @@ -342,36 +338,6 @@ const updateNotificationSettings = (params: UpdateNotificationSettingsParams) => }); }; -const fetchPinnedAccounts = (accountId: string) => - (dispatch: AppDispatch, getState: () => RootState) => { - dispatch(fetchPinnedAccountsRequest(accountId)); - - return getClient(getState).accounts.getAccountEndorsements(accountId).then(response => { - dispatch(importEntities({ accounts: response })); - dispatch(fetchPinnedAccountsSuccess(accountId, response, null)); - }).catch(error => { - dispatch(fetchPinnedAccountsFail(accountId, error)); - }); - }; - -const fetchPinnedAccountsRequest = (accountId: string) => ({ - type: PINNED_ACCOUNTS_FETCH_REQUEST, - accountId, -}); - -const fetchPinnedAccountsSuccess = (accountId: string, accounts: Array, next: null) => ({ - type: PINNED_ACCOUNTS_FETCH_SUCCESS, - accountId, - accounts, - next, -}); - -const fetchPinnedAccountsFail = (accountId: string, error: unknown) => ({ - type: PINNED_ACCOUNTS_FETCH_FAIL, - accountId, - error, -}); - interface AccountSearchRequestAction { type: typeof ACCOUNT_SEARCH_REQUEST; params: { @@ -452,9 +418,6 @@ type AccountsAction = | NotificationSettingsRequestAction | NotificationSettingsSuccessAction | NotificationSettingsFailAction - | ReturnType - | ReturnType - | ReturnType | AccountSearchRequestAction | AccountSearchSuccessAction | AccountSearchFailAction @@ -475,9 +438,6 @@ export { ACCOUNT_MUTE_REQUEST, ACCOUNT_MUTE_SUCCESS, ACCOUNT_MUTE_FAIL, - PINNED_ACCOUNTS_FETCH_REQUEST, - PINNED_ACCOUNTS_FETCH_SUCCESS, - PINNED_ACCOUNTS_FETCH_FAIL, ACCOUNT_SEARCH_REQUEST, ACCOUNT_SEARCH_SUCCESS, ACCOUNT_SEARCH_FAIL, @@ -499,7 +459,6 @@ export { pinAccount, unpinAccount, updateNotificationSettings, - fetchPinnedAccounts, accountSearch, accountLookup, biteAccount, diff --git a/packages/pl-fe/src/actions/familiar-followers.ts b/packages/pl-fe/src/actions/familiar-followers.ts deleted file mode 100644 index c651abcf6..000000000 --- a/packages/pl-fe/src/actions/familiar-followers.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { AppDispatch, RootState } from 'pl-fe/store'; - -import { getClient } from '../api'; - -import { fetchRelationships } from './accounts'; -import { importEntities } from './importer'; - -import type { Account } from 'pl-api'; - -const FAMILIAR_FOLLOWERS_FETCH_REQUEST = 'FAMILIAR_FOLLOWERS_FETCH_REQUEST' as const; -const FAMILIAR_FOLLOWERS_FETCH_SUCCESS = 'FAMILIAR_FOLLOWERS_FETCH_SUCCESS' as const; -const FAMILIAR_FOLLOWERS_FETCH_FAIL = 'FAMILIAR_FOLLOWERS_FETCH_FAIL' as const; - -const fetchAccountFamiliarFollowers = (accountId: string) => (dispatch: AppDispatch, getState: () => RootState) => { - dispatch({ - type: FAMILIAR_FOLLOWERS_FETCH_REQUEST, - accountId, - }); - - getClient(getState()).accounts.getFamiliarFollowers([accountId]) - .then((data) => { - const accounts = data.find(({ id }: { id: string }) => id === accountId)!.accounts; - - dispatch(importEntities({ accounts })); - dispatch(fetchRelationships(accounts.map((item) => item.id))); - dispatch({ - type: FAMILIAR_FOLLOWERS_FETCH_SUCCESS, - accountId, - accounts, - }); - }) - .catch(error => dispatch({ - type: FAMILIAR_FOLLOWERS_FETCH_FAIL, - accountId, - error, - skipAlert: true, - })); -}; - -type FamiliarFollowersAction = - | { - type: typeof FAMILIAR_FOLLOWERS_FETCH_REQUEST; - accountId: string; - } - | { - type: typeof FAMILIAR_FOLLOWERS_FETCH_SUCCESS; - accountId: string; - accounts: Array; - } - | { - type: typeof FAMILIAR_FOLLOWERS_FETCH_FAIL; - accountId: string; - error: unknown; - skipAlert: true; - } - -export { - FAMILIAR_FOLLOWERS_FETCH_REQUEST, - FAMILIAR_FOLLOWERS_FETCH_SUCCESS, - FAMILIAR_FOLLOWERS_FETCH_FAIL, - fetchAccountFamiliarFollowers, - type FamiliarFollowersAction, -}; diff --git a/packages/pl-fe/src/api/hooks/account-lists/use-endorsed-accounts.ts b/packages/pl-fe/src/api/hooks/account-lists/use-endorsed-accounts.ts new file mode 100644 index 000000000..df02ab92a --- /dev/null +++ b/packages/pl-fe/src/api/hooks/account-lists/use-endorsed-accounts.ts @@ -0,0 +1,20 @@ +import { useQuery } from '@tanstack/react-query'; + +import { importEntities } from 'pl-fe/actions/importer'; +import { useAppDispatch } from 'pl-fe/hooks/use-app-dispatch'; +import { useClient } from 'pl-fe/hooks/use-client'; + +const useEndorsedAccounts = (accountId: string) => { + const client = useClient(); + const dispatch = useAppDispatch(); + + return useQuery({ + queryKey: ['accountsLists', 'endorsedAccounts', accountId], + queryFn: () => client.accounts.getAccountEndorsements(accountId).then((accounts) => { + dispatch(importEntities({ accounts })); + return accounts.map(({ id }) => id); + }), + }); +}; + +export { useEndorsedAccounts }; diff --git a/packages/pl-fe/src/api/hooks/account-lists/use-familiar-followers.ts b/packages/pl-fe/src/api/hooks/account-lists/use-familiar-followers.ts new file mode 100644 index 000000000..eeece0d65 --- /dev/null +++ b/packages/pl-fe/src/api/hooks/account-lists/use-familiar-followers.ts @@ -0,0 +1,28 @@ +import { useQuery } from '@tanstack/react-query'; + +import { importEntities } from 'pl-fe/actions/importer'; +import { useAppDispatch } from 'pl-fe/hooks/use-app-dispatch'; +import { useClient } from 'pl-fe/hooks/use-client'; +import { useFeatures } from 'pl-fe/hooks/use-features'; +import { useLoggedIn } from 'pl-fe/hooks/use-logged-in'; + +const useFamiliarFollowers = (accountId: string) => { + const client = useClient(); + const dispatch = useAppDispatch(); + const features = useFeatures(); + const { isLoggedIn } = useLoggedIn(); + + return useQuery({ + queryKey: ['accountsLists', 'endorsedAccounts', accountId], + queryFn: () => client.accounts.getFamiliarFollowers([accountId]).then((response) => { + const result = response.find(({ id }) => id === accountId); + if (!result) return []; + + dispatch(importEntities({ accounts: result.accounts })); + return result.accounts.map(({ id }) => id); + }), + enabled: isLoggedIn && features.familiarFollowers, + }); +}; + +export { useFamiliarFollowers }; diff --git a/packages/pl-fe/src/features/ui/components/modals/familiar-followers-modal.tsx b/packages/pl-fe/src/features/ui/components/modals/familiar-followers-modal.tsx index d90147511..520f73756 100644 --- a/packages/pl-fe/src/features/ui/components/modals/familiar-followers-modal.tsx +++ b/packages/pl-fe/src/features/ui/components/modals/familiar-followers-modal.tsx @@ -1,6 +1,7 @@ import React, { useRef } from 'react'; import { FormattedMessage } from 'react-intl'; +import { useFamiliarFollowers } from 'pl-fe/api/hooks/account-lists/use-familiar-followers'; import ScrollableList from 'pl-fe/components/scrollable-list'; import Modal from 'pl-fe/components/ui/modal'; import Spinner from 'pl-fe/components/ui/spinner'; @@ -20,7 +21,7 @@ interface FamiliarFollowersModalProps { const FamiliarFollowersModal: React.FC = ({ accountId, onClose }) => { const modalRef = useRef(null); const account = useAppSelector(state => getAccount(state, accountId)); - const familiarFollowerIds = useAppSelector(state => state.user_lists.familiar_followers[accountId]?.items || []); + const { data: familiarFollowerIds } = useFamiliarFollowers(accountId); const onClickClose = () => { onClose('FAMILIAR_FOLLOWERS'); diff --git a/packages/pl-fe/src/features/ui/components/panels/pinned-accounts-panel.tsx b/packages/pl-fe/src/features/ui/components/panels/pinned-accounts-panel.tsx index b4b7a5582..e2fe888cb 100644 --- a/packages/pl-fe/src/features/ui/components/panels/pinned-accounts-panel.tsx +++ b/packages/pl-fe/src/features/ui/components/panels/pinned-accounts-panel.tsx @@ -1,13 +1,11 @@ -import React, { useEffect } from 'react'; +import React from 'react'; import { FormattedMessage } from 'react-intl'; -import { fetchPinnedAccounts } from 'pl-fe/actions/accounts'; +import { useEndorsedAccounts } from 'pl-fe/api/hooks/account-lists/use-endorsed-accounts'; import Widget from 'pl-fe/components/ui/widget'; import AccountContainer from 'pl-fe/containers/account-container'; import Emojify from 'pl-fe/features/emoji/emojify'; import { WhoToFollowPanel } from 'pl-fe/features/ui/util/async-components'; -import { useAppDispatch } from 'pl-fe/hooks/use-app-dispatch'; -import { useAppSelector } from 'pl-fe/hooks/use-app-selector'; import type { Account } from 'pl-fe/normalizers/account'; @@ -17,12 +15,7 @@ interface IPinnedAccountsPanel { } const PinnedAccountsPanel: React.FC = ({ account, limit }) => { - const dispatch = useAppDispatch(); - const pinned = useAppSelector((state) => state.user_lists.pinned[account.id]?.items || []).slice(0, limit); - - useEffect(() => { - dispatch(fetchPinnedAccounts(account.id)); - }, []); + const { data: pinned = [] } = useEndorsedAccounts(accountId); if (!pinned.length) { return ( diff --git a/packages/pl-fe/src/features/ui/components/profile-familiar-followers.tsx b/packages/pl-fe/src/features/ui/components/profile-familiar-followers.tsx index 6730f1eaf..e31fc4beb 100644 --- a/packages/pl-fe/src/features/ui/components/profile-familiar-followers.tsx +++ b/packages/pl-fe/src/features/ui/components/profile-familiar-followers.tsx @@ -1,17 +1,15 @@ -import React, { useEffect } from 'react'; +import React from 'react'; import { FormattedList, FormattedMessage } from 'react-intl'; import { Link } from 'react-router-dom'; -import { fetchAccountFamiliarFollowers } from 'pl-fe/actions/familiar-followers'; +import { useFamiliarFollowers } from 'pl-fe/api/hooks/account-lists/use-familiar-followers'; import AvatarStack from 'pl-fe/components/avatar-stack'; import HoverAccountWrapper from 'pl-fe/components/hover-account-wrapper'; import HStack from 'pl-fe/components/ui/hstack'; import Text from 'pl-fe/components/ui/text'; import VerificationBadge from 'pl-fe/components/verification-badge'; import Emojify from 'pl-fe/features/emoji/emojify'; -import { useAppDispatch } from 'pl-fe/hooks/use-app-dispatch'; import { useAppSelector } from 'pl-fe/hooks/use-app-selector'; -import { useFeatures } from 'pl-fe/hooks/use-features'; import { makeGetAccount } from 'pl-fe/selectors'; import { useModalsStore } from 'pl-fe/stores/modals'; @@ -25,18 +23,9 @@ interface IProfileFamiliarFollowers { const ProfileFamiliarFollowers: React.FC = ({ account }) => { const { openModal } = useModalsStore(); - const dispatch = useAppDispatch(); - const me = useAppSelector((state) => state.me); - const features = useFeatures(); - const familiarFollowerIds = useAppSelector(state => state.user_lists.familiar_followers[account.id]?.items || []); + const { data: familiarFollowerIds = [] } = useFamiliarFollowers(account.id); const familiarFollowers = useAppSelector(state => familiarFollowerIds.slice(0, 2).map(accountId => getAccount(state, accountId))); - useEffect(() => { - if (me && features.familiarFollowers) { - dispatch(fetchAccountFamiliarFollowers(account.id)); - } - }, [account.id]); - const openFamiliarFollowersModal = () => { openModal('FAMILIAR_FOLLOWERS', { accountId: account.id, diff --git a/packages/pl-fe/src/reducers/user-lists.test.ts b/packages/pl-fe/src/reducers/user-lists.test.ts index a42d8c31f..bcb2bfa8f 100644 --- a/packages/pl-fe/src/reducers/user-lists.test.ts +++ b/packages/pl-fe/src/reducers/user-lists.test.ts @@ -1,20 +1,9 @@ -import { OrderedSet as ImmutableOrderedSet } from 'immutable'; - import reducer from './user-lists'; describe('user_lists reducer', () => { it('should return the initial state', () => { expect(reducer(undefined, {} as any)).toMatchObject({ - followers: {}, - following: {}, - reblogged_by: {}, - favourited_by: {}, - reactions: {}, - follow_requests: { next: null, items: ImmutableOrderedSet(), isLoading: false }, - blocks: { next: null, items: ImmutableOrderedSet(), isLoading: false }, - mutes: { next: null, items: ImmutableOrderedSet(), isLoading: false }, - pinned: {}, - familiar_followers: {}, + group_blocks: {}, }); }); }); diff --git a/packages/pl-fe/src/reducers/user-lists.ts b/packages/pl-fe/src/reducers/user-lists.ts index 3a1412f6f..857d7d810 100644 --- a/packages/pl-fe/src/reducers/user-lists.ts +++ b/packages/pl-fe/src/reducers/user-lists.ts @@ -1,7 +1,5 @@ import { create } from 'mutative'; -import { PINNED_ACCOUNTS_FETCH_SUCCESS, type AccountsAction } from 'pl-fe/actions/accounts'; -import { FAMILIAR_FOLLOWERS_FETCH_SUCCESS, type FamiliarFollowersAction } from 'pl-fe/actions/familiar-followers'; import { GROUP_BLOCKS_FETCH_REQUEST, GROUP_BLOCKS_FETCH_SUCCESS, @@ -18,13 +16,11 @@ interface List { isLoading: boolean; } -type NestedListKey = 'pinned' | 'familiar_followers' | 'group_blocks'; +type NestedListKey = 'group_blocks'; type State = Record>; const initialState: State = { - pinned: {}, - familiar_followers: {}, group_blocks: {}, }; @@ -37,12 +33,8 @@ const normalizeList = (state: State, path: NestedListPath, accounts: Array { +const userLists = (state = initialState, action: GroupsAction): State => { switch (action.type) { - case PINNED_ACCOUNTS_FETCH_SUCCESS: - return normalizeList(state, ['pinned', action.accountId], action.accounts, action.next); - case FAMILIAR_FOLLOWERS_FETCH_SUCCESS: - return normalizeList(state, ['familiar_followers', action.accountId], action.accounts); case GROUP_BLOCKS_FETCH_SUCCESS: return normalizeList(state, ['group_blocks', action.groupId], action.accounts, action.next); case GROUP_BLOCKS_FETCH_REQUEST: From 908dfa816ed5e2584459ade8f089d78d66af4dde Mon Sep 17 00:00:00 2001 From: mkljczk Date: Thu, 5 Dec 2024 01:31:33 +0100 Subject: [PATCH 02/46] Update pl-fe.yaml --- .github/workflows/pl-fe.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pl-fe.yaml b/.github/workflows/pl-fe.yaml index f0333f583..fad6f0d7b 100644 --- a/.github/workflows/pl-fe.yaml +++ b/.github/workflows/pl-fe.yaml @@ -12,7 +12,7 @@ jobs: name: Test and upload artifacts strategy: matrix: - node-version: [21.x] + node-version: [22.x] steps: - name: Install system dependencies From 368bd553c74c64f00f6dd2db0e38f3c37dea77ac Mon Sep 17 00:00:00 2001 From: mkljczk Date: Thu, 5 Dec 2024 09:12:27 +0100 Subject: [PATCH 03/46] pl-fe: fix Signed-off-by: mkljczk --- .../src/features/ui/components/panels/pinned-accounts-panel.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/pl-fe/src/features/ui/components/panels/pinned-accounts-panel.tsx b/packages/pl-fe/src/features/ui/components/panels/pinned-accounts-panel.tsx index e2fe888cb..1a5c294ee 100644 --- a/packages/pl-fe/src/features/ui/components/panels/pinned-accounts-panel.tsx +++ b/packages/pl-fe/src/features/ui/components/panels/pinned-accounts-panel.tsx @@ -15,7 +15,7 @@ interface IPinnedAccountsPanel { } const PinnedAccountsPanel: React.FC = ({ account, limit }) => { - const { data: pinned = [] } = useEndorsedAccounts(accountId); + const { data: pinned = [] } = useEndorsedAccounts(account.id); if (!pinned.length) { return ( From feb5b7a836756a780501586b1deb372848bb6a5e Mon Sep 17 00:00:00 2001 From: mkljczk Date: Thu, 5 Dec 2024 10:12:33 +0100 Subject: [PATCH 04/46] pl-fe: update en.json Signed-off-by: mkljczk --- packages/pl-fe/src/locales/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/pl-fe/src/locales/en.json b/packages/pl-fe/src/locales/en.json index 8a01b42c6..9ba4f4b4d 100644 --- a/packages/pl-fe/src/locales/en.json +++ b/packages/pl-fe/src/locales/en.json @@ -1623,4 +1623,4 @@ "video.play": "Play", "video.unmute": "Unmute sound", "who_to_follow.title": "People to follow" -} \ No newline at end of file +} From 047a371a452ed6c9874db8cb2351e65cbb0490c8 Mon Sep 17 00:00:00 2001 From: mkljczk Date: Thu, 5 Dec 2024 10:18:27 +0100 Subject: [PATCH 05/46] pl-fe: move stuff around Signed-off-by: mkljczk --- packages/pl-fe/src/actions/accounts.ts | 2 +- packages/pl-fe/src/actions/domain-blocks.ts | 2 +- packages/pl-fe/src/actions/notifications.ts | 2 +- .../api/hooks/accounts/use-account-lookup.ts | 3 +- .../src/api/hooks/accounts/use-account.ts | 3 +- .../src/api/hooks/admin/use-announcements.ts | 2 +- .../api/hooks/statuses/use-bookmark-folder.ts | 5 -- .../hooks/statuses/use-bookmark-folders.ts | 22 ------- .../statuses/use-create-bookmark-folder.ts | 21 ------ .../statuses/use-delete-bookmark-folder.ts | 16 ----- .../statuses/use-update-bookmark-folder.ts | 21 ------ .../api/hooks/streaming/use-user-stream.ts | 2 +- .../announcements/announcements-panel.tsx | 2 +- .../src/components/announcements/reaction.tsx | 2 +- .../announcements/reactions-bar.tsx | 2 +- .../pl-fe/src/components/birthday-panel.tsx | 2 +- .../pl-fe/src/components/location-search.tsx | 2 +- .../pl-fe/src/components/sidebar-menu.tsx | 4 +- .../src/components/sidebar-navigation.tsx | 4 +- .../src/components/status-action-bar.tsx | 2 +- .../pl-fe/src/components/status-content.tsx | 2 +- .../pl-fe/src/components/translate-button.tsx | 4 +- packages/pl-fe/src/components/upload.tsx | 2 +- packages/pl-fe/src/features/about/index.tsx | 2 +- packages/pl-fe/src/features/audio/index.tsx | 2 +- .../components/new-folder-form.tsx | 2 +- .../src/features/bookmark-folders/index.tsx | 2 +- .../pl-fe/src/features/bookmarks/index.tsx | 3 +- .../tabs/manage-pending-participants.tsx | 2 +- .../pl-fe/src/features/directory/index.tsx | 2 +- .../components/account-authorize.tsx | 2 +- .../src/features/follow-requests/index.tsx | 2 +- .../features/interaction-requests/index.tsx | 2 +- packages/pl-fe/src/features/quotes/index.tsx | 2 +- .../search/components/search-results.tsx | 8 +-- .../features/ui/components/action-button.tsx | 2 +- .../ui/components/modals/birthdays-modal.tsx | 2 +- .../modals/compare-history-modal.tsx | 2 +- .../ui/components/modals/dislikes-modal.tsx | 2 +- .../modals/edit-bookmark-folder-modal.tsx | 3 +- .../modals/event-participants-modal.tsx | 2 +- .../modals/familiar-followers-modal.tsx | 2 +- .../ui/components/modals/favourites-modal.tsx | 2 +- .../ui/components/modals/reactions-modal.tsx | 2 +- .../ui/components/modals/reblogs-modal.tsx | 2 +- .../modals/select-bookmark-folder-modal.tsx | 2 +- .../panels/pinned-accounts-panel.tsx | 2 +- .../components/profile-familiar-followers.tsx | 2 +- packages/pl-fe/src/features/ui/index.tsx | 2 +- packages/pl-fe/src/features/video/index.tsx | 2 +- .../account-lists/use-birthday-reminders.ts | 0 .../account-lists/use-directory.ts | 0 .../account-lists/use-endorsed-accounts.ts | 0 .../use-event-participation-requests.ts | 0 .../account-lists/use-event-participations.ts | 0 .../account-lists/use-familiar-followers.ts | 0 .../account-lists/use-follow-requests.ts | 0 .../account-lists/use-status-interactions.ts | 0 .../accounts/use-account-scrobble.ts | 0 .../announcements/use-announcements.ts | 0 .../instance/use-translation-languages.ts | 0 .../hooks => queries}/pl-fe/use-about-page.ts | 0 .../search/use-search-location.ts | 0 .../hooks => queries}/search/use-search.ts | 0 .../queries/statuses/use-bookmark-folders.ts | 66 +++++++++++++++++++ .../statuses/use-interaction-requests.ts | 0 .../statuses/use-status-history.ts | 0 .../statuses/use-status-quotes.ts | 0 .../statuses/use-status-translation.ts | 0 .../trends/use-suggested-accounts.ts | 0 .../trends/use-trending-links.ts | 0 .../trends/use-trending-statuses.ts | 0 72 files changed, 119 insertions(+), 138 deletions(-) delete mode 100644 packages/pl-fe/src/api/hooks/statuses/use-bookmark-folder.ts delete mode 100644 packages/pl-fe/src/api/hooks/statuses/use-bookmark-folders.ts delete mode 100644 packages/pl-fe/src/api/hooks/statuses/use-create-bookmark-folder.ts delete mode 100644 packages/pl-fe/src/api/hooks/statuses/use-delete-bookmark-folder.ts delete mode 100644 packages/pl-fe/src/api/hooks/statuses/use-update-bookmark-folder.ts rename packages/pl-fe/src/{api/hooks => queries}/account-lists/use-birthday-reminders.ts (100%) rename packages/pl-fe/src/{api/hooks => queries}/account-lists/use-directory.ts (100%) rename packages/pl-fe/src/{api/hooks => queries}/account-lists/use-endorsed-accounts.ts (100%) rename packages/pl-fe/src/{api/hooks => queries}/account-lists/use-event-participation-requests.ts (100%) rename packages/pl-fe/src/{api/hooks => queries}/account-lists/use-event-participations.ts (100%) rename packages/pl-fe/src/{api/hooks => queries}/account-lists/use-familiar-followers.ts (100%) rename packages/pl-fe/src/{api/hooks => queries}/account-lists/use-follow-requests.ts (100%) rename packages/pl-fe/src/{api/hooks => queries}/account-lists/use-status-interactions.ts (100%) rename packages/pl-fe/src/{api/hooks => queries}/accounts/use-account-scrobble.ts (100%) rename packages/pl-fe/src/{api/hooks => queries}/announcements/use-announcements.ts (100%) rename packages/pl-fe/src/{api/hooks => queries}/instance/use-translation-languages.ts (100%) rename packages/pl-fe/src/{api/hooks => queries}/pl-fe/use-about-page.ts (100%) rename packages/pl-fe/src/{api/hooks => queries}/search/use-search-location.ts (100%) rename packages/pl-fe/src/{api/hooks => queries}/search/use-search.ts (100%) create mode 100644 packages/pl-fe/src/queries/statuses/use-bookmark-folders.ts rename packages/pl-fe/src/{api/hooks => queries}/statuses/use-interaction-requests.ts (100%) rename packages/pl-fe/src/{api/hooks => queries}/statuses/use-status-history.ts (100%) rename packages/pl-fe/src/{api/hooks => queries}/statuses/use-status-quotes.ts (100%) rename packages/pl-fe/src/{api/hooks => queries}/statuses/use-status-translation.ts (100%) rename packages/pl-fe/src/{api/hooks => queries}/trends/use-suggested-accounts.ts (100%) rename packages/pl-fe/src/{api/hooks => queries}/trends/use-trending-links.ts (100%) rename packages/pl-fe/src/{api/hooks => queries}/trends/use-trending-statuses.ts (100%) diff --git a/packages/pl-fe/src/actions/accounts.ts b/packages/pl-fe/src/actions/accounts.ts index d20c14b46..966bd8089 100644 --- a/packages/pl-fe/src/actions/accounts.ts +++ b/packages/pl-fe/src/actions/accounts.ts @@ -17,7 +17,7 @@ import { getClient, type PlfeResponse } from '../api'; import { importEntities } from './importer'; -import type { MinifiedSuggestion } from 'pl-fe/api/hooks/trends/use-suggested-accounts'; +import type { MinifiedSuggestion } from 'pl-fe/queries/trends/use-suggested-accounts'; import type { MinifiedStatus } from 'pl-fe/reducers/statuses'; import type { AppDispatch, RootState } from 'pl-fe/store'; import type { History } from 'pl-fe/types/history'; diff --git a/packages/pl-fe/src/actions/domain-blocks.ts b/packages/pl-fe/src/actions/domain-blocks.ts index 439801b06..88c3903c0 100644 --- a/packages/pl-fe/src/actions/domain-blocks.ts +++ b/packages/pl-fe/src/actions/domain-blocks.ts @@ -5,9 +5,9 @@ import { isLoggedIn } from 'pl-fe/utils/auth'; import { getClient } from '../api'; import type { PaginatedResponse } from 'pl-api'; -import type { MinifiedSuggestion } from 'pl-fe/api/hooks/trends/use-suggested-accounts'; import type { EntityStore } from 'pl-fe/entity-store/types'; import type { Account } from 'pl-fe/normalizers/account'; +import type { MinifiedSuggestion } from 'pl-fe/queries/trends/use-suggested-accounts'; import type { AppDispatch, RootState } from 'pl-fe/store'; const DOMAIN_BLOCK_REQUEST = 'DOMAIN_BLOCK_REQUEST' as const; diff --git a/packages/pl-fe/src/actions/notifications.ts b/packages/pl-fe/src/actions/notifications.ts index 34976f763..f8c5df481 100644 --- a/packages/pl-fe/src/actions/notifications.ts +++ b/packages/pl-fe/src/actions/notifications.ts @@ -3,9 +3,9 @@ import 'intl-pluralrules'; import { defineMessages } from 'react-intl'; import { getClient } from 'pl-fe/api'; -import { appendFollowRequest } from 'pl-fe/api/hooks/account-lists/use-follow-requests'; import { getNotificationStatus } from 'pl-fe/features/notifications/components/notification'; import { normalizeNotification } from 'pl-fe/normalizers/notification'; +import { appendFollowRequest } from 'pl-fe/queries/account-lists/use-follow-requests'; import { getFilters, regexFromFilters } from 'pl-fe/selectors'; import { useSettingsStore } from 'pl-fe/stores/settings'; import { isLoggedIn } from 'pl-fe/utils/auth'; diff --git a/packages/pl-fe/src/api/hooks/accounts/use-account-lookup.ts b/packages/pl-fe/src/api/hooks/accounts/use-account-lookup.ts index ac3806700..86abdc638 100644 --- a/packages/pl-fe/src/api/hooks/accounts/use-account-lookup.ts +++ b/packages/pl-fe/src/api/hooks/accounts/use-account-lookup.ts @@ -8,7 +8,8 @@ import { useFeatures } from 'pl-fe/hooks/use-features'; import { useLoggedIn } from 'pl-fe/hooks/use-logged-in'; import { type Account, normalizeAccount } from 'pl-fe/normalizers/account'; -import { useAccountScrobble } from './use-account-scrobble'; +import { useAccountScrobble } from '../../../queries/accounts/use-account-scrobble'; + import { useRelationship } from './use-relationship'; import type { Account as BaseAccount } from 'pl-api'; diff --git a/packages/pl-fe/src/api/hooks/accounts/use-account.ts b/packages/pl-fe/src/api/hooks/accounts/use-account.ts index 2f27e7ef7..75f0e3ac7 100644 --- a/packages/pl-fe/src/api/hooks/accounts/use-account.ts +++ b/packages/pl-fe/src/api/hooks/accounts/use-account.ts @@ -9,7 +9,8 @@ import { useFeatures } from 'pl-fe/hooks/use-features'; import { useLoggedIn } from 'pl-fe/hooks/use-logged-in'; import { type Account, normalizeAccount } from 'pl-fe/normalizers/account'; -import { useAccountScrobble } from './use-account-scrobble'; +import { useAccountScrobble } from '../../../queries/accounts/use-account-scrobble'; + import { useRelationship } from './use-relationship'; import type { Account as BaseAccount } from 'pl-api'; diff --git a/packages/pl-fe/src/api/hooks/admin/use-announcements.ts b/packages/pl-fe/src/api/hooks/admin/use-announcements.ts index c313e0895..651ae4b0b 100644 --- a/packages/pl-fe/src/api/hooks/admin/use-announcements.ts +++ b/packages/pl-fe/src/api/hooks/admin/use-announcements.ts @@ -10,7 +10,7 @@ import * as v from 'valibot'; import { useClient } from 'pl-fe/hooks/use-client'; import { queryClient } from 'pl-fe/queries/client'; -import { useAnnouncements as useUserAnnouncements } from '../announcements/use-announcements'; +import { useAnnouncements as useUserAnnouncements } from '../../../queries/announcements/use-announcements'; const useAnnouncements = () => { const client = useClient(); diff --git a/packages/pl-fe/src/api/hooks/statuses/use-bookmark-folder.ts b/packages/pl-fe/src/api/hooks/statuses/use-bookmark-folder.ts deleted file mode 100644 index 79f145aaa..000000000 --- a/packages/pl-fe/src/api/hooks/statuses/use-bookmark-folder.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { useBookmarkFolders } from './use-bookmark-folders'; - -const useBookmarkFolder = (folderId?: string) => useBookmarkFolders((data) => folderId ? data.find(folder => folder.id === folderId) : undefined); - -export { useBookmarkFolder }; diff --git a/packages/pl-fe/src/api/hooks/statuses/use-bookmark-folders.ts b/packages/pl-fe/src/api/hooks/statuses/use-bookmark-folders.ts deleted file mode 100644 index 7e857b1ac..000000000 --- a/packages/pl-fe/src/api/hooks/statuses/use-bookmark-folders.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { useQuery } from '@tanstack/react-query'; - -import { useClient } from 'pl-fe/hooks/use-client'; -import { useFeatures } from 'pl-fe/hooks/use-features'; - -import type { BookmarkFolder } from 'pl-api'; - -const useBookmarkFolders = ( - select?: ((data: Array) => T), -) => { - const client = useClient(); - const features = useFeatures(); - - return useQuery({ - queryKey: ['bookmarkFolders'], - queryFn: () => client.myAccount.getBookmarkFolders(), - enabled: features.bookmarkFolders, - select, - }); -}; - -export { useBookmarkFolders }; diff --git a/packages/pl-fe/src/api/hooks/statuses/use-create-bookmark-folder.ts b/packages/pl-fe/src/api/hooks/statuses/use-create-bookmark-folder.ts deleted file mode 100644 index 0cc9acfc8..000000000 --- a/packages/pl-fe/src/api/hooks/statuses/use-create-bookmark-folder.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { useMutation } from '@tanstack/react-query'; - -import { useClient } from 'pl-fe/hooks/use-client'; -import { queryClient } from 'pl-fe/queries/client'; - -interface CreateBookmarkFolderParams { - name: string; - emoji?: string; -} - -const useCreateBookmarkFolder = () => { - const client = useClient(); - - return useMutation({ - mutationKey: ['bookmarkFolders', 'create'], - mutationFn: (params: CreateBookmarkFolderParams) => client.myAccount.createBookmarkFolder(params), - onSettled: () => queryClient.invalidateQueries({ queryKey: ['bookmarkFolders'] }), - }); -}; - -export { useCreateBookmarkFolder }; diff --git a/packages/pl-fe/src/api/hooks/statuses/use-delete-bookmark-folder.ts b/packages/pl-fe/src/api/hooks/statuses/use-delete-bookmark-folder.ts deleted file mode 100644 index 9c96d5786..000000000 --- a/packages/pl-fe/src/api/hooks/statuses/use-delete-bookmark-folder.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { useMutation } from '@tanstack/react-query'; - -import { useClient } from 'pl-fe/hooks/use-client'; -import { queryClient } from 'pl-fe/queries/client'; - -const useDeleteBookmarkFolder = () => { - const client = useClient(); - - return useMutation({ - mutationKey: ['bookmarkFolders', 'delete'], - mutationFn: (folderId: string) => client.myAccount.deleteBookmarkFolder(folderId), - onSettled: () => queryClient.invalidateQueries({ queryKey: ['bookmarkFolders'] }), - }); -}; - -export { useDeleteBookmarkFolder }; diff --git a/packages/pl-fe/src/api/hooks/statuses/use-update-bookmark-folder.ts b/packages/pl-fe/src/api/hooks/statuses/use-update-bookmark-folder.ts deleted file mode 100644 index 13c6b28e9..000000000 --- a/packages/pl-fe/src/api/hooks/statuses/use-update-bookmark-folder.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { useMutation } from '@tanstack/react-query'; - -import { useClient } from 'pl-fe/hooks/use-client'; -import { queryClient } from 'pl-fe/queries/client'; - -interface UpdateBookmarkFolderParams { - name: string; - emoji?: string; -} - -const useUpdateBookmarkFolder = (folderId: string) => { - const client = useClient(); - - return useMutation({ - mutationKey: ['bookmarkFolders', 'update', folderId], - mutationFn: (params: UpdateBookmarkFolderParams) => client.myAccount.updateBookmarkFolder(folderId, params), - onSettled: () => queryClient.invalidateQueries({ queryKey: ['bookmarkFolders'] }), - }); -}; - -export { useUpdateBookmarkFolder }; diff --git a/packages/pl-fe/src/api/hooks/streaming/use-user-stream.ts b/packages/pl-fe/src/api/hooks/streaming/use-user-stream.ts index ac161db0c..8804f0741 100644 --- a/packages/pl-fe/src/api/hooks/streaming/use-user-stream.ts +++ b/packages/pl-fe/src/api/hooks/streaming/use-user-stream.ts @@ -19,7 +19,7 @@ import { useSettingsStore } from 'pl-fe/stores/settings'; import { getUnreadChatsCount, updateChatListItem } from 'pl-fe/utils/chats'; import { play, soundCache } from 'pl-fe/utils/sounds'; -import { updateReactions } from '../announcements/use-announcements'; +import { updateReactions } from '../../../queries/announcements/use-announcements'; import { useTimelineStream } from './use-timeline-stream'; diff --git a/packages/pl-fe/src/components/announcements/announcements-panel.tsx b/packages/pl-fe/src/components/announcements/announcements-panel.tsx index ecbddd826..1f66af996 100644 --- a/packages/pl-fe/src/components/announcements/announcements-panel.tsx +++ b/packages/pl-fe/src/components/announcements/announcements-panel.tsx @@ -4,11 +4,11 @@ import { FormattedMessage } from 'react-intl'; import ReactSwipeableViews from 'react-swipeable-views'; import { createSelector } from 'reselect'; -import { useAnnouncements } from 'pl-fe/api/hooks/announcements/use-announcements'; import Card from 'pl-fe/components/ui/card'; import HStack from 'pl-fe/components/ui/hstack'; import Widget from 'pl-fe/components/ui/widget'; import { useAppSelector } from 'pl-fe/hooks/use-app-selector'; +import { useAnnouncements } from 'pl-fe/queries/announcements/use-announcements'; import Announcement from './announcement'; diff --git a/packages/pl-fe/src/components/announcements/reaction.tsx b/packages/pl-fe/src/components/announcements/reaction.tsx index 99ba3b790..ac6d817c2 100644 --- a/packages/pl-fe/src/components/announcements/reaction.tsx +++ b/packages/pl-fe/src/components/announcements/reaction.tsx @@ -1,9 +1,9 @@ import clsx from 'clsx'; import React, { useState } from 'react'; -import { useAnnouncements } from 'pl-fe/api/hooks/announcements/use-announcements'; import AnimatedNumber from 'pl-fe/components/animated-number'; import unicodeMapping from 'pl-fe/features/emoji/mapping'; +import { useAnnouncements } from 'pl-fe/queries/announcements/use-announcements'; import Emoji from './emoji'; diff --git a/packages/pl-fe/src/components/announcements/reactions-bar.tsx b/packages/pl-fe/src/components/announcements/reactions-bar.tsx index d0db5971b..3d56c774d 100644 --- a/packages/pl-fe/src/components/announcements/reactions-bar.tsx +++ b/packages/pl-fe/src/components/announcements/reactions-bar.tsx @@ -1,9 +1,9 @@ import React from 'react'; import { TransitionMotion, spring } from 'react-motion'; -import { useAnnouncements } from 'pl-fe/api/hooks/announcements/use-announcements'; import EmojiPickerDropdown from 'pl-fe/features/emoji/containers/emoji-picker-dropdown-container'; import { useSettings } from 'pl-fe/hooks/use-settings'; +import { useAnnouncements } from 'pl-fe/queries/announcements/use-announcements'; import Reaction from './reaction'; diff --git a/packages/pl-fe/src/components/birthday-panel.tsx b/packages/pl-fe/src/components/birthday-panel.tsx index b7b9f06a6..8205351fd 100644 --- a/packages/pl-fe/src/components/birthday-panel.tsx +++ b/packages/pl-fe/src/components/birthday-panel.tsx @@ -1,9 +1,9 @@ import React, { useRef, useState } from 'react'; import { FormattedMessage } from 'react-intl'; -import { useBirthdayReminders } from 'pl-fe/api/hooks/account-lists/use-birthday-reminders'; import Widget from 'pl-fe/components/ui/widget'; import AccountContainer from 'pl-fe/containers/account-container'; +import { useBirthdayReminders } from 'pl-fe/queries/account-lists/use-birthday-reminders'; const timeToMidnight = () => { const now = new Date(); diff --git a/packages/pl-fe/src/components/location-search.tsx b/packages/pl-fe/src/components/location-search.tsx index 7e1a19530..4766a10a8 100644 --- a/packages/pl-fe/src/components/location-search.tsx +++ b/packages/pl-fe/src/components/location-search.tsx @@ -3,9 +3,9 @@ import clsx from 'clsx'; import React, { useState } from 'react'; import { defineMessages, useIntl } from 'react-intl'; -import { useSearchLocation } from 'pl-fe/api/hooks/search/use-search-location'; import AutosuggestInput, { AutoSuggestion } from 'pl-fe/components/autosuggest-input'; import Icon from 'pl-fe/components/icon'; +import { useSearchLocation } from 'pl-fe/queries/search/use-search-location'; import type { Location } from 'pl-api'; diff --git a/packages/pl-fe/src/components/sidebar-menu.tsx b/packages/pl-fe/src/components/sidebar-menu.tsx index aabaaff18..d1d9669d5 100644 --- a/packages/pl-fe/src/components/sidebar-menu.tsx +++ b/packages/pl-fe/src/components/sidebar-menu.tsx @@ -5,9 +5,7 @@ import { defineMessages, useIntl, FormattedMessage } from 'react-intl'; import { Link, NavLink } from 'react-router-dom'; import { fetchOwnAccounts, logOut, switchAccount } from 'pl-fe/actions/auth'; -import { useFollowRequestsCount } from 'pl-fe/api/hooks/account-lists/use-follow-requests'; import { useAccount } from 'pl-fe/api/hooks/accounts/use-account'; -import { useInteractionRequestsCount } from 'pl-fe/api/hooks/statuses/use-interaction-requests'; import Account from 'pl-fe/components/account'; import Divider from 'pl-fe/components/ui/divider'; import HStack from 'pl-fe/components/ui/hstack'; @@ -20,6 +18,8 @@ import { useAppSelector } from 'pl-fe/hooks/use-app-selector'; import { useFeatures } from 'pl-fe/hooks/use-features'; import { useInstance } from 'pl-fe/hooks/use-instance'; import { useRegistrationStatus } from 'pl-fe/hooks/use-registration-status'; +import { useFollowRequestsCount } from 'pl-fe/queries/account-lists/use-follow-requests'; +import { useInteractionRequestsCount } from 'pl-fe/queries/statuses/use-interaction-requests'; import { makeGetOtherAccounts } from 'pl-fe/selectors'; import { useSettingsStore } from 'pl-fe/stores/settings'; import { useUiStore } from 'pl-fe/stores/ui'; diff --git a/packages/pl-fe/src/components/sidebar-navigation.tsx b/packages/pl-fe/src/components/sidebar-navigation.tsx index bb18d825e..ad3313a61 100644 --- a/packages/pl-fe/src/components/sidebar-navigation.tsx +++ b/packages/pl-fe/src/components/sidebar-navigation.tsx @@ -1,8 +1,6 @@ import React from 'react'; import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; -import { useFollowRequestsCount } from 'pl-fe/api/hooks/account-lists/use-follow-requests'; -import { useInteractionRequestsCount } from 'pl-fe/api/hooks/statuses/use-interaction-requests'; import Icon from 'pl-fe/components/ui/icon'; import Stack from 'pl-fe/components/ui/stack'; import { useStatContext } from 'pl-fe/contexts/stat-context'; @@ -15,6 +13,8 @@ import { useLogo } from 'pl-fe/hooks/use-logo'; import { useOwnAccount } from 'pl-fe/hooks/use-own-account'; import { useRegistrationStatus } from 'pl-fe/hooks/use-registration-status'; import { useSettings } from 'pl-fe/hooks/use-settings'; +import { useFollowRequestsCount } from 'pl-fe/queries/account-lists/use-follow-requests'; +import { useInteractionRequestsCount } from 'pl-fe/queries/statuses/use-interaction-requests'; import Account from './account'; import DropdownMenu, { Menu } from './dropdown-menu'; diff --git a/packages/pl-fe/src/components/status-action-bar.tsx b/packages/pl-fe/src/components/status-action-bar.tsx index 413173f89..1171584ab 100644 --- a/packages/pl-fe/src/components/status-action-bar.tsx +++ b/packages/pl-fe/src/components/status-action-bar.tsx @@ -17,7 +17,6 @@ import { useBlockGroupMember } from 'pl-fe/api/hooks/groups/use-block-group-memb import { useDeleteGroupStatus } from 'pl-fe/api/hooks/groups/use-delete-group-status'; import { useGroup } from 'pl-fe/api/hooks/groups/use-group'; import { useGroupRelationship } from 'pl-fe/api/hooks/groups/use-group-relationship'; -import { useTranslationLanguages } from 'pl-fe/api/hooks/instance/use-translation-languages'; import DropdownMenu from 'pl-fe/components/dropdown-menu'; import StatusActionButton from 'pl-fe/components/status-action-button'; import HStack from 'pl-fe/components/ui/hstack'; @@ -31,6 +30,7 @@ import { useInstance } from 'pl-fe/hooks/use-instance'; import { useOwnAccount } from 'pl-fe/hooks/use-own-account'; import { useSettings } from 'pl-fe/hooks/use-settings'; import { useChats } from 'pl-fe/queries/chats'; +import { useTranslationLanguages } from 'pl-fe/queries/instance/use-translation-languages'; import { RootState } from 'pl-fe/store'; import { useModalsStore } from 'pl-fe/stores/modals'; import { useStatusMetaStore } from 'pl-fe/stores/status-meta'; diff --git a/packages/pl-fe/src/components/status-content.tsx b/packages/pl-fe/src/components/status-content.tsx index 966889c42..d429f5669 100644 --- a/packages/pl-fe/src/components/status-content.tsx +++ b/packages/pl-fe/src/components/status-content.tsx @@ -2,7 +2,6 @@ import clsx from 'clsx'; import React, { useState, useRef, useLayoutEffect, useMemo, useEffect } from 'react'; import { FormattedMessage } from 'react-intl'; -import { useStatusTranslation } from 'pl-fe/api/hooks/statuses/use-status-translation'; import Icon from 'pl-fe/components/icon'; import Button from 'pl-fe/components/ui/button'; import Stack from 'pl-fe/components/ui/stack'; @@ -10,6 +9,7 @@ import Text from 'pl-fe/components/ui/text'; import Emojify from 'pl-fe/features/emoji/emojify'; import QuotedStatus from 'pl-fe/features/status/containers/quoted-status-container'; import { useSettings } from 'pl-fe/hooks/use-settings'; +import { useStatusTranslation } from 'pl-fe/queries/statuses/use-status-translation'; import { useStatusMetaStore } from 'pl-fe/stores/status-meta'; import { onlyEmoji as isOnlyEmoji } from 'pl-fe/utils/rich-content'; diff --git a/packages/pl-fe/src/components/translate-button.tsx b/packages/pl-fe/src/components/translate-button.tsx index 3d8e41198..32eab1807 100644 --- a/packages/pl-fe/src/components/translate-button.tsx +++ b/packages/pl-fe/src/components/translate-button.tsx @@ -1,8 +1,6 @@ import React, { useEffect } from 'react'; import { FormattedMessage, useIntl } from 'react-intl'; -import { useTranslationLanguages } from 'pl-fe/api/hooks/instance/use-translation-languages'; -import { useStatusTranslation } from 'pl-fe/api/hooks/statuses/use-status-translation'; import HStack from 'pl-fe/components/ui/hstack'; import Icon from 'pl-fe/components/ui/icon'; import Stack from 'pl-fe/components/ui/stack'; @@ -11,6 +9,8 @@ import { useAppSelector } from 'pl-fe/hooks/use-app-selector'; import { useFeatures } from 'pl-fe/hooks/use-features'; import { useInstance } from 'pl-fe/hooks/use-instance'; import { useSettings } from 'pl-fe/hooks/use-settings'; +import { useTranslationLanguages } from 'pl-fe/queries/instance/use-translation-languages'; +import { useStatusTranslation } from 'pl-fe/queries/statuses/use-status-translation'; import { useStatusMetaStore } from 'pl-fe/stores/status-meta'; import type { Status } from 'pl-fe/normalizers/status'; diff --git a/packages/pl-fe/src/components/upload.tsx b/packages/pl-fe/src/components/upload.tsx index 095407f05..65b238e03 100644 --- a/packages/pl-fe/src/components/upload.tsx +++ b/packages/pl-fe/src/components/upload.tsx @@ -237,7 +237,7 @@ const Upload: React.FC = ({ /> )} -
+
{mediaType === 'video' && (
-
+
-
+
diff --git a/packages/pl-fe/src/features/status/components/thread-status.tsx b/packages/pl-fe/src/features/status/components/thread-status.tsx index 0d9495d78..18cceb488 100644 --- a/packages/pl-fe/src/features/status/components/thread-status.tsx +++ b/packages/pl-fe/src/features/status/components/thread-status.tsx @@ -26,12 +26,7 @@ const ThreadStatus: React.FC = (props): JSX.Element => { if (isDeleted) { return (
- +
); } diff --git a/packages/pl-fe/src/features/status/components/thread.tsx b/packages/pl-fe/src/features/status/components/thread.tsx index 4f8bbda1b..1a2f4e77f 100644 --- a/packages/pl-fe/src/features/status/components/thread.tsx +++ b/packages/pl-fe/src/features/status/components/thread.tsx @@ -329,7 +329,7 @@ const Thread: React.FC = ({ const focusedStatus = (
{status.deleted ? ( - + ) : (
Date: Thu, 5 Dec 2024 16:13:32 +0100 Subject: [PATCH 33/46] recommend tailwind css vscode extension Signed-off-by: mkljczk --- .vscode/extensions.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index d1762aa9a..33be54684 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -4,6 +4,6 @@ "bradlc.vscode-tailwindcss", "stylelint.vscode-stylelint", "wix.vscode-import-cost", - "redhat.vscode-yaml" + "bradlc.vscode-tailwindcss" ] } From 6687a12f01841b77167184747a53affb7a398603 Mon Sep 17 00:00:00 2001 From: mkljczk Date: Thu, 5 Dec 2024 16:14:05 +0100 Subject: [PATCH 34/46] pl-fe: update verified badge styles Signed-off-by: mkljczk --- packages/pl-fe/src/features/account/components/header.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/pl-fe/src/features/account/components/header.tsx b/packages/pl-fe/src/features/account/components/header.tsx index 201a526c1..4847b75fd 100644 --- a/packages/pl-fe/src/features/account/components/header.tsx +++ b/packages/pl-fe/src/features/account/components/header.tsx @@ -657,7 +657,7 @@ const Header: React.FC = ({ account }) => { /> {account.verified && ( -
+
)} From 4c0bd101c57e857ac392db1cf556f936750cae58 Mon Sep 17 00:00:00 2001 From: mkljczk Date: Thu, 5 Dec 2024 16:14:28 +0100 Subject: [PATCH 35/46] pl-fe: make search input focusable by hotkeys again Signed-off-by: mkljczk --- packages/pl-fe/src/components/autosuggest-account-input.tsx | 1 + packages/pl-fe/src/components/search-input.tsx | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/pl-fe/src/components/autosuggest-account-input.tsx b/packages/pl-fe/src/components/autosuggest-account-input.tsx index aa75dae6f..fadff8f28 100644 --- a/packages/pl-fe/src/components/autosuggest-account-input.tsx +++ b/packages/pl-fe/src/components/autosuggest-account-input.tsx @@ -11,6 +11,7 @@ import type { InputThemes } from 'pl-fe/components/ui/input'; const noOp = () => { }; interface IAutosuggestAccountInput { + id?: string; onChange: React.ChangeEventHandler; onSelected: (accountId: string) => void; autoFocus?: boolean; diff --git a/packages/pl-fe/src/components/search-input.tsx b/packages/pl-fe/src/components/search-input.tsx index 11460b297..36e571bf6 100644 --- a/packages/pl-fe/src/components/search-input.tsx +++ b/packages/pl-fe/src/components/search-input.tsx @@ -78,6 +78,7 @@ const SearchInput = () => {
Date: Thu, 5 Dec 2024 16:31:23 +0100 Subject: [PATCH 36/46] pl-fe: optimize initial js size Signed-off-by: mkljczk --- .../pl-fe/src/components/account-hover-card.tsx | 2 +- packages/pl-fe/src/components/account.tsx | 2 +- .../announcements/announcements-panel.tsx | 2 +- .../src/components/announcements/reaction.tsx | 4 ++-- .../pl-fe/src/components/autosuggest-input.tsx | 2 +- packages/pl-fe/src/components/avatar-stack.tsx | 2 +- packages/pl-fe/src/components/big-card.tsx | 2 +- .../dropdown-menu/dropdown-menu-item.tsx | 4 ++-- .../components/dropdown-menu/dropdown-menu.tsx | 4 ++-- packages/pl-fe/src/components/event-preview.tsx | 4 ++-- packages/pl-fe/src/components/group-card.tsx | 4 ++-- .../components/groups/popover/group-popover.tsx | 4 ++-- packages/pl-fe/src/components/hashtags-bar.tsx | 2 +- .../pl-fe/src/components/landing-gradient.tsx | 2 +- packages/pl-fe/src/components/link.tsx | 2 +- packages/pl-fe/src/components/list.tsx | 2 +- packages/pl-fe/src/components/mention.tsx | 2 +- packages/pl-fe/src/components/modal-root.tsx | 2 +- packages/pl-fe/src/components/navlinks.tsx | 2 +- packages/pl-fe/src/components/parsed-content.tsx | 2 +- .../pl-fe/src/components/pending-items-row.tsx | 2 +- .../pl-fe/src/components/polls/poll-option.tsx | 10 +++++----- packages/pl-fe/src/components/radio.tsx | 2 +- .../pl-fe/src/components/scroll-top-button.tsx | 2 +- packages/pl-fe/src/components/sidebar-menu.tsx | 12 ++++++------ .../pl-fe/src/components/site-error-boundary.tsx | 8 ++++---- .../src/components/status-action-button.tsx | 2 +- .../pl-fe/src/components/status-hover-card.tsx | 2 +- packages/pl-fe/src/components/status-mention.tsx | 2 +- .../src/components/status-reactions-bar.tsx | 2 +- .../src/components/status-reply-mentions.tsx | 2 +- packages/pl-fe/src/components/status.tsx | 4 ++-- .../src/components/statuses/status-info.tsx | 2 +- .../pl-fe/src/components/thumb-navigation.tsx | 6 +++--- packages/pl-fe/src/components/trending-link.tsx | 2 +- packages/pl-fe/src/components/ui/accordion.tsx | 2 +- packages/pl-fe/src/components/ui/card.tsx | 2 +- packages/pl-fe/src/components/ui/checkbox.tsx | 2 +- packages/pl-fe/src/components/ui/counter.tsx | 2 +- packages/pl-fe/src/components/ui/divider.tsx | 4 ++-- packages/pl-fe/src/components/ui/form-group.tsx | 4 ++-- packages/pl-fe/src/components/ui/icon-button.tsx | 2 +- .../src/components/ui/inline-multiselect.tsx | 4 ++-- packages/pl-fe/src/components/ui/input.tsx | 4 ++-- packages/pl-fe/src/components/ui/layout.tsx | 2 +- packages/pl-fe/src/components/ui/modal.tsx | 8 ++++---- packages/pl-fe/src/components/ui/popover.tsx | 4 ++-- .../pl-fe/src/components/ui/progress-bar.tsx | 4 ++-- packages/pl-fe/src/components/ui/select.tsx | 2 +- packages/pl-fe/src/components/ui/slider.tsx | 6 +++--- packages/pl-fe/src/components/ui/tabs.tsx | 4 ++-- packages/pl-fe/src/components/ui/tag-input.tsx | 2 +- packages/pl-fe/src/components/ui/tag.tsx | 2 +- packages/pl-fe/src/components/ui/textarea.tsx | 2 +- packages/pl-fe/src/components/ui/toast.tsx | 8 ++++---- packages/pl-fe/src/components/ui/toggle.tsx | 2 +- packages/pl-fe/src/components/ui/widget.tsx | 2 +- .../pl-fe/src/components/verification-badge.tsx | 4 ++-- packages/pl-fe/src/features/about/index.tsx | 2 +- .../account-timeline/components/moved-note.tsx | 2 +- .../src/features/account/components/header.tsx | 8 ++++---- .../pl-fe/src/features/admin/announcements.tsx | 2 +- .../src/features/admin/components/report.tsx | 2 +- packages/pl-fe/src/features/admin/domains.tsx | 2 +- packages/pl-fe/src/features/admin/relays.tsx | 2 +- packages/pl-fe/src/features/admin/rules.tsx | 2 +- .../src/features/aliases/components/search.tsx | 2 +- packages/pl-fe/src/features/audio/index.tsx | 4 ++-- .../auth-login/components/consumers-list.tsx | 2 +- .../pl-fe/src/features/auth-token-list/index.tsx | 2 +- packages/pl-fe/src/features/backups/index.tsx | 2 +- .../features/chats/components/chat-composer.tsx | 4 ++-- .../features/chats/components/chat-list-item.tsx | 4 ++-- .../src/features/chats/components/chat-list.tsx | 4 ++-- .../chats/components/chat-page/chat-page.tsx | 6 +++--- .../chats/components/chat-pending-upload.tsx | 2 +- .../chats/components/chat-search/results.tsx | 4 ++-- .../features/chats/components/chat-textarea.tsx | 16 ++++++++-------- .../features/chats/components/chat-upload.tsx | 4 ++-- .../components/chat-widget/chat-pane-header.tsx | 2 +- .../components/chat-widget/chat-settings.tsx | 6 +++--- .../chats/components/chat-widget/chat-window.tsx | 2 +- .../chat-widget/headers/chat-search-header.tsx | 2 +- .../src/features/chats/components/ui/pane.tsx | 2 +- packages/pl-fe/src/features/circle/index.tsx | 2 +- .../compose-event/components/upload-button.tsx | 2 +- .../features/compose-event/tabs/edit-event.tsx | 4 ++-- .../features/compose/components/compose-form.tsx | 2 +- .../compose/components/language-dropdown.tsx | 2 +- .../compose/components/reply-indicator.tsx | 2 +- .../compose/components/reply-mentions.tsx | 2 +- .../plugins/floating-link-editor-plugin.tsx | 2 +- .../floating-text-format-toolbar-plugin.tsx | 4 ++-- .../crypto-donate/components/crypto-address.tsx | 3 +-- .../components/detailed-crypto-address.tsx | 3 +-- .../directory/components/account-card.tsx | 4 ++-- .../edit-profile/components/avatar-picker.tsx | 2 +- .../edit-profile/components/header-picker.tsx | 2 +- .../pl-fe/src/features/embedded-status/index.tsx | 2 +- .../features/event/components/event-header.tsx | 6 +++--- .../src/features/event/event-discussion.tsx | 2 +- .../src/features/event/event-information.tsx | 4 ++-- packages/pl-fe/src/features/filters/index.tsx | 2 +- .../features/group/components/group-header.tsx | 8 ++++---- .../pl-fe/src/features/group/group-timeline.tsx | 2 +- .../src/features/hashtag-timeline/index.tsx | 2 +- .../pl-fe/src/features/home-timeline/index.tsx | 2 +- .../src/features/interaction-requests/index.tsx | 6 +++--- .../landing-timeline/components/logo-text.tsx | 2 +- packages/pl-fe/src/features/migration/index.tsx | 2 +- .../notifications/components/notification.tsx | 2 +- .../pl-fe/src/features/notifications/index.tsx | 2 +- .../onboarding/steps/avatar-selection-step.tsx | 2 +- .../features/onboarding/steps/completed-step.tsx | 2 +- .../steps/cover-photo-selection-step.tsx | 4 ++-- .../features/onboarding/steps/fediverse-step.tsx | 6 +++--- .../onboarding/steps/suggested-accounts-step.tsx | 2 +- .../pl-fe-config/components/icon-picker-menu.tsx | 4 ++-- .../pl-fe-config/components/site-preview.tsx | 2 +- .../components/placeholder-avatar.tsx | 4 ++-- .../placeholder/components/placeholder-card.tsx | 2 +- .../components/placeholder-chat-message.tsx | 4 ++-- .../components/placeholder-display-name.tsx | 2 +- .../components/placeholder-event-header.tsx | 2 +- .../components/placeholder-event-preview.tsx | 4 ++-- .../components/placeholder-group-card.tsx | 4 ++-- .../components/placeholder-group-search.tsx | 2 +- .../components/placeholder-hashtag.tsx | 2 +- .../components/placeholder-media-gallery.tsx | 2 +- .../components/placeholder-notification.tsx | 2 +- .../placeholder-sidebar-suggestions.tsx | 2 +- .../components/placeholder-sidebar-trends.tsx | 2 +- .../components/placeholder-status-content.tsx | 2 +- .../pl-fe/src/features/public-timeline/index.tsx | 2 +- .../components/pinned-hosts-picker.tsx | 2 +- .../src/features/search/components/search.tsx | 2 +- .../status/components/detailed-status.tsx | 2 +- .../features/status/components/thread-status.tsx | 2 +- .../src/features/status/components/thread.tsx | 6 +++--- .../features/ui/components/background-shapes.tsx | 2 +- .../features/ui/components/column-forbidden.tsx | 2 +- .../components/modals/compare-history-modal.tsx | 2 +- .../ui/components/modals/compose-modal.tsx | 2 +- .../ui/components/modals/dropdown-menu-modal.tsx | 2 +- .../modals/edit-bookmark-folder-modal.tsx | 2 +- .../ui/components/modals/hotkeys-modal.tsx | 2 +- .../steps/confirmation-step.tsx | 6 +++--- .../report-modal/steps/confirmation-step.tsx | 2 +- .../modals/report-modal/steps/reason-step.tsx | 2 +- .../features/ui/components/profile-dropdown.tsx | 6 +++--- packages/pl-fe/src/features/ui/index.tsx | 2 +- .../src/features/ui/util/async-components.ts | 2 ++ packages/pl-fe/src/features/video/index.tsx | 2 +- packages/pl-fe/src/init/pl-fe-head.tsx | 2 +- packages/pl-fe/src/layouts/chats-layout.tsx | 2 +- packages/pl-fe/src/layouts/home-layout.tsx | 4 ++-- packages/pl-fe/src/layouts/landing-layout.tsx | 2 +- packages/pl-fe/vite.config.ts | 2 +- 158 files changed, 242 insertions(+), 242 deletions(-) diff --git a/packages/pl-fe/src/components/account-hover-card.tsx b/packages/pl-fe/src/components/account-hover-card.tsx index 1286f798a..5c721f950 100644 --- a/packages/pl-fe/src/components/account-hover-card.tsx +++ b/packages/pl-fe/src/components/account-hover-card.tsx @@ -124,7 +124,7 @@ const AccountHoverCard: React.FC = ({ visible = true }) => { onMouseEnter={handleMouseEnter} onMouseLeave={handleMouseLeave} > - + = ({ account, disabled }) => { return ( diff --git a/packages/pl-fe/src/components/autosuggest-input.tsx b/packages/pl-fe/src/components/autosuggest-input.tsx index 1fc057963..5756a59be 100644 --- a/packages/pl-fe/src/components/autosuggest-input.tsx +++ b/packages/pl-fe/src/components/autosuggest-input.tsx @@ -217,7 +217,7 @@ const AutosuggestInput: React.FC = ({ return menu.map((item, i) => ( = ({ accountIds, limit = 3 }) => { style={{ zIndex: limit - i }} > = ({ title, subtitle, children }) => ( -
+
{title} {subtitle && {subtitle}} diff --git a/packages/pl-fe/src/components/dropdown-menu/dropdown-menu-item.tsx b/packages/pl-fe/src/components/dropdown-menu/dropdown-menu-item.tsx index 8e0390a8d..3e7e4b268 100644 --- a/packages/pl-fe/src/components/dropdown-menu/dropdown-menu-item.tsx +++ b/packages/pl-fe/src/components/dropdown-menu/dropdown-menu-item.tsx @@ -100,7 +100,7 @@ const DropdownMenuItem = ({ index, item, onClick, autoFocus, onSetTab }: IDropdo } return ( -
  • +
  • { } const getClassName = () => { - const className = clsx('z-[1001] bg-white py-1 shadow-lg ease-in-out focus:outline-none black:bg-black no-reduce-motion:transition-all dark:bg-gray-900 dark:ring-2 dark:ring-primary-700', { + const className = clsx('black:bg-black no-reduce-motion:transition-all dark:ring-primary-700 z-[1001] bg-white py-1 shadow-lg ease-in-out focus:outline-none dark:bg-gray-900 dark:ring-2', { 'rounded-md min-w-56 max-w-sm duration-100': true, 'no-reduce-motion:scale-0': !(isDisplayed && isOpen), 'scale-100': isDisplayed && isOpen, @@ -371,7 +371,7 @@ const DropdownMenu = (props: IDropdownMenu) => {
  • diff --git a/packages/pl-fe/src/components/event-preview.tsx b/packages/pl-fe/src/components/event-preview.tsx index 3d457cbad..ae33e35ac 100644 --- a/packages/pl-fe/src/components/event-preview.tsx +++ b/packages/pl-fe/src/components/event-preview.tsx @@ -54,11 +54,11 @@ const EventPreview: React.FC = ({ status, className, hideAction, )); return ( -
    +
    {floatingAction && action}
    -
    +
    {banner && {intl.formatMessage(messages.eventBanner)}}
    diff --git a/packages/pl-fe/src/components/group-card.tsx b/packages/pl-fe/src/components/group-card.tsx index 1a384169a..db067ebf1 100644 --- a/packages/pl-fe/src/components/group-card.tsx +++ b/packages/pl-fe/src/components/group-card.tsx @@ -19,11 +19,11 @@ interface IGroupCard { const GroupCard: React.FC = ({ group }) => ( {/* Group Cover Image */} - + { content={ {/* Group Cover Image */} - + {group.header && ( = ({ hashtags }) => { key={hashtag} to={`/tags/${hashtag}`} onClick={(e) => e.stopPropagation()} - className='flex items-center rounded-sm bg-gray-100 px-1.5 py-1 text-center text-xs font-medium text-primary-600 black:bg-primary-900 dark:bg-primary-700 dark:text-white' + className='text-primary-600 black:bg-primary-900 dark:bg-primary-700 flex items-center rounded-sm bg-gray-100 px-1.5 py-1 text-center text-xs font-medium dark:text-white' > #{hashtag} diff --git a/packages/pl-fe/src/components/landing-gradient.tsx b/packages/pl-fe/src/components/landing-gradient.tsx index 7bf75dc11..0e582c7dd 100644 --- a/packages/pl-fe/src/components/landing-gradient.tsx +++ b/packages/pl-fe/src/components/landing-gradient.tsx @@ -2,7 +2,7 @@ import React from 'react'; /** Fullscreen gradient used as a backdrop to public pages. */ const LandingGradient: React.FC = () => ( -
    +
    ); export { LandingGradient as default }; diff --git a/packages/pl-fe/src/components/link.tsx b/packages/pl-fe/src/components/link.tsx index 413061279..7516ce49f 100644 --- a/packages/pl-fe/src/components/link.tsx +++ b/packages/pl-fe/src/components/link.tsx @@ -4,7 +4,7 @@ import { Link as Comp, LinkProps } from 'react-router-dom'; const Link = (props: LinkProps) => ( ); diff --git a/packages/pl-fe/src/components/list.tsx b/packages/pl-fe/src/components/list.tsx index d5881ff4b..b125be4d1 100644 --- a/packages/pl-fe/src/components/list.tsx +++ b/packages/pl-fe/src/components/list.tsx @@ -56,7 +56,7 @@ const ListItem: React.FC = ({ className, label, hint, children, to, h return null; }), [children, domId]); - const classNames = clsx('flex items-center justify-between overflow-hidden bg-gradient-to-r from-gradient-start/20 to-gradient-end/20 first:rounded-t-lg last:rounded-b-lg dark:from-gradient-start/10 dark:to-gradient-end/10', + const classNames = clsx('from-gradient-start/20 to-gradient-end/20 dark:from-gradient-start/10 dark:to-gradient-end/10 flex items-center justify-between overflow-hidden bg-gradient-to-r first:rounded-t-lg last:rounded-b-lg', className, { 'px-4 py-2': size === 'md', diff --git a/packages/pl-fe/src/components/mention.tsx b/packages/pl-fe/src/components/mention.tsx index 68bcabb39..56310296b 100644 --- a/packages/pl-fe/src/components/mention.tsx +++ b/packages/pl-fe/src/components/mention.tsx @@ -23,7 +23,7 @@ const Mention: React.FC = ({ mention: { acct, username }, disabled }) diff --git a/packages/pl-fe/src/components/modal-root.tsx b/packages/pl-fe/src/components/modal-root.tsx index be0eb10fc..a6dfa527c 100644 --- a/packages/pl-fe/src/components/modal-root.tsx +++ b/packages/pl-fe/src/components/modal-root.tsx @@ -205,7 +205,7 @@ const ModalRoot: React.FC = ({ children, onCancel, onClose, type })