Disable announcements reactions on Pleroma
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
724fe8b765
commit
f6a0d31b54
4 changed files with 54 additions and 31 deletions
|
@ -1,4 +1,5 @@
|
||||||
import api from '../api';
|
import api from 'soapbox/api';
|
||||||
|
import { getFeatures } from 'soapbox/utils/features';
|
||||||
|
|
||||||
import { importFetchedStatuses } from './importer';
|
import { importFetchedStatuses } from './importer';
|
||||||
|
|
||||||
|
@ -32,6 +33,11 @@ const noOp = () => {};
|
||||||
|
|
||||||
export const fetchAnnouncements = (done = noOp) =>
|
export const fetchAnnouncements = (done = noOp) =>
|
||||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||||
|
const { instance } = getState();
|
||||||
|
const features = getFeatures(instance);
|
||||||
|
|
||||||
|
if (!features.announcements) return null;
|
||||||
|
|
||||||
dispatch(fetchAnnouncementsRequest());
|
dispatch(fetchAnnouncementsRequest());
|
||||||
|
|
||||||
return api(getState).get('/api/v1/announcements').then(response => {
|
return api(getState).get('/api/v1/announcements').then(response => {
|
||||||
|
|
|
@ -2,6 +2,7 @@ import React from 'react';
|
||||||
import { FormattedDate } from 'react-intl';
|
import { FormattedDate } from 'react-intl';
|
||||||
|
|
||||||
import { Stack, Text } from 'soapbox/components/ui';
|
import { Stack, Text } from 'soapbox/components/ui';
|
||||||
|
import { useFeatures } from 'soapbox/hooks';
|
||||||
|
|
||||||
import AnnouncementContent from './announcement-content';
|
import AnnouncementContent from './announcement-content';
|
||||||
import ReactionsBar from './reactions-bar';
|
import ReactionsBar from './reactions-bar';
|
||||||
|
@ -17,6 +18,8 @@ interface IAnnouncement {
|
||||||
}
|
}
|
||||||
|
|
||||||
const Announcement: React.FC<IAnnouncement> = ({ announcement, addReaction, removeReaction, emojiMap }) => {
|
const Announcement: React.FC<IAnnouncement> = ({ announcement, addReaction, removeReaction, emojiMap }) => {
|
||||||
|
const features = useFeatures();
|
||||||
|
|
||||||
const startsAt = announcement.starts_at && new Date(announcement.starts_at);
|
const startsAt = announcement.starts_at && new Date(announcement.starts_at);
|
||||||
const endsAt = announcement.ends_at && new Date(announcement.ends_at);
|
const endsAt = announcement.ends_at && new Date(announcement.ends_at);
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
|
@ -26,35 +29,35 @@ const Announcement: React.FC<IAnnouncement> = ({ announcement, addReaction, remo
|
||||||
const skipTime = announcement.all_day;
|
const skipTime = announcement.all_day;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<Stack className='w-full' space={2}>
|
||||||
<Stack space={2}>
|
{hasTimeRange && (
|
||||||
{hasTimeRange && (
|
<Text theme='muted'>
|
||||||
<Text theme='muted'>
|
<FormattedDate
|
||||||
<FormattedDate
|
value={startsAt}
|
||||||
value={startsAt}
|
hour12={false}
|
||||||
hour12={false}
|
year={(skipYear || startsAt.getFullYear() === now.getFullYear()) ? undefined : 'numeric'}
|
||||||
year={(skipYear || startsAt.getFullYear() === now.getFullYear()) ? undefined : 'numeric'}
|
month='short'
|
||||||
month='short'
|
day='2-digit'
|
||||||
day='2-digit'
|
hour={skipTime ? undefined : '2-digit'} minute={skipTime ? undefined : '2-digit'}
|
||||||
hour={skipTime ? undefined : '2-digit'} minute={skipTime ? undefined : '2-digit'}
|
/>
|
||||||
/>
|
{' '}
|
||||||
{' '}
|
-
|
||||||
-
|
{' '}
|
||||||
{' '}
|
<FormattedDate
|
||||||
<FormattedDate
|
value={endsAt}
|
||||||
value={endsAt}
|
hour12={false}
|
||||||
hour12={false}
|
year={(skipYear || endsAt.getFullYear() === now.getFullYear()) ? undefined : 'numeric'}
|
||||||
year={(skipYear || endsAt.getFullYear() === now.getFullYear()) ? undefined : 'numeric'}
|
month={skipEndDate ? undefined : 'short'}
|
||||||
month={skipEndDate ? undefined : 'short'}
|
day={skipEndDate ? undefined : '2-digit'}
|
||||||
day={skipEndDate ? undefined : '2-digit'}
|
hour={skipTime ? undefined : '2-digit'}
|
||||||
hour={skipTime ? undefined : '2-digit'}
|
minute={skipTime ? undefined : '2-digit'}
|
||||||
minute={skipTime ? undefined : '2-digit'}
|
/>
|
||||||
/>
|
</Text>
|
||||||
</Text>
|
)}
|
||||||
)}
|
|
||||||
|
|
||||||
<AnnouncementContent announcement={announcement} />
|
<AnnouncementContent announcement={announcement} />
|
||||||
|
|
||||||
|
{features.announcementsReactions && (
|
||||||
<ReactionsBar
|
<ReactionsBar
|
||||||
reactions={announcement.reactions}
|
reactions={announcement.reactions}
|
||||||
announcementId={announcement.id}
|
announcementId={announcement.id}
|
||||||
|
@ -62,8 +65,8 @@ const Announcement: React.FC<IAnnouncement> = ({ announcement, addReaction, remo
|
||||||
removeReaction={removeReaction}
|
removeReaction={removeReaction}
|
||||||
emojiMap={emojiMap}
|
emojiMap={emojiMap}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
)}
|
||||||
</div>
|
</Stack>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ const AnnouncementsPanel = () => {
|
||||||
/>
|
/>
|
||||||
)).reverse()}
|
)).reverse()}
|
||||||
</ReactSwipeableViews>
|
</ReactSwipeableViews>
|
||||||
{announcements.size > 2 && (
|
{announcements.size > 1 && (
|
||||||
<HStack space={2} alignItems='center' justifyContent='center' className='relative'>
|
<HStack space={2} alignItems='center' justifyContent='center' className='relative'>
|
||||||
{announcements.map((_, i) => (
|
{announcements.map((_, i) => (
|
||||||
<button
|
<button
|
||||||
|
|
|
@ -142,11 +142,25 @@ const getInstanceFeatures = (instance: Instance) => {
|
||||||
*/
|
*/
|
||||||
accountWebsite: v.software === TRUTHSOCIAL,
|
accountWebsite: v.software === TRUTHSOCIAL,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Can display announcements set by admins.
|
||||||
|
* @see GET /api/v1/announcements
|
||||||
|
* @see POST /api/v1/announcements/:id/dismiss
|
||||||
|
* @see {@link https://docs.joinmastodon.org/methods/announcements/}
|
||||||
|
*/
|
||||||
announcements: any([
|
announcements: any([
|
||||||
v.software === MASTODON && gte(v.compatVersion, '3.1.0'),
|
v.software === MASTODON && gte(v.compatVersion, '3.1.0'),
|
||||||
v.software === PLEROMA && gte(v.version, '2.2.49'),
|
v.software === PLEROMA && gte(v.version, '2.2.49'),
|
||||||
]),
|
]),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Can emoji react to announcements set by admins.
|
||||||
|
* @see PUT /api/v1/announcements/:id/reactions/:name
|
||||||
|
* @see DELETE /api/v1/announcements/:id/reactions/:name
|
||||||
|
* @see {@link https://docs.joinmastodon.org/methods/announcements/}
|
||||||
|
*/
|
||||||
|
announcementsReactions: v.software === MASTODON && gte(v.compatVersion, '3.1.0'),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set your birthday and view upcoming birthdays.
|
* Set your birthday and view upcoming birthdays.
|
||||||
* @see GET /api/v1/pleroma/birthdays
|
* @see GET /api/v1/pleroma/birthdays
|
||||||
|
|
Loading…
Reference in a new issue