Merge branch 'fetch-relationships' into 'develop'

Fetch relationships when opening favourites/reblogs modal

See merge request soapbox-pub/soapbox-fe!1750
This commit is contained in:
Justin 2022-08-26 12:50:51 +00:00
commit 7191c2af72
6 changed files with 16 additions and 16 deletions

View file

@ -5,6 +5,7 @@ import { isLoggedIn } from 'soapbox/utils/auth';
import api from '../api'; import api from '../api';
import { fetchRelationships } from './accounts';
import { importFetchedAccounts, importFetchedStatus } from './importer'; import { importFetchedAccounts, importFetchedStatus } from './importer';
import type { AxiosError } from 'axios'; import type { AxiosError } from 'axios';
@ -292,6 +293,7 @@ const fetchReblogs = (id: string) =>
api(getState).get(`/api/v1/statuses/${id}/reblogged_by`).then(response => { api(getState).get(`/api/v1/statuses/${id}/reblogged_by`).then(response => {
dispatch(importFetchedAccounts(response.data)); dispatch(importFetchedAccounts(response.data));
dispatch(fetchRelationships(response.data.map((item: APIEntity) => item.id)));
dispatch(fetchReblogsSuccess(id, response.data)); dispatch(fetchReblogsSuccess(id, response.data));
}).catch(error => { }).catch(error => {
dispatch(fetchReblogsFail(id, error)); dispatch(fetchReblogsFail(id, error));
@ -323,6 +325,7 @@ const fetchFavourites = (id: string) =>
api(getState).get(`/api/v1/statuses/${id}/favourited_by`).then(response => { api(getState).get(`/api/v1/statuses/${id}/favourited_by`).then(response => {
dispatch(importFetchedAccounts(response.data)); dispatch(importFetchedAccounts(response.data));
dispatch(fetchRelationships(response.data.map((item: APIEntity) => item.id)));
dispatch(fetchFavouritesSuccess(id, response.data)); dispatch(fetchFavouritesSuccess(id, response.data));
}).catch(error => { }).catch(error => {
dispatch(fetchFavouritesFail(id, error)); dispatch(fetchFavouritesFail(id, error));

View file

@ -97,7 +97,7 @@ export const ProfileHoverCard: React.FC<IProfileHoverCard> = ({ visible = true }
return ( return (
<div <div
className={classNames({ className={classNames({
'absolute transition-opacity w-[320px] z-50 top-0 left-0': true, 'absolute transition-opacity w-[320px] z-[101] top-0 left-0': true,
'opacity-100': visible, 'opacity-100': visible,
'opacity-0 pointer-events-none': !visible, 'opacity-0 pointer-events-none': !visible,
})} })}

View file

@ -163,7 +163,7 @@ const StatusInteractionBar: React.FC<IStatusInteractionBar> = ({ status }): JSX.
return ( return (
<HStack space={3}> <HStack space={3}>
{getReposts()} {getReposts()}
{features.emojiReacts ? getEmojiReacts() : getFavourites()} {features.emojiReacts ? getEmojiReacts() : getFavourites()}
</HStack> </HStack>
); );

View file

@ -2,8 +2,7 @@ import React, { useEffect } from 'react';
import { FormattedMessage } from 'react-intl'; import { FormattedMessage } from 'react-intl';
import { fetchFavourites } from 'soapbox/actions/interactions'; import { fetchFavourites } from 'soapbox/actions/interactions';
import ScrollableList from 'soapbox/components/scrollable_list'; import { Modal, Spinner, Stack } from 'soapbox/components/ui';
import { Modal, Spinner } from 'soapbox/components/ui';
import AccountContainer from 'soapbox/containers/account_container'; import AccountContainer from 'soapbox/containers/account_container';
import { useAppDispatch, useAppSelector } from 'soapbox/hooks'; import { useAppDispatch, useAppSelector } from 'soapbox/hooks';
@ -34,18 +33,16 @@ const FavouritesModal: React.FC<IFavouritesModal> = ({ onClose, statusId }) => {
if (!accountIds) { if (!accountIds) {
body = <Spinner />; body = <Spinner />;
} else { } else {
const emptyMessage = <FormattedMessage id='empty_column.favourites' defaultMessage='No one has liked this post yet. When someone does, they will show up here.' />;
body = ( body = (
<ScrollableList <Stack space={3}>
scrollKey='favourites' {accountIds.size > 0 ? (
emptyMessage={emptyMessage} accountIds.map((id) =>
itemClassName='pb-3' <AccountContainer key={id} id={id} />,
> )
{accountIds.map((id) => ) : (
<AccountContainer key={id} id={id} />, <FormattedMessage id='empty_column.favourites' defaultMessage='No one has liked this post yet. When someone does, they will show up here.' />
)} )}
</ScrollableList> </Stack>
); );
} }

View file

@ -203,7 +203,7 @@ export function ReblogsModal() {
} }
export function FavouritesModal() { export function FavouritesModal() {
return import(/* webpackChunkName: "features/ui" */'../components/favourites_modal'); return import(/* webpackChunkName: "features/ui" */'../components/modals/favourites-modal');
} }
export function ReactionsModal() { export function ReactionsModal() {

View file

@ -6035,7 +6035,7 @@
"id": "column.favourites" "id": "column.favourites"
} }
], ],
"path": "app/soapbox/features/ui/components/favourites_modal.json" "path": "app/soapbox/features/ui/components/modals/favourites-modal.json"
}, },
{ {
"descriptors": [ "descriptors": [