diff --git a/app/soapbox/actions/announcements.ts b/app/soapbox/actions/announcements.ts index 49e63c65af..7047f6004e 100644 --- a/app/soapbox/actions/announcements.ts +++ b/app/soapbox/actions/announcements.ts @@ -1,4 +1,5 @@ -import api from '../api'; +import api from 'soapbox/api'; +import { getFeatures } from 'soapbox/utils/features'; import { importFetchedStatuses } from './importer'; @@ -32,6 +33,11 @@ const noOp = () => {}; export const fetchAnnouncements = (done = noOp) => (dispatch: AppDispatch, getState: () => RootState) => { + const { instance } = getState(); + const features = getFeatures(instance); + + if (!features.announcements) return null; + dispatch(fetchAnnouncementsRequest()); return api(getState).get('/api/v1/announcements').then(response => { diff --git a/app/soapbox/components/announcements/announcement.tsx b/app/soapbox/components/announcements/announcement.tsx index 4f8ffa3bcb..f6344f7b5d 100644 --- a/app/soapbox/components/announcements/announcement.tsx +++ b/app/soapbox/components/announcements/announcement.tsx @@ -2,6 +2,7 @@ import React from 'react'; import { FormattedDate } from 'react-intl'; import { Stack, Text } from 'soapbox/components/ui'; +import { useFeatures } from 'soapbox/hooks'; import AnnouncementContent from './announcement-content'; import ReactionsBar from './reactions-bar'; @@ -17,6 +18,8 @@ interface IAnnouncement { } const Announcement: React.FC = ({ announcement, addReaction, removeReaction, emojiMap }) => { + const features = useFeatures(); + const startsAt = announcement.starts_at && new Date(announcement.starts_at); const endsAt = announcement.ends_at && new Date(announcement.ends_at); const now = new Date(); @@ -26,35 +29,35 @@ const Announcement: React.FC = ({ announcement, addReaction, remo const skipTime = announcement.all_day; return ( -
- - {hasTimeRange && ( - - - {' '} - - - {' '} - - - )} + + {hasTimeRange && ( + + + {' '} + - + {' '} + + + )} - + + {features.announcementsReactions && ( = ({ announcement, addReaction, remo removeReaction={removeReaction} emojiMap={emojiMap} /> - -
+ )} + ); }; diff --git a/app/soapbox/components/announcements/announcements-panel.tsx b/app/soapbox/components/announcements/announcements-panel.tsx index ade25057f4..200615dab8 100644 --- a/app/soapbox/components/announcements/announcements-panel.tsx +++ b/app/soapbox/components/announcements/announcements-panel.tsx @@ -45,7 +45,7 @@ const AnnouncementsPanel = () => { /> )).reverse()} - {announcements.size > 2 && ( + {announcements.size > 1 && ( {announcements.map((_, i) => (