Merge branch 'fix-request-to-media' into 'develop'
Fix 403 toast on Group Media endpoint See merge request soapbox-pub/soapbox!2451
This commit is contained in:
commit
5d58a3e18f
|
@ -21,6 +21,9 @@ const GroupMediaPanel: React.FC<IGroupMediaPanel> = ({ group }) => {
|
||||||
|
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
|
const isMember = !!group?.relationship?.member;
|
||||||
|
const isPrivate = group?.locked;
|
||||||
|
|
||||||
const attachments: ImmutableList<Attachment> = useAppSelector((state) => group ? getGroupGallery(state, group?.id) : ImmutableList());
|
const attachments: ImmutableList<Attachment> = useAppSelector((state) => group ? getGroupGallery(state, group?.id) : ImmutableList());
|
||||||
|
|
||||||
const handleOpenMedia = (attachment: Attachment): void => {
|
const handleOpenMedia = (attachment: Attachment): void => {
|
||||||
|
@ -37,13 +40,13 @@ const GroupMediaPanel: React.FC<IGroupMediaPanel> = ({ group }) => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|
||||||
if (group) {
|
if (group && (isMember || !isPrivate)) {
|
||||||
dispatch(expandGroupMediaTimeline(group.id))
|
dispatch(expandGroupMediaTimeline(group.id))
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
.then(() => setLoading(false))
|
.then(() => setLoading(false))
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
}
|
}
|
||||||
}, [group?.id]);
|
}, [group?.id, isMember, isPrivate]);
|
||||||
|
|
||||||
const renderAttachments = () => {
|
const renderAttachments = () => {
|
||||||
const nineAttachments = attachments.slice(0, 9);
|
const nineAttachments = attachments.slice(0, 9);
|
||||||
|
@ -69,6 +72,10 @@ const GroupMediaPanel: React.FC<IGroupMediaPanel> = ({ group }) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (isPrivate && !isMember) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Widget title={<FormattedMessage id='media_panel.title' defaultMessage='Media' />}>
|
<Widget title={<FormattedMessage id='media_panel.title' defaultMessage='Media' />}>
|
||||||
{group && (
|
{group && (
|
||||||
|
|
Loading…
Reference in New Issue