mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-14 08:19:05 +00:00
[Glitch] Change public self-quotes of private posts to be disallowed
Port 75fca715e9 to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
@@ -89,6 +89,24 @@ const selectStatusPolicy = createAppSelector(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const selectDisablePublicVisibilities = createAppSelector(
|
||||||
|
[
|
||||||
|
(state) => state.statuses,
|
||||||
|
(_state, statusId?: string) => !!statusId,
|
||||||
|
(state) => state.compose.get('quoted_status_id') as string | null,
|
||||||
|
],
|
||||||
|
(statuses, isEditing, statusId) => {
|
||||||
|
if (isEditing || !statusId) return false;
|
||||||
|
|
||||||
|
const status = statuses.get(statusId);
|
||||||
|
if (!status) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return status.get('visibility') === 'private';
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
export const VisibilityModal: FC<VisibilityModalProps> = forwardRef(
|
export const VisibilityModal: FC<VisibilityModalProps> = forwardRef(
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
({ onClose, onChange, statusId }, _ref) => {
|
({ onClose, onChange, statusId }, _ref) => {
|
||||||
@@ -110,9 +128,30 @@ export const VisibilityModal: FC<VisibilityModalProps> = forwardRef(
|
|||||||
const disableVisibility = !!statusId;
|
const disableVisibility = !!statusId;
|
||||||
const disableQuotePolicy =
|
const disableQuotePolicy =
|
||||||
visibility === 'private' || visibility === 'direct';
|
visibility === 'private' || visibility === 'direct';
|
||||||
|
const disablePublicVisibilities: boolean = useAppSelector(
|
||||||
|
selectDisablePublicVisibilities,
|
||||||
|
);
|
||||||
|
|
||||||
const visibilityItems = useMemo<SelectItem<StatusVisibility>[]>(
|
const visibilityItems = useMemo<SelectItem<StatusVisibility>[]>(() => {
|
||||||
() => [
|
const items: SelectItem<StatusVisibility>[] = [
|
||||||
|
{
|
||||||
|
value: 'private',
|
||||||
|
text: intl.formatMessage(privacyMessages.private_short),
|
||||||
|
meta: intl.formatMessage(privacyMessages.private_long),
|
||||||
|
icon: 'lock',
|
||||||
|
iconComponent: LockIcon,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'direct',
|
||||||
|
text: intl.formatMessage(privacyMessages.direct_short),
|
||||||
|
meta: intl.formatMessage(privacyMessages.direct_long),
|
||||||
|
icon: 'at',
|
||||||
|
iconComponent: AlternateEmailIcon,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
if (!disablePublicVisibilities) {
|
||||||
|
items.unshift(
|
||||||
{
|
{
|
||||||
value: 'public',
|
value: 'public',
|
||||||
text: intl.formatMessage(privacyMessages.public_short),
|
text: intl.formatMessage(privacyMessages.public_short),
|
||||||
@@ -128,23 +167,11 @@ export const VisibilityModal: FC<VisibilityModalProps> = forwardRef(
|
|||||||
icon: 'unlock',
|
icon: 'unlock',
|
||||||
iconComponent: QuietTimeIcon,
|
iconComponent: QuietTimeIcon,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
value: 'private',
|
|
||||||
text: intl.formatMessage(privacyMessages.private_short),
|
|
||||||
meta: intl.formatMessage(privacyMessages.private_long),
|
|
||||||
icon: 'lock',
|
|
||||||
iconComponent: LockIcon,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 'direct',
|
|
||||||
text: intl.formatMessage(privacyMessages.direct_short),
|
|
||||||
meta: intl.formatMessage(privacyMessages.direct_long),
|
|
||||||
icon: 'at',
|
|
||||||
iconComponent: AlternateEmailIcon,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[intl],
|
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return items;
|
||||||
|
}, [intl, disablePublicVisibilities]);
|
||||||
const quoteItems = useMemo<SelectItem<ApiQuotePolicy>[]>(
|
const quoteItems = useMemo<SelectItem<ApiQuotePolicy>[]>(
|
||||||
() => [
|
() => [
|
||||||
{ value: 'public', text: intl.formatMessage(messages.quotePublic) },
|
{ value: 'public', text: intl.formatMessage(messages.quotePublic) },
|
||||||
@@ -236,6 +263,14 @@ export const VisibilityModal: FC<VisibilityModalProps> = forwardRef(
|
|||||||
/>
|
/>
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
|
{!statusId && disablePublicVisibilities && (
|
||||||
|
<p className='visibility-dropdown__helper'>
|
||||||
|
<FormattedMessage
|
||||||
|
id='visibility_modal.helper.privacy_private_self_quote'
|
||||||
|
defaultMessage='Self-quotes of private posts cannot be made public.'
|
||||||
|
/>
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<label
|
<label
|
||||||
|
|||||||
@@ -410,7 +410,8 @@ export const composeReducer = (state = initialState, action) => {
|
|||||||
return state
|
return state
|
||||||
.set('quoted_status_id', status.get('id'))
|
.set('quoted_status_id', status.get('id'))
|
||||||
.set('spoiler', status.get('sensitive'))
|
.set('spoiler', status.get('sensitive'))
|
||||||
.set('spoiler_text', status.get('spoiler_text'));
|
.set('spoiler_text', status.get('spoiler_text'))
|
||||||
|
.update('privacy', (visibility) => ['public', 'unlisted'].includes(visibility) && status.get('visibility') === 'private' ? 'private' : visibility);
|
||||||
} else if (quoteComposeCancel.match(action)) {
|
} else if (quoteComposeCancel.match(action)) {
|
||||||
return state.set('quoted_status_id', null);
|
return state.set('quoted_status_id', null);
|
||||||
} else if (setComposeQuotePolicy.match(action)) {
|
} else if (setComposeQuotePolicy.match(action)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user