From edce9d0876f63df779ad4fd03f3b6df46fe84e23 Mon Sep 17 00:00:00 2001 From: Justin Date: Thu, 25 Aug 2022 08:52:11 -0400 Subject: [PATCH] Fetch relationships when opening favourites/reblogs modal --- app/soapbox/actions/interactions.ts | 3 +++ app/soapbox/components/profile-hover-card.tsx | 2 +- .../components/status-interaction-bar.tsx | 2 +- .../favourites-modal.tsx} | 20 +++++++++---------- .../features/ui/util/async-components.ts | 2 +- app/soapbox/locales/defaultMessages.json | 2 +- 6 files changed, 16 insertions(+), 15 deletions(-) rename app/soapbox/features/ui/components/{favourites_modal.tsx => modals/favourites-modal.tsx} (71%) diff --git a/app/soapbox/actions/interactions.ts b/app/soapbox/actions/interactions.ts index 70fd93317c..1a90a259fd 100644 --- a/app/soapbox/actions/interactions.ts +++ b/app/soapbox/actions/interactions.ts @@ -5,6 +5,7 @@ import { isLoggedIn } from 'soapbox/utils/auth'; import api from '../api'; +import { fetchRelationships } from './accounts'; import { importFetchedAccounts, importFetchedStatus } from './importer'; import type { AxiosError } from 'axios'; @@ -292,6 +293,7 @@ const fetchReblogs = (id: string) => api(getState).get(`/api/v1/statuses/${id}/reblogged_by`).then(response => { dispatch(importFetchedAccounts(response.data)); + dispatch(fetchRelationships(response.data.map((item: APIEntity) => item.id))); dispatch(fetchReblogsSuccess(id, response.data)); }).catch(error => { dispatch(fetchReblogsFail(id, error)); @@ -323,6 +325,7 @@ const fetchFavourites = (id: string) => api(getState).get(`/api/v1/statuses/${id}/favourited_by`).then(response => { dispatch(importFetchedAccounts(response.data)); + dispatch(fetchRelationships(response.data.map((item: APIEntity) => item.id))); dispatch(fetchFavouritesSuccess(id, response.data)); }).catch(error => { dispatch(fetchFavouritesFail(id, error)); diff --git a/app/soapbox/components/profile-hover-card.tsx b/app/soapbox/components/profile-hover-card.tsx index 11de952f26..e2574c7553 100644 --- a/app/soapbox/components/profile-hover-card.tsx +++ b/app/soapbox/components/profile-hover-card.tsx @@ -97,7 +97,7 @@ export const ProfileHoverCard: React.FC = ({ visible = true } return (
= ({ status }): JSX. return ( {getReposts()} - + {features.emojiReacts ? getEmojiReacts() : getFavourites()} ); diff --git a/app/soapbox/features/ui/components/favourites_modal.tsx b/app/soapbox/features/ui/components/modals/favourites-modal.tsx similarity index 71% rename from app/soapbox/features/ui/components/favourites_modal.tsx rename to app/soapbox/features/ui/components/modals/favourites-modal.tsx index 60bc9123f0..f1452b5826 100644 --- a/app/soapbox/features/ui/components/favourites_modal.tsx +++ b/app/soapbox/features/ui/components/modals/favourites-modal.tsx @@ -3,7 +3,7 @@ import { FormattedMessage } from 'react-intl'; import { fetchFavourites } from 'soapbox/actions/interactions'; import ScrollableList from 'soapbox/components/scrollable_list'; -import { Modal, Spinner } from 'soapbox/components/ui'; +import { Modal, Spinner, Stack } from 'soapbox/components/ui'; import AccountContainer from 'soapbox/containers/account_container'; import { useAppDispatch, useAppSelector } from 'soapbox/hooks'; @@ -34,18 +34,16 @@ const FavouritesModal: React.FC = ({ onClose, statusId }) => { if (!accountIds) { body = ; } else { - const emptyMessage = ; - body = ( - - {accountIds.map((id) => - , + + {accountIds.size > 0 ? ( + accountIds.map((id) => + , + ) + ) : ( + )} - + ); } diff --git a/app/soapbox/features/ui/util/async-components.ts b/app/soapbox/features/ui/util/async-components.ts index 8836b9a09d..e73efd2434 100644 --- a/app/soapbox/features/ui/util/async-components.ts +++ b/app/soapbox/features/ui/util/async-components.ts @@ -203,7 +203,7 @@ export function ReblogsModal() { } export function FavouritesModal() { - return import(/* webpackChunkName: "features/ui" */'../components/favourites_modal'); + return import(/* webpackChunkName: "features/ui" */'../components/modals/favourites-modal'); } export function ReactionsModal() { diff --git a/app/soapbox/locales/defaultMessages.json b/app/soapbox/locales/defaultMessages.json index 674824f45d..2dd513e590 100644 --- a/app/soapbox/locales/defaultMessages.json +++ b/app/soapbox/locales/defaultMessages.json @@ -6035,7 +6035,7 @@ "id": "column.favourites" } ], - "path": "app/soapbox/features/ui/components/favourites_modal.json" + "path": "app/soapbox/features/ui/components/modals/favourites-modal.json" }, { "descriptors": [