Merge branch 'status-fixes' into 'develop'

Status fixes

Closes #1068

See merge request soapbox-pub/soapbox-fe!1734
This commit is contained in:
Alex Gleason 2022-08-14 13:18:31 +00:00
commit bc25e9d0f4
4 changed files with 22 additions and 31 deletions

View file

@ -47,6 +47,7 @@ export interface IStatus {
featured?: boolean,
hideActionBar?: boolean,
hoverable?: boolean,
withDismiss?: boolean,
}
const Status: React.FC<IStatus> = (props) => {
@ -63,6 +64,7 @@ const Status: React.FC<IStatus> = (props) => {
unread,
group,
hideActionBar,
withDismiss,
} = props;
const intl = useIntl();
const history = useHistory();
@ -179,7 +181,7 @@ const Status: React.FC<IStatus> = (props) => {
};
if (!status) return null;
let prepend, rebloggedByText, reblogElement, reblogElementMobile;
let rebloggedByText, reblogElement, reblogElementMobile;
if (hidden) {
return (
@ -205,20 +207,6 @@ const Status: React.FC<IStatus> = (props) => {
);
}
if (featured) {
prepend = (
<div className='pt-4 px-4'>
<HStack alignItems='center' space={1}>
<Icon src={require('@tabler/icons/pinned.svg')} className='text-gray-600 dark:text-gray-400' />
<Text size='sm' theme='muted' weight='medium'>
<FormattedMessage id='status.pinned' defaultMessage='Pinned post' />
</Text>
</HStack>
</div>
);
}
if (status.reblog && typeof status.reblog === 'object') {
const displayNameHtml = { __html: String(status.getIn(['account', 'display_name_html'])) };
@ -316,7 +304,17 @@ const Status: React.FC<IStatus> = (props) => {
onClick={() => history.push(statusUrl)}
role='link'
>
{prepend}
{featured && (
<div className='pt-4 px-4'>
<HStack alignItems='center' space={1}>
<Icon src={require('@tabler/icons/pinned.svg')} className='text-gray-600 dark:text-gray-400' />
<Text size='sm' theme='muted' weight='medium'>
<FormattedMessage id='status.pinned' defaultMessage='Pinned post' />
</Text>
</HStack>
</div>
)}
<div
className={classNames('status__wrapper', `status-${actualStatus.visibility}`, {
@ -374,7 +372,7 @@ const Status: React.FC<IStatus> = (props) => {
{!hideActionBar && (
<div className='pt-4'>
<StatusActionBar status={actualStatus} />
<StatusActionBar status={actualStatus} withDismiss={withDismiss} />
</div>
)}
</div>

View file

@ -122,7 +122,6 @@ const StatusList: React.FC<IStatusList> = ({
const renderStatus = (statusId: string) => {
return (
// @ts-ignore
<StatusContainer
key={statusId}
id={statusId}
@ -157,7 +156,6 @@ const StatusList: React.FC<IStatusList> = ({
if (!featuredStatusIds) return [];
return featuredStatusIds.toArray().map(statusId => (
// @ts-ignore
<StatusContainer
key={`f-${statusId}`}
id={statusId}

View file

@ -4,15 +4,13 @@ import Status, { IStatus } from 'soapbox/components/status';
import { useAppSelector } from 'soapbox/hooks';
import { makeGetStatus } from 'soapbox/selectors';
interface IStatusContainer extends Omit<IStatus, 'id'> {
interface IStatusContainer extends Omit<IStatus, 'status'> {
id: string,
/** @deprecated Unused. */
contextType?: any,
/** @deprecated Unused. */
otherAccounts?: any,
/** @deprecated Unused. */
withDismiss?: any,
/** @deprecated Unused. */
getScrollPosition?: any,
/** @deprecated Unused. */
updateScrollBottom?: any,
@ -24,11 +22,12 @@ const getStatus = makeGetStatus();
* Legacy Status wrapper accepting a status ID instead of the full entity.
* @deprecated Use the Status component directly.
*/
const StatusContainer: React.FC<IStatusContainer> = ({ id, onMoveUp, onMoveDown }) => {
const StatusContainer: React.FC<IStatusContainer> = (props) => {
const { id, ...rest } = props;
const status = useAppSelector(state => getStatus(state, { id }));
if (status) {
return <Status status={status} onMoveUp={onMoveUp} onMoveDown={onMoveDown} />;
return <Status status={status} {...rest} />;
} else {
return null;
}

View file

@ -18,7 +18,7 @@ import { makeGetNotification } from 'soapbox/selectors';
import { NotificationType, validType } from 'soapbox/utils/notification';
import type { ScrollPosition } from 'soapbox/components/status';
import type { Account, Status, Notification as NotificationEntity } from 'soapbox/types/entities';
import type { Account, Status as StatusEntity, Notification as NotificationEntity } from 'soapbox/types/entities';
const getNotification = makeGetNotification();
@ -143,7 +143,7 @@ interface INotificaton {
notification: NotificationEntity,
onMoveUp?: (notificationId: string) => void,
onMoveDown?: (notificationId: string) => void,
onReblog?: (status: Status, e?: KeyboardEvent) => void,
onReblog?: (status: StatusEntity, e?: KeyboardEvent) => void,
getScrollPosition?: () => ScrollPosition | undefined,
updateScrollBottom?: (bottom: number) => void,
}
@ -216,7 +216,7 @@ const Notification: React.FC<INotificaton> = (props) => {
if (e?.shiftKey || !boostModal) {
dispatch(reblog(status));
} else {
dispatch(openModal('BOOST', { status, onReblog: (status: Status) => {
dispatch(openModal('BOOST', { status, onReblog: (status: StatusEntity) => {
dispatch(reblog(status));
} }));
}
@ -303,16 +303,12 @@ const Notification: React.FC<INotificaton> = (props) => {
case 'update':
case 'pleroma:emoji_reaction':
return status && typeof status === 'object' ? (
// @ts-ignore
<StatusContainer
id={status.id}
withDismiss
hidden={hidden}
onMoveDown={handleMoveDown}
onMoveUp={handleMoveUp}
contextType='notifications'
getScrollPosition={props.getScrollPosition}
updateScrollBottom={props.updateScrollBottom}
/>
) : null;
default: