From 6465423ccb38f828f33ba96c34cf3473fc05c05d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Sun, 27 Nov 2022 23:29:45 +0100 Subject: [PATCH] Cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- app/soapbox/components/event-preview.tsx | 42 ++++++++++++------- app/soapbox/components/status-media.tsx | 13 ++---- .../event/components/event-action-button.tsx | 8 ++-- .../event/components/event-header.tsx | 6 +-- .../features/event/event-information.tsx | 28 +++++++------ .../events/components/event-carousel.tsx | 4 +- app/soapbox/features/events/index.tsx | 2 +- .../components/placeholder-event-preview.tsx | 4 +- app/soapbox/normalizers/status.ts | 26 ++++++++++-- app/soapbox/reducers/compose_event.ts | 4 +- 10 files changed, 81 insertions(+), 56 deletions(-) diff --git a/app/soapbox/components/event-preview.tsx b/app/soapbox/components/event-preview.tsx index 74dd69021..2ee688e05 100644 --- a/app/soapbox/components/event-preview.tsx +++ b/app/soapbox/components/event-preview.tsx @@ -19,12 +19,13 @@ const messages = defineMessages({ }); interface IEventPreview { - status: StatusEntity, - className?: string, - hideAction?: boolean; + status: StatusEntity + className?: string + hideAction?: boolean + floatingAction?: boolean } -const EventPreview: React.FC = ({ status, className, hideAction }) => { +const EventPreview: React.FC = ({ status, className, hideAction, floatingAction = true }) => { const intl = useIntl(); const me = useAppSelector((state) => state.me); @@ -32,26 +33,37 @@ const EventPreview: React.FC = ({ status, className, hideAction } const account = status.account as AccountEntity; const event = status.event!; - const banner = status.media_attachments?.find(({ description }) => description === 'Banner'); + const banner = event.banner; + + const action = !hideAction && (account.id === me ? ( + + ) : ( + + )); return (
- {!hideAction && (account.id === me ? ( - - ) : )} + {floatingAction && action}
{banner && {intl.formatMessage(messages.bannerHeader)}}
- {event.name} + + {event.name} + + {!floatingAction && action} +
diff --git a/app/soapbox/components/status-media.tsx b/app/soapbox/components/status-media.tsx index a09ce171a..d1ca296e9 100644 --- a/app/soapbox/components/status-media.tsx +++ b/app/soapbox/components/status-media.tsx @@ -24,8 +24,6 @@ interface IStatusMedia { showMedia?: boolean, /** Callback when visibility is toggled (eg clicked through NSFW). */ onToggleVisibility?: () => void, - /** Whether or not to hide image describer as 'Banner' */ - excludeBanner?: boolean, } /** Render media attachments for a status. */ @@ -35,7 +33,6 @@ const StatusMedia: React.FC = ({ onClick, showMedia = true, onToggleVisibility = () => { }, - excludeBanner = false, }) => { const dispatch = useAppDispatch(); const settings = useSettings(); @@ -43,10 +40,8 @@ const StatusMedia: React.FC = ({ const [mediaWrapperWidth, setMediaWrapperWidth] = useState(undefined); - const mediaAttachments = excludeBanner ? status.media_attachments.filter(({ description, pleroma }) => description !== 'Banner' && pleroma.get('mime_type') !== 'text/html') : status.media_attachments; - - const size = mediaAttachments.size; - const firstAttachment = mediaAttachments.first(); + const size = status.media_attachments.size; + const firstAttachment = status.media_attachments.first(); let media: JSX.Element | null = null; @@ -76,7 +71,7 @@ const StatusMedia: React.FC = ({ if (muted) { media = ( @@ -147,7 +142,7 @@ const StatusMedia: React.FC = ({ {(Component: any) => ( = ({ status }) => { +const EventActionButton: React.FC = ({ status, theme = 'secondary' }) => { const intl = useIntl(); const dispatch = useAppDispatch(); @@ -86,7 +88,7 @@ const EventActionButton: React.FC = ({ status }) => { return (