pl-fe: add some feedback on deleted post, remove unused feature
Signed-off-by: mkljczk <git@mkljczk.pl>
This commit is contained in:
parent
8de583e1eb
commit
40376e4576
7 changed files with 35 additions and 37 deletions
|
@ -171,13 +171,7 @@ const unmuteStatus = (statusId: string) =>
|
||||||
};
|
};
|
||||||
|
|
||||||
const toggleMuteStatus = (status: Pick<Status, 'id' | 'muted'>) =>
|
const toggleMuteStatus = (status: Pick<Status, 'id' | 'muted'>) =>
|
||||||
(dispatch: AppDispatch) => {
|
status.muted ? unmuteStatus(status.id) : muteStatus(status.id);
|
||||||
if (status.muted) {
|
|
||||||
dispatch(unmuteStatus(status.id));
|
|
||||||
} else {
|
|
||||||
dispatch(muteStatus(status.id));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// let TRANSLATIONS_QUEUE: Set<string> = new Set();
|
// let TRANSLATIONS_QUEUE: Set<string> = new Set();
|
||||||
// let TRANSLATIONS_TIMEOUT: NodeJS.Timeout | null = null;
|
// let TRANSLATIONS_TIMEOUT: NodeJS.Timeout | null = null;
|
||||||
|
|
|
@ -85,7 +85,6 @@ interface IAccount {
|
||||||
/** Override other actions for specificity like mute/unmute. */
|
/** Override other actions for specificity like mute/unmute. */
|
||||||
actionType?: 'muting' | 'blocking' | 'follow_request' | 'biting';
|
actionType?: 'muting' | 'blocking' | 'follow_request' | 'biting';
|
||||||
avatarSize?: number;
|
avatarSize?: number;
|
||||||
hidden?: boolean;
|
|
||||||
hideActions?: boolean;
|
hideActions?: boolean;
|
||||||
id?: string;
|
id?: string;
|
||||||
onActionClick?: (account: AccountSchema) => void;
|
onActionClick?: (account: AccountSchema) => void;
|
||||||
|
@ -115,7 +114,6 @@ const Account = ({
|
||||||
actionTitle,
|
actionTitle,
|
||||||
actionAlignment = 'center',
|
actionAlignment = 'center',
|
||||||
avatarSize = 42,
|
avatarSize = 42,
|
||||||
hidden = false,
|
|
||||||
hideActions = false,
|
hideActions = false,
|
||||||
onActionClick,
|
onActionClick,
|
||||||
showAccountHoverCard = true,
|
showAccountHoverCard = true,
|
||||||
|
@ -181,15 +179,6 @@ const Account = ({
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hidden) {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
{account.display_name}
|
|
||||||
{account.username}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (withDate) timestamp = account.created_at;
|
if (withDate) timestamp = account.created_at;
|
||||||
|
|
||||||
const LinkEl: any = withLinkToProfile ? Link : 'div';
|
const LinkEl: any = withLinkToProfile ? Link : 'div';
|
||||||
|
|
|
@ -29,6 +29,7 @@ import StatusLanguagePicker from './status-language-picker';
|
||||||
import StatusReactionsBar from './status-reactions-bar';
|
import StatusReactionsBar from './status-reactions-bar';
|
||||||
import StatusReplyMentions from './status-reply-mentions';
|
import StatusReplyMentions from './status-reply-mentions';
|
||||||
import StatusInfo from './statuses/status-info';
|
import StatusInfo from './statuses/status-info';
|
||||||
|
import Tombstone from './tombstone';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
reblogged_by: { id: 'status.reblogged_by', defaultMessage: '{name} reposted' },
|
reblogged_by: { id: 'status.reblogged_by', defaultMessage: '{name} reposted' },
|
||||||
|
@ -40,7 +41,6 @@ interface IStatus {
|
||||||
status: SelectedStatus;
|
status: SelectedStatus;
|
||||||
onClick?: () => void;
|
onClick?: () => void;
|
||||||
muted?: boolean;
|
muted?: boolean;
|
||||||
hidden?: boolean;
|
|
||||||
unread?: boolean;
|
unread?: boolean;
|
||||||
onMoveUp?: (statusId: string, featured?: boolean) => void;
|
onMoveUp?: (statusId: string, featured?: boolean) => void;
|
||||||
onMoveDown?: (statusId: string, featured?: boolean) => void;
|
onMoveDown?: (statusId: string, featured?: boolean) => void;
|
||||||
|
@ -65,7 +65,6 @@ const Status: React.FC<IStatus> = (props) => {
|
||||||
onMoveUp,
|
onMoveUp,
|
||||||
onMoveDown,
|
onMoveDown,
|
||||||
muted,
|
muted,
|
||||||
hidden,
|
|
||||||
featured,
|
featured,
|
||||||
unread,
|
unread,
|
||||||
hideActionBar,
|
hideActionBar,
|
||||||
|
@ -95,7 +94,7 @@ const Status: React.FC<IStatus> = (props) => {
|
||||||
|
|
||||||
// Track height changes we know about to compensate scrolling.
|
// Track height changes we know about to compensate scrolling.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
didShowCard.current = Boolean(!muted && !hidden && status?.card);
|
didShowCard.current = Boolean(!muted && status?.card);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleClick = (e?: React.MouseEvent) => {
|
const handleClick = (e?: React.MouseEvent) => {
|
||||||
|
@ -299,16 +298,13 @@ const Status: React.FC<IStatus> = (props) => {
|
||||||
|
|
||||||
if (!status) return null;
|
if (!status) return null;
|
||||||
|
|
||||||
if (hidden) {
|
if (status.deleted) return (
|
||||||
return (
|
<Tombstone
|
||||||
<div ref={node}>
|
id={status.id}
|
||||||
<>
|
onMoveUp={onMoveUp}
|
||||||
{actualStatus.account.display_name || actualStatus.account.username}
|
onMoveDown={onMoveDown}
|
||||||
{actualStatus.content}
|
/>
|
||||||
</>
|
);
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (filtered && status.showFiltered !== false) {
|
if (filtered && status.showFiltered !== false) {
|
||||||
const minHandlers = muted ? undefined : {
|
const minHandlers = muted ? undefined : {
|
||||||
|
|
|
@ -181,7 +181,6 @@ const buildMessage = (
|
||||||
const avatarSize = 48;
|
const avatarSize = 48;
|
||||||
|
|
||||||
interface INotification {
|
interface INotification {
|
||||||
hidden?: boolean;
|
|
||||||
notification: NotificationGroup;
|
notification: NotificationGroup;
|
||||||
onMoveUp?: (notificationId: string) => void;
|
onMoveUp?: (notificationId: string) => void;
|
||||||
onMoveDown?: (notificationId: string) => void;
|
onMoveDown?: (notificationId: string) => void;
|
||||||
|
@ -196,7 +195,7 @@ const getNotificationStatus = (n: Pick<NotificationGroup, 'type'> & ({ status: S
|
||||||
};
|
};
|
||||||
|
|
||||||
const Notification: React.FC<INotification> = (props) => {
|
const Notification: React.FC<INotification> = (props) => {
|
||||||
const { hidden = false, onMoveUp, onMoveDown } = props;
|
const { onMoveUp, onMoveDown } = props;
|
||||||
|
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
|
@ -330,7 +329,6 @@ const Notification: React.FC<INotification> = (props) => {
|
||||||
return account && typeof account === 'object' ? (
|
return account && typeof account === 'object' ? (
|
||||||
<AccountContainer
|
<AccountContainer
|
||||||
id={account.id}
|
id={account.id}
|
||||||
hidden={hidden}
|
|
||||||
avatarSize={avatarSize}
|
avatarSize={avatarSize}
|
||||||
actionType='follow_request'
|
actionType='follow_request'
|
||||||
withRelationship
|
withRelationship
|
||||||
|
@ -340,7 +338,6 @@ const Notification: React.FC<INotification> = (props) => {
|
||||||
return account && typeof account === 'object' ? (
|
return account && typeof account === 'object' ? (
|
||||||
<AccountContainer
|
<AccountContainer
|
||||||
id={account.id}
|
id={account.id}
|
||||||
hidden={hidden}
|
|
||||||
avatarSize={avatarSize}
|
avatarSize={avatarSize}
|
||||||
actionType='biting'
|
actionType='biting'
|
||||||
withRelationship
|
withRelationship
|
||||||
|
@ -350,7 +347,6 @@ const Notification: React.FC<INotification> = (props) => {
|
||||||
return account && typeof account === 'object' && notification.target && typeof notification.target === 'object' ? (
|
return account && typeof account === 'object' && notification.target && typeof notification.target === 'object' ? (
|
||||||
<AccountContainer
|
<AccountContainer
|
||||||
id={notification.target_id}
|
id={notification.target_id}
|
||||||
hidden={hidden}
|
|
||||||
avatarSize={avatarSize}
|
avatarSize={avatarSize}
|
||||||
withRelationship
|
withRelationship
|
||||||
/>
|
/>
|
||||||
|
@ -368,7 +364,6 @@ const Notification: React.FC<INotification> = (props) => {
|
||||||
return status && typeof status === 'object' ? (
|
return status && typeof status === 'object' ? (
|
||||||
<StatusContainer
|
<StatusContainer
|
||||||
id={status.id}
|
id={status.id}
|
||||||
hidden={hidden}
|
|
||||||
onMoveDown={handleMoveDown}
|
onMoveDown={handleMoveDown}
|
||||||
onMoveUp={handleMoveUp}
|
onMoveUp={handleMoveUp}
|
||||||
avatarSize={avatarSize}
|
avatarSize={avatarSize}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
|
import Tombstone from 'pl-fe/components/tombstone';
|
||||||
import StatusContainer from 'pl-fe/containers/status-container';
|
import StatusContainer from 'pl-fe/containers/status-container';
|
||||||
import PlaceholderStatus from 'pl-fe/features/placeholder/components/placeholder-status';
|
import PlaceholderStatus from 'pl-fe/features/placeholder/components/placeholder-status';
|
||||||
import { useAppSelector } from 'pl-fe/hooks/use-app-selector';
|
import { useAppSelector } from 'pl-fe/hooks/use-app-selector';
|
||||||
|
@ -20,6 +21,20 @@ const ThreadStatus: React.FC<IThreadStatus> = (props): JSX.Element => {
|
||||||
const replyToId = useAppSelector(state => state.contexts.inReplyTos[id]);
|
const replyToId = useAppSelector(state => state.contexts.inReplyTos[id]);
|
||||||
const replyCount = useAppSelector(state => (state.contexts.replies[id] || []).length);
|
const replyCount = useAppSelector(state => (state.contexts.replies[id] || []).length);
|
||||||
const isLoaded = useAppSelector(state => Boolean(state.statuses[id]));
|
const isLoaded = useAppSelector(state => Boolean(state.statuses[id]));
|
||||||
|
const isDeleted = useAppSelector(state => Boolean(state.statuses[id]?.deleted));
|
||||||
|
|
||||||
|
if (isDeleted) {
|
||||||
|
return (
|
||||||
|
<div className='py-4 pb-8'>
|
||||||
|
<Tombstone
|
||||||
|
key={id}
|
||||||
|
id={id}
|
||||||
|
onMoveUp={props.onMoveUp}
|
||||||
|
onMoveDown={props.onMoveDown}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const renderConnector = (): JSX.Element | null => {
|
const renderConnector = (): JSX.Element | null => {
|
||||||
const isConnectedTop = replyToId && replyToId !== focusedStatusId;
|
const isConnectedTop = replyToId && replyToId !== focusedStatusId;
|
||||||
|
|
|
@ -115,6 +115,7 @@ const normalizeStatus = (status: BaseStatus & {
|
||||||
group_id: status.group?.id || null,
|
group_id: status.group?.id || null,
|
||||||
expectsCard: false,
|
expectsCard: false,
|
||||||
showFiltered: null as null | boolean,
|
showFiltered: null as null | boolean,
|
||||||
|
deleted: false,
|
||||||
...status,
|
...status,
|
||||||
quote_id: status.quote?.id || status.quote_id || null,
|
quote_id: status.quote?.id || status.quote_id || null,
|
||||||
account: normalizeAccount(status.account),
|
account: normalizeAccount(status.account),
|
||||||
|
|
|
@ -40,6 +40,7 @@ import {
|
||||||
STATUS_UNFILTER,
|
STATUS_UNFILTER,
|
||||||
STATUS_UNMUTE_SUCCESS,
|
STATUS_UNMUTE_SUCCESS,
|
||||||
type StatusesAction,
|
type StatusesAction,
|
||||||
|
STATUS_DELETE_SUCCESS,
|
||||||
} from '../actions/statuses';
|
} from '../actions/statuses';
|
||||||
import { TIMELINE_DELETE, type TimelineAction } from '../actions/timelines';
|
import { TIMELINE_DELETE, type TimelineAction } from '../actions/timelines';
|
||||||
|
|
||||||
|
@ -281,6 +282,13 @@ const statuses = (state = initialState, action: EmojiReactsAction | EventsAction
|
||||||
status.event.join_state = action.previousState;
|
status.event.join_state = action.previousState;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
case STATUS_DELETE_SUCCESS:
|
||||||
|
return create(state, (draft) => {
|
||||||
|
const status = draft[action.statusId];
|
||||||
|
if (status) {
|
||||||
|
status.deleted = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue