From ed4b86c5fa4da12c8f2e8f633895879f93e28c12 Mon Sep 17 00:00:00 2001 From: Chewbacca Date: Fri, 21 Apr 2023 09:36:37 -0400 Subject: [PATCH] Add page to show statuses per tag --- app/soapbox/actions/timelines.ts | 4 ++ .../features/group/group-tag-timeline.tsx | 54 ++++++++++++++++--- app/soapbox/features/ui/index.tsx | 2 +- 3 files changed, 51 insertions(+), 9 deletions(-) diff --git a/app/soapbox/actions/timelines.ts b/app/soapbox/actions/timelines.ts index cafaa6aa5..902b99f70 100644 --- a/app/soapbox/actions/timelines.ts +++ b/app/soapbox/actions/timelines.ts @@ -248,6 +248,9 @@ const expandListTimeline = (id: string, { maxId }: Record = {}, don const expandGroupTimeline = (id: string, { maxId }: Record = {}, done = noOp) => expandTimeline(`group:${id}`, `/api/v1/timelines/group/${id}`, { max_id: maxId }, done); +const expandGroupTimelineFromTag = (id: string, tagName: string, { maxId }: Record = {}, done = noOp) => + expandTimeline(`group:tags:${id}:${tagName}`, `/api/v1/timelines/group/${id}/tags/${tagName}`, { max_id: maxId }, done); + const expandGroupMediaTimeline = (id: string | number, { maxId }: Record = {}) => expandTimeline(`group:${id}:media`, `/api/v1/timelines/group/${id}`, { max_id: maxId, only_media: true, limit: 40, with_muted: true }); @@ -350,6 +353,7 @@ export { expandAccountMediaTimeline, expandListTimeline, expandGroupTimeline, + expandGroupTimelineFromTag, expandGroupMediaTimeline, expandHashtagTimeline, expandTimelineRequest, diff --git a/app/soapbox/features/group/group-tag-timeline.tsx b/app/soapbox/features/group/group-tag-timeline.tsx index 2663c59cf..f2ddee382 100644 --- a/app/soapbox/features/group/group-tag-timeline.tsx +++ b/app/soapbox/features/group/group-tag-timeline.tsx @@ -1,28 +1,66 @@ -import React from 'react'; +import React, { useEffect } from 'react'; +import { FormattedMessage } from 'react-intl'; -import { Column } from 'soapbox/components/ui'; +import { expandGroupTimelineFromTag } from 'soapbox/actions/timelines'; +import { Column, Icon, Stack, Text } from 'soapbox/components/ui'; +import { useAppDispatch } from 'soapbox/hooks'; import { useGroup, useGroupTag } from 'soapbox/hooks/api'; -type RouteParams = { id: string, groupId: string }; +import Timeline from '../ui/components/timeline'; + +type RouteParams = { tagId: string, groupId: string }; interface IGroupTimeline { params: RouteParams } const GroupTagTimeline: React.FC = (props) => { + const dispatch = useAppDispatch(); const groupId = props.params.groupId; - const tagId = props.params.id; + const tagId = props.params.tagId; const { group } = useGroup(groupId); - const { tag } = useGroupTag(tagId); + const { tag, isLoading } = useGroupTag(tagId); - if (!group) { + const handleLoadMore = (maxId: string) => { + dispatch(expandGroupTimelineFromTag(groupId, tag?.name as string, { maxId })); + }; + + useEffect(() => { + if (tag?.name) { + dispatch(expandGroupTimelineFromTag(groupId, tag?.name)); + } + }, [groupId, tag]); + + + if (isLoading || !tag || !group) { return null; } return ( - - {/* TODO */} + + +
+ +
+ + + + + + } + />
); }; diff --git a/app/soapbox/features/ui/index.tsx b/app/soapbox/features/ui/index.tsx index 565666465..b41cd6746 100644 --- a/app/soapbox/features/ui/index.tsx +++ b/app/soapbox/features/ui/index.tsx @@ -327,7 +327,7 @@ const SwitchingColumnsArea: React.FC = ({ children }) => {features.groups && } {features.groupsTags && } - {features.groupsTags && } + {features.groupsTags && } {features.groups && } {features.groups && } {features.groups && }