Merge branch 'status-visibility-fixes' into 'develop'
Status visibility fixes Closes #1156 and #1154 See merge request soapbox-pub/soapbox!1860
This commit is contained in:
commit
63bdf6ad38
8 changed files with 81 additions and 120 deletions
|
@ -1,15 +1,18 @@
|
||||||
import classNames from 'clsx';
|
import classNames from 'clsx';
|
||||||
import React, { useState } from 'react';
|
import React, { MouseEventHandler, useState } from 'react';
|
||||||
import { defineMessages, useIntl, FormattedMessage, FormattedList } from 'react-intl';
|
import { defineMessages, useIntl } from 'react-intl';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
|
|
||||||
import StatusMedia from 'soapbox/components/status-media';
|
import StatusMedia from 'soapbox/components/status-media';
|
||||||
import { Stack, Text } from 'soapbox/components/ui';
|
import { Stack } from 'soapbox/components/ui';
|
||||||
import AccountContainer from 'soapbox/containers/account_container';
|
import AccountContainer from 'soapbox/containers/account_container';
|
||||||
import { useSettings } from 'soapbox/hooks';
|
import { useSettings } from 'soapbox/hooks';
|
||||||
import { defaultMediaVisibility } from 'soapbox/utils/status';
|
import { defaultMediaVisibility } from 'soapbox/utils/status';
|
||||||
|
|
||||||
import OutlineBox from './outline-box';
|
import OutlineBox from './outline-box';
|
||||||
|
import StatusReplyMentions from './status-reply-mentions';
|
||||||
|
import StatusContent from './status_content';
|
||||||
|
import SensitiveContentOverlay from './statuses/sensitive-content-overlay';
|
||||||
|
|
||||||
import type { Account as AccountEntity, Status as StatusEntity } from 'soapbox/types/entities';
|
import type { Account as AccountEntity, Status as StatusEntity } from 'soapbox/types/entities';
|
||||||
|
|
||||||
|
@ -36,7 +39,7 @@ const QuotedStatus: React.FC<IQuotedStatus> = ({ status, onCancel, compose }) =>
|
||||||
|
|
||||||
const [showMedia, setShowMedia] = useState<boolean>(defaultMediaVisibility(status, displayMedia));
|
const [showMedia, setShowMedia] = useState<boolean>(defaultMediaVisibility(status, displayMedia));
|
||||||
|
|
||||||
const handleExpandClick = (e: React.MouseEvent<HTMLDivElement>) => {
|
const handleExpandClick: MouseEventHandler<HTMLDivElement> = (e) => {
|
||||||
if (!status) return;
|
if (!status) return;
|
||||||
const account = status.account as AccountEntity;
|
const account = status.account as AccountEntity;
|
||||||
|
|
||||||
|
@ -57,57 +60,6 @@ const QuotedStatus: React.FC<IQuotedStatus> = ({ status, onCancel, compose }) =>
|
||||||
setShowMedia(!showMedia);
|
setShowMedia(!showMedia);
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderReplyMentions = () => {
|
|
||||||
if (!status?.in_reply_to_id) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const account = status.account as AccountEntity;
|
|
||||||
const to = status.mentions || [];
|
|
||||||
|
|
||||||
if (to.size === 0) {
|
|
||||||
if (status.in_reply_to_account_id === account.id) {
|
|
||||||
return (
|
|
||||||
<div className='reply-mentions'>
|
|
||||||
<FormattedMessage
|
|
||||||
id='reply_mentions.reply'
|
|
||||||
defaultMessage='Replying to {accounts}'
|
|
||||||
values={{
|
|
||||||
accounts: `@${account.username}`,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return (
|
|
||||||
<div className='reply-mentions'>
|
|
||||||
<FormattedMessage id='reply_mentions.reply_empty' defaultMessage='Replying to post' />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const accounts = to.slice(0, 2).map(account => <>@{account.username}</>).toArray();
|
|
||||||
|
|
||||||
if (to.size > 2) {
|
|
||||||
accounts.push(
|
|
||||||
<FormattedMessage id='reply_mentions.more' defaultMessage='{count} more' values={{ count: to.size - 2 }} />,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className='reply-mentions'>
|
|
||||||
<FormattedMessage
|
|
||||||
id='reply_mentions.reply'
|
|
||||||
defaultMessage='Replying to {accounts}'
|
|
||||||
values={{
|
|
||||||
accounts: <FormattedList type='conjunction' value={accounts} />,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!status) {
|
if (!status) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -127,7 +79,7 @@ const QuotedStatus: React.FC<IQuotedStatus> = ({ status, onCancel, compose }) =>
|
||||||
return (
|
return (
|
||||||
<OutlineBox
|
<OutlineBox
|
||||||
data-testid='quoted-status'
|
data-testid='quoted-status'
|
||||||
className={classNames('mt-3 cursor-pointer', {
|
className={classNames('cursor-pointer', {
|
||||||
'hover:bg-gray-100 dark:hover:bg-gray-800': !compose,
|
'hover:bg-gray-100 dark:hover:bg-gray-800': !compose,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
|
@ -144,20 +96,36 @@ const QuotedStatus: React.FC<IQuotedStatus> = ({ status, onCancel, compose }) =>
|
||||||
withLinkToProfile={!compose}
|
withLinkToProfile={!compose}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{renderReplyMentions()}
|
<StatusReplyMentions status={status} hoverable={false} />
|
||||||
|
|
||||||
<Text
|
<Stack className={classNames('relative', {
|
||||||
className='break-words status__content status__content--quote'
|
'min-h-[220px]': status.hidden,
|
||||||
size='sm'
|
})}
|
||||||
dangerouslySetInnerHTML={{ __html: status.contentHtml }}
|
>
|
||||||
/>
|
{(status.hidden) && (
|
||||||
|
<SensitiveContentOverlay
|
||||||
|
status={status}
|
||||||
|
visible={showMedia}
|
||||||
|
onToggleVisibility={handleToggleMediaVisibility}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
<StatusMedia
|
<Stack space={4}>
|
||||||
status={status}
|
<StatusContent
|
||||||
muted={compose}
|
status={status}
|
||||||
showMedia={showMedia}
|
collapsable
|
||||||
onToggleVisibility={handleToggleMediaVisibility}
|
/>
|
||||||
/>
|
|
||||||
|
{(status.media_attachments.size > 0) && (
|
||||||
|
<StatusMedia
|
||||||
|
status={status}
|
||||||
|
muted={compose}
|
||||||
|
showMedia={showMedia}
|
||||||
|
onToggleVisibility={handleToggleMediaVisibility}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
</OutlineBox>
|
</OutlineBox>
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
.status-content p {
|
.status-content p {
|
||||||
@apply mb-5 whitespace-pre-wrap;
|
@apply mb-4 whitespace-pre-wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-content p:last-child {
|
.status-content p:last-child {
|
||||||
@apply mb-0.5;
|
@apply mb-0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-content a {
|
.status-content a {
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
.status-content ul,
|
.status-content ul,
|
||||||
.status-content ol {
|
.status-content ol {
|
||||||
@apply pl-10 mb-5;
|
@apply pl-10 mb-4;
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-content ul {
|
.status-content ul {
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-content blockquote {
|
.status-content blockquote {
|
||||||
@apply py-1 pl-4 mb-5 border-l-4 border-solid border-gray-400 text-gray-500 dark:text-gray-400;
|
@apply py-1 pl-4 mb-4 border-l-4 border-solid border-gray-400 text-gray-500 dark:text-gray-400;
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-content code {
|
.status-content code {
|
||||||
|
@ -51,7 +51,7 @@
|
||||||
|
|
||||||
/* Code block */
|
/* Code block */
|
||||||
.status-content pre {
|
.status-content pre {
|
||||||
@apply py-2 px-3 mb-5 leading-6 overflow-x-auto rounded-md break-all;
|
@apply py-2 px-3 mb-4 leading-6 overflow-x-auto rounded-md break-all;
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-content pre:last-child {
|
.status-content pre:last-child {
|
||||||
|
@ -60,7 +60,7 @@
|
||||||
|
|
||||||
/* Markdown images */
|
/* Markdown images */
|
||||||
.status-content img:not(.emojione):not([width][height]) {
|
.status-content img:not(.emojione):not([width][height]) {
|
||||||
@apply w-full h-72 object-contain rounded-lg overflow-hidden my-5 block;
|
@apply w-full h-72 object-contain rounded-lg overflow-hidden my-4 block;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* User setting to underline links */
|
/* User setting to underline links */
|
||||||
|
|
|
@ -65,7 +65,6 @@ const Status: React.FC<IStatus> = (props) => {
|
||||||
hidden,
|
hidden,
|
||||||
featured,
|
featured,
|
||||||
unread,
|
unread,
|
||||||
group,
|
|
||||||
hideActionBar,
|
hideActionBar,
|
||||||
variant = 'rounded',
|
variant = 'rounded',
|
||||||
withDismiss,
|
withDismiss,
|
||||||
|
@ -296,8 +295,8 @@ const Status: React.FC<IStatus> = (props) => {
|
||||||
|
|
||||||
const accountAction = props.accountAction || reblogElement;
|
const accountAction = props.accountAction || reblogElement;
|
||||||
|
|
||||||
const inReview = status.visibility === 'self';
|
const inReview = actualStatus.visibility === 'self';
|
||||||
const isSensitive = status.hidden;
|
const isSensitive = actualStatus.hidden;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<HotKeys handlers={handlers} data-testid='status'>
|
<HotKeys handlers={handlers} data-testid='status'>
|
||||||
|
@ -349,6 +348,8 @@ const Status: React.FC<IStatus> = (props) => {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className='status__content-wrapper'>
|
<div className='status__content-wrapper'>
|
||||||
|
<StatusReplyMentions status={actualStatus} hoverable={hoverable} />
|
||||||
|
|
||||||
<Stack
|
<Stack
|
||||||
className={
|
className={
|
||||||
classNames('relative', {
|
classNames('relative', {
|
||||||
|
@ -356,40 +357,35 @@ const Status: React.FC<IStatus> = (props) => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{(inReview || isSensitive) ? (
|
{(inReview || isSensitive) && (
|
||||||
<SensitiveContentOverlay
|
<SensitiveContentOverlay
|
||||||
status={status}
|
status={status}
|
||||||
visible={showMedia}
|
visible={showMedia}
|
||||||
onToggleVisibility={handleToggleMediaVisibility}
|
onToggleVisibility={handleToggleMediaVisibility}
|
||||||
/>
|
/>
|
||||||
) : null}
|
|
||||||
|
|
||||||
{!group && actualStatus.group && (
|
|
||||||
<div className='status__meta'>
|
|
||||||
Posted in <NavLink to={`/groups/${actualStatus.getIn(['group', 'id'])}`}>{String(actualStatus.getIn(['group', 'title']))}</NavLink>
|
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<StatusReplyMentions
|
<Stack space={4}>
|
||||||
status={actualStatus}
|
<StatusContent
|
||||||
hoverable={hoverable}
|
status={actualStatus}
|
||||||
/>
|
onClick={handleClick}
|
||||||
|
collapsable
|
||||||
|
/>
|
||||||
|
|
||||||
<StatusContent
|
{(quote || actualStatus.media_attachments.size > 0) && (
|
||||||
status={actualStatus}
|
<Stack space={4}>
|
||||||
onClick={handleClick}
|
<StatusMedia
|
||||||
collapsable
|
status={actualStatus}
|
||||||
/>
|
muted={muted}
|
||||||
|
onClick={handleClick}
|
||||||
|
showMedia={showMedia}
|
||||||
|
onToggleVisibility={handleToggleMediaVisibility}
|
||||||
|
/>
|
||||||
|
|
||||||
<StatusMedia
|
{quote}
|
||||||
status={actualStatus}
|
</Stack>
|
||||||
muted={muted}
|
)}
|
||||||
onClick={handleClick}
|
</Stack>
|
||||||
showMedia={showMedia}
|
|
||||||
onToggleVisibility={handleToggleMediaVisibility}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{quote}
|
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
{!hideActionBar && (
|
{!hideActionBar && (
|
||||||
|
|
|
@ -29,7 +29,6 @@ interface IDetailedStatus {
|
||||||
|
|
||||||
const DetailedStatus: React.FC<IDetailedStatus> = ({
|
const DetailedStatus: React.FC<IDetailedStatus> = ({
|
||||||
status,
|
status,
|
||||||
onToggleHidden,
|
|
||||||
onOpenCompareHistoryModal,
|
onOpenCompareHistoryModal,
|
||||||
onToggleMediaVisibility,
|
onToggleMediaVisibility,
|
||||||
showMedia,
|
showMedia,
|
||||||
|
@ -93,23 +92,29 @@ const DetailedStatus: React.FC<IDetailedStatus> = ({
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{(isUnderReview || isSensitive) ? (
|
{(isUnderReview || isSensitive) && (
|
||||||
<SensitiveContentOverlay
|
<SensitiveContentOverlay
|
||||||
status={status}
|
status={status}
|
||||||
visible={showMedia}
|
visible={showMedia}
|
||||||
onToggleVisibility={onToggleMediaVisibility}
|
onToggleVisibility={onToggleMediaVisibility}
|
||||||
/>
|
/>
|
||||||
) : null}
|
)}
|
||||||
|
|
||||||
<StatusContent status={actualStatus} />
|
<Stack space={4}>
|
||||||
|
<StatusContent status={actualStatus} />
|
||||||
|
|
||||||
<StatusMedia
|
{(quote || actualStatus.media_attachments.size > 0) && (
|
||||||
status={actualStatus}
|
<Stack space={4}>
|
||||||
showMedia={showMedia}
|
<StatusMedia
|
||||||
onToggleVisibility={onToggleMediaVisibility}
|
status={actualStatus}
|
||||||
/>
|
showMedia={showMedia}
|
||||||
|
onToggleVisibility={onToggleMediaVisibility}
|
||||||
|
/>
|
||||||
|
|
||||||
{quote}
|
{quote}
|
||||||
|
</Stack>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
<HStack justifyContent='between' alignItems='center' className='py-2' wrap>
|
<HStack justifyContent='between' alignItems='center' className='py-2' wrap>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
.media-gallery {
|
.media-gallery {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
margin-top: 8px;
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
.detailed-status {
|
.detailed-status {
|
||||||
.reply-mentions {
|
.reply-mentions {
|
||||||
display: block;
|
display: block;
|
||||||
margin: 4px 0 0 0;
|
|
||||||
|
|
||||||
span {
|
span {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
|
@ -14,11 +14,6 @@
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
animation: fade 150ms linear;
|
animation: fade 150ms linear;
|
||||||
|
|
||||||
.video-player,
|
|
||||||
.audio-player {
|
|
||||||
margin-top: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.light {
|
&.light {
|
||||||
.display-name {
|
.display-name {
|
||||||
strong {
|
strong {
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
margin-top: 8px;
|
|
||||||
position: relative;
|
position: relative;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
|
|
Loading…
Reference in a new issue