Refactor CW handling in an action (#31103)
parent
03dea64b79
commit
9cb9427133
|
@ -308,6 +308,21 @@ export function revealStatus(ids) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function toggleStatusSpoilers(statusId) {
|
||||||
|
return (dispatch, getState) => {
|
||||||
|
const status = getState().statuses.get(statusId);
|
||||||
|
|
||||||
|
if (!status)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (status.get('hidden')) {
|
||||||
|
dispatch(revealStatus(statusId));
|
||||||
|
} else {
|
||||||
|
dispatch(hideStatus(statusId));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function toggleStatusCollapse(id, isCollapsed) {
|
export function toggleStatusCollapse(id, isCollapsed) {
|
||||||
return {
|
return {
|
||||||
type: STATUS_COLLAPSE,
|
type: STATUS_COLLAPSE,
|
||||||
|
|
|
@ -36,8 +36,7 @@ import {
|
||||||
muteStatus,
|
muteStatus,
|
||||||
unmuteStatus,
|
unmuteStatus,
|
||||||
deleteStatus,
|
deleteStatus,
|
||||||
hideStatus,
|
toggleStatusSpoilers,
|
||||||
revealStatus,
|
|
||||||
toggleStatusCollapse,
|
toggleStatusCollapse,
|
||||||
editStatus,
|
editStatus,
|
||||||
translateStatus,
|
translateStatus,
|
||||||
|
@ -223,11 +222,7 @@ const mapDispatchToProps = (dispatch, { intl, contextType }) => ({
|
||||||
},
|
},
|
||||||
|
|
||||||
onToggleHidden (status) {
|
onToggleHidden (status) {
|
||||||
if (status.get('hidden')) {
|
dispatch(toggleStatusSpoilers(status.get('id')));
|
||||||
dispatch(revealStatus(status.get('id')));
|
|
||||||
} else {
|
|
||||||
dispatch(hideStatus(status.get('id')));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onToggleCollapsed (status, isCollapsed) {
|
onToggleCollapsed (status, isCollapsed) {
|
||||||
|
|
|
@ -18,7 +18,7 @@ import ReplyIcon from '@/material-icons/400-24px/reply.svg?react';
|
||||||
import { replyCompose } from 'mastodon/actions/compose';
|
import { replyCompose } from 'mastodon/actions/compose';
|
||||||
import { markConversationRead, deleteConversation } from 'mastodon/actions/conversations';
|
import { markConversationRead, deleteConversation } from 'mastodon/actions/conversations';
|
||||||
import { openModal } from 'mastodon/actions/modal';
|
import { openModal } from 'mastodon/actions/modal';
|
||||||
import { muteStatus, unmuteStatus, revealStatus, hideStatus } from 'mastodon/actions/statuses';
|
import { muteStatus, unmuteStatus, toggleStatusSpoilers } from 'mastodon/actions/statuses';
|
||||||
import AttachmentList from 'mastodon/components/attachment_list';
|
import AttachmentList from 'mastodon/components/attachment_list';
|
||||||
import AvatarComposite from 'mastodon/components/avatar_composite';
|
import AvatarComposite from 'mastodon/components/avatar_composite';
|
||||||
import { IconButton } from 'mastodon/components/icon_button';
|
import { IconButton } from 'mastodon/components/icon_button';
|
||||||
|
@ -138,11 +138,7 @@ export const Conversation = ({ conversation, scrollKey, onMoveUp, onMoveDown })
|
||||||
}, [dispatch, lastStatus]);
|
}, [dispatch, lastStatus]);
|
||||||
|
|
||||||
const handleShowMore = useCallback(() => {
|
const handleShowMore = useCallback(() => {
|
||||||
if (lastStatus.get('hidden')) {
|
dispatch(toggleStatusSpoilers(lastStatus.get('id')));
|
||||||
dispatch(revealStatus(lastStatus.get('id')));
|
|
||||||
} else {
|
|
||||||
dispatch(hideStatus(lastStatus.get('id')));
|
|
||||||
}
|
|
||||||
}, [dispatch, lastStatus]);
|
}, [dispatch, lastStatus]);
|
||||||
|
|
||||||
if (!lastStatus) {
|
if (!lastStatus) {
|
||||||
|
|
|
@ -6,8 +6,7 @@ import {
|
||||||
toggleReblog,
|
toggleReblog,
|
||||||
} from '../../../actions/interactions';
|
} from '../../../actions/interactions';
|
||||||
import {
|
import {
|
||||||
hideStatus,
|
toggleStatusSpoilers,
|
||||||
revealStatus,
|
|
||||||
} from '../../../actions/statuses';
|
} from '../../../actions/statuses';
|
||||||
import { makeGetNotification, makeGetStatus, makeGetReport } from '../../../selectors';
|
import { makeGetNotification, makeGetStatus, makeGetReport } from '../../../selectors';
|
||||||
import Notification from '../components/notification';
|
import Notification from '../components/notification';
|
||||||
|
@ -43,11 +42,7 @@ const mapDispatchToProps = dispatch => ({
|
||||||
},
|
},
|
||||||
|
|
||||||
onToggleHidden (status) {
|
onToggleHidden (status) {
|
||||||
if (status.get('hidden')) {
|
dispatch(toggleStatusSpoilers(status.get('id')));
|
||||||
dispatch(revealStatus(status.get('id')));
|
|
||||||
} else {
|
|
||||||
dispatch(hideStatus(status.get('id')));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -22,8 +22,7 @@ import {
|
||||||
muteStatus,
|
muteStatus,
|
||||||
unmuteStatus,
|
unmuteStatus,
|
||||||
deleteStatus,
|
deleteStatus,
|
||||||
hideStatus,
|
toggleStatusSpoilers,
|
||||||
revealStatus,
|
|
||||||
} from '../../../actions/statuses';
|
} from '../../../actions/statuses';
|
||||||
import { deleteModal } from '../../../initial_state';
|
import { deleteModal } from '../../../initial_state';
|
||||||
import { makeGetStatus, makeGetPictureInPicture } from '../../../selectors';
|
import { makeGetStatus, makeGetPictureInPicture } from '../../../selectors';
|
||||||
|
@ -156,11 +155,7 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
|
||||||
},
|
},
|
||||||
|
|
||||||
onToggleHidden (status) {
|
onToggleHidden (status) {
|
||||||
if (status.get('hidden')) {
|
dispatch(toggleStatusSpoilers(status.get('id')));
|
||||||
dispatch(revealStatus(status.get('id')));
|
|
||||||
} else {
|
|
||||||
dispatch(hideStatus(status.get('id')));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue