diff --git a/src/js/components/feed/Feed.tsx b/src/js/components/feed/Feed.tsx index ca9e897a..12b576a3 100644 --- a/src/js/components/feed/Feed.tsx +++ b/src/js/components/feed/Feed.tsx @@ -15,6 +15,22 @@ import { useLocalState } from '@/LocalState'; const PAGE_SIZE = 6; +function mapEventsToMedia(events: any[]): ImageOrVideo[] { + return events.flatMap((event) => { + const imageMatches = (event.content.match(Image.regex) || []).map((url: string) => ({ + type: 'image', + url, + created_at: event.created_at, + })); + const videoMatches = (event.content.match(Video.regex) || []).map((url: string) => ({ + type: 'video', + url, + created_at: event.created_at, + })); + return [...imageMatches, ...videoMatches]; + }); +} + const Feed = (props: FeedProps) => { const { showDisplayAs, filterOptions, emptyMessage } = props; if (!filterOptions || filterOptions.length === 0) { @@ -22,8 +38,8 @@ const Feed = (props: FeedProps) => { } const [filterOption, setFilterOption] = useState(filterOptions[0]); const [displayCount, setDisplayCount] = useState(PAGE_SIZE); - const [displayAs, setDisplayAs] = useState('feed' as DisplayAs); - const [modalItemIndex, setModalImageIndex] = useState(null as number | null); + const [displayAs, setDisplayAs] = useState('feed'); + const [modalItemIndex, setModalImageIndex] = useState(null); const lastElementRef = useRef(null); const [mutedUsers] = useLocalState('muted', {}); @@ -58,22 +74,6 @@ const Feed = (props: FeedProps) => { } } - function mapEventsToMedia(events) { - return events.flatMap((event) => { - const imageMatches = (event.content.match(Image.regex) || []).map((url: string) => ({ - type: 'image', - url, - created_at: event.created_at, - })); - const videoMatches = (event.content.match(Video.regex) || []).map((url: string) => ({ - type: 'video', - url, - created_at: event.created_at, - })); - return [...imageMatches, ...videoMatches]; - }); - } - const imagesAndVideos = useMemo(() => { if (displayAs === 'feed') { return []; @@ -93,7 +93,7 @@ const Feed = (props: FeedProps) => { }} /> - + { setDisplayCount(PAGE_SIZE); diff --git a/src/js/views/feeds/Notifications.tsx b/src/js/views/feeds/Notifications.tsx index c6890f58..52bda973 100644 --- a/src/js/views/feeds/Notifications.tsx +++ b/src/js/views/feeds/Notifications.tsx @@ -36,6 +36,7 @@ export default class Notifications extends View { return (