import clsx from 'clsx'; import { List as ImmutableList, Map as ImmutableMap } from 'immutable'; import React, { useState } from 'react'; import { FormattedMessage } from 'react-intl'; import ReactSwipeableViews from 'react-swipeable-views'; import { createSelector } from 'reselect'; import { addReaction as addReactionAction, removeReaction as removeReactionAction } from 'soapbox/actions/announcements'; import { Card, HStack, Widget } from 'soapbox/components/ui'; import { useAppDispatch, useAppSelector } from 'soapbox/hooks'; import Announcement from './announcement'; import type { RootState } from 'soapbox/store'; const customEmojiMap = createSelector([(state: RootState) => state.custom_emojis], items => (items as ImmutableList>).reduce((map, emoji) => map.set(emoji.get('shortcode')!, emoji), ImmutableMap>())); const AnnouncementsPanel = () => { const dispatch = useAppDispatch(); const emojiMap = useAppSelector(state => customEmojiMap(state)); const [index, setIndex] = useState(0); const announcements = useAppSelector((state) => state.announcements.items); const addReaction = (id: string, name: string) => dispatch(addReactionAction(id, name)); const removeReaction = (id: string, name: string) => dispatch(removeReactionAction(id, name)); if (announcements.size === 0) return null; const handleChangeIndex = (index: number) => { setIndex(index % announcements.size); }; return ( }> {announcements.map((announcement) => ( )).reverse()} {announcements.size > 1 && ( {announcements.map((_, i) => (