kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Compose: clean up unused sensitivity actions
rodzic
69157097dd
commit
9ae8fc4e03
|
@ -54,7 +54,6 @@ const COMPOSE_SUGGESTION_TAGS_UPDATE = 'COMPOSE_SUGGESTION_TAGS_UPDATE';
|
||||||
|
|
||||||
const COMPOSE_TAG_HISTORY_UPDATE = 'COMPOSE_TAG_HISTORY_UPDATE';
|
const COMPOSE_TAG_HISTORY_UPDATE = 'COMPOSE_TAG_HISTORY_UPDATE';
|
||||||
|
|
||||||
const COMPOSE_SENSITIVITY_CHANGE = 'COMPOSE_SENSITIVITY_CHANGE';
|
|
||||||
const COMPOSE_SPOILERNESS_CHANGE = 'COMPOSE_SPOILERNESS_CHANGE';
|
const COMPOSE_SPOILERNESS_CHANGE = 'COMPOSE_SPOILERNESS_CHANGE';
|
||||||
const COMPOSE_TYPE_CHANGE = 'COMPOSE_TYPE_CHANGE';
|
const COMPOSE_TYPE_CHANGE = 'COMPOSE_TYPE_CHANGE';
|
||||||
const COMPOSE_SPOILER_TEXT_CHANGE = 'COMPOSE_SPOILER_TEXT_CHANGE';
|
const COMPOSE_SPOILER_TEXT_CHANGE = 'COMPOSE_SPOILER_TEXT_CHANGE';
|
||||||
|
@ -600,11 +599,6 @@ const insertIntoTagHistory = (composeId: string, recognizedTags: APIEntity[], te
|
||||||
dispatch(updateTagHistory(composeId, newHistory));
|
dispatch(updateTagHistory(composeId, newHistory));
|
||||||
};
|
};
|
||||||
|
|
||||||
const changeComposeSensitivity = (composeId: string) => ({
|
|
||||||
type: COMPOSE_SENSITIVITY_CHANGE,
|
|
||||||
id: composeId,
|
|
||||||
});
|
|
||||||
|
|
||||||
const changeComposeSpoilerness = (composeId: string) => ({
|
const changeComposeSpoilerness = (composeId: string) => ({
|
||||||
type: COMPOSE_SPOILERNESS_CHANGE,
|
type: COMPOSE_SPOILERNESS_CHANGE,
|
||||||
id: composeId,
|
id: composeId,
|
||||||
|
@ -741,7 +735,6 @@ export {
|
||||||
COMPOSE_SUGGESTION_SELECT,
|
COMPOSE_SUGGESTION_SELECT,
|
||||||
COMPOSE_SUGGESTION_TAGS_UPDATE,
|
COMPOSE_SUGGESTION_TAGS_UPDATE,
|
||||||
COMPOSE_TAG_HISTORY_UPDATE,
|
COMPOSE_TAG_HISTORY_UPDATE,
|
||||||
COMPOSE_SENSITIVITY_CHANGE,
|
|
||||||
COMPOSE_SPOILERNESS_CHANGE,
|
COMPOSE_SPOILERNESS_CHANGE,
|
||||||
COMPOSE_TYPE_CHANGE,
|
COMPOSE_TYPE_CHANGE,
|
||||||
COMPOSE_SPOILER_TEXT_CHANGE,
|
COMPOSE_SPOILER_TEXT_CHANGE,
|
||||||
|
@ -796,7 +789,6 @@ export {
|
||||||
selectComposeSuggestion,
|
selectComposeSuggestion,
|
||||||
updateSuggestionTags,
|
updateSuggestionTags,
|
||||||
updateTagHistory,
|
updateTagHistory,
|
||||||
changeComposeSensitivity,
|
|
||||||
changeComposeSpoilerness,
|
changeComposeSpoilerness,
|
||||||
changeComposeContentType,
|
changeComposeContentType,
|
||||||
changeComposeSpoilerText,
|
changeComposeSpoilerText,
|
||||||
|
|
|
@ -1,48 +0,0 @@
|
||||||
import React from 'react';
|
|
||||||
import { useIntl, defineMessages, FormattedMessage } from 'react-intl';
|
|
||||||
|
|
||||||
import { changeComposeSensitivity } from 'soapbox/actions/compose';
|
|
||||||
import { FormGroup, Checkbox } from 'soapbox/components/ui';
|
|
||||||
import { useAppDispatch, useCompose } from 'soapbox/hooks';
|
|
||||||
|
|
||||||
const messages = defineMessages({
|
|
||||||
marked: { id: 'compose_form.sensitive.marked', defaultMessage: 'Media is marked as sensitive' },
|
|
||||||
unmarked: { id: 'compose_form.sensitive.unmarked', defaultMessage: 'Media is not marked as sensitive' },
|
|
||||||
});
|
|
||||||
|
|
||||||
interface ISensitiveButton {
|
|
||||||
composeId: string,
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Button to mark own media as sensitive. */
|
|
||||||
const SensitiveButton: React.FC<ISensitiveButton> = ({ composeId }) => {
|
|
||||||
const intl = useIntl();
|
|
||||||
const dispatch = useAppDispatch();
|
|
||||||
|
|
||||||
const compose = useCompose(composeId);
|
|
||||||
|
|
||||||
const active = compose.sensitive === true;
|
|
||||||
const disabled = compose.spoiler === true;
|
|
||||||
|
|
||||||
const onClick = () => {
|
|
||||||
dispatch(changeComposeSensitivity(composeId));
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className='px-2.5 py-1'>
|
|
||||||
<FormGroup
|
|
||||||
labelText={<FormattedMessage id='compose_form.sensitive.hide' defaultMessage='Mark media as sensitive' />}
|
|
||||||
labelTitle={intl.formatMessage(active ? messages.marked : messages.unmarked)}
|
|
||||||
>
|
|
||||||
<Checkbox
|
|
||||||
name='mark-sensitive'
|
|
||||||
checked={active}
|
|
||||||
onChange={onClick}
|
|
||||||
disabled={disabled}
|
|
||||||
/>
|
|
||||||
</FormGroup>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default SensitiveButton;
|
|
|
@ -3,7 +3,6 @@ import React from 'react';
|
||||||
|
|
||||||
import { useCompose } from 'soapbox/hooks';
|
import { useCompose } from 'soapbox/hooks';
|
||||||
|
|
||||||
import SensitiveButton from './sensitive-button';
|
|
||||||
import Upload from './upload';
|
import Upload from './upload';
|
||||||
import UploadProgress from './upload-progress';
|
import UploadProgress from './upload-progress';
|
||||||
|
|
||||||
|
@ -28,8 +27,6 @@ const UploadForm: React.FC<IUploadForm> = ({ composeId }) => {
|
||||||
<Upload id={id} key={id} composeId={composeId} />
|
<Upload id={id} key={id} composeId={composeId} />
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{!mediaIds.isEmpty() && <SensitiveButton composeId={composeId} />}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -181,30 +181,8 @@ describe('compose reducer', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle COMPOSE_SENSITIVITY_CHANGE on Mark Sensitive click, don\'t toggle if spoiler active', () => {
|
|
||||||
const state = initialState.set('home', ReducerCompose({ spoiler: true, sensitive: true, idempotencyKey: '' }));
|
|
||||||
const action = {
|
|
||||||
type: actions.COMPOSE_SENSITIVITY_CHANGE,
|
|
||||||
id: 'home',
|
|
||||||
};
|
|
||||||
expect(reducer(state, action).toJS().home).toMatchObject({
|
|
||||||
sensitive: true,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should handle COMPOSE_SENSITIVITY_CHANGE on Mark Sensitive click, toggle if spoiler inactive', () => {
|
|
||||||
const state = initialState.set('home', ReducerCompose({ spoiler: false, sensitive: true }));
|
|
||||||
const action = {
|
|
||||||
type: actions.COMPOSE_SENSITIVITY_CHANGE,
|
|
||||||
id: 'home',
|
|
||||||
};
|
|
||||||
expect(reducer(state, action).toJS().home).toMatchObject({
|
|
||||||
sensitive: false,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should handle COMPOSE_SPOILERNESS_CHANGE on CW button click', () => {
|
it('should handle COMPOSE_SPOILERNESS_CHANGE on CW button click', () => {
|
||||||
const state = initialState.set('home', ReducerCompose({ spoiler_text: 'spoiler text', spoiler: true, media_attachments: ImmutableList() }));
|
const state = initialState.set('home', ReducerCompose({ spoiler_text: 'spoiler text', spoiler: true, sensitive: true, media_attachments: ImmutableList() }));
|
||||||
const action = {
|
const action = {
|
||||||
type: actions.COMPOSE_SPOILERNESS_CHANGE,
|
type: actions.COMPOSE_SPOILERNESS_CHANGE,
|
||||||
id: 'home',
|
id: 'home',
|
||||||
|
@ -212,6 +190,7 @@ describe('compose reducer', () => {
|
||||||
expect(reducer(state, action).toJS().home).toMatchObject({
|
expect(reducer(state, action).toJS().home).toMatchObject({
|
||||||
spoiler: false,
|
spoiler: false,
|
||||||
spoiler_text: '',
|
spoiler_text: '',
|
||||||
|
sensitive: false,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@ import {
|
||||||
COMPOSE_SUGGESTION_SELECT,
|
COMPOSE_SUGGESTION_SELECT,
|
||||||
COMPOSE_SUGGESTION_TAGS_UPDATE,
|
COMPOSE_SUGGESTION_TAGS_UPDATE,
|
||||||
COMPOSE_TAG_HISTORY_UPDATE,
|
COMPOSE_TAG_HISTORY_UPDATE,
|
||||||
COMPOSE_SENSITIVITY_CHANGE,
|
|
||||||
COMPOSE_SPOILERNESS_CHANGE,
|
COMPOSE_SPOILERNESS_CHANGE,
|
||||||
COMPOSE_TYPE_CHANGE,
|
COMPOSE_TYPE_CHANGE,
|
||||||
COMPOSE_SPOILER_TEXT_CHANGE,
|
COMPOSE_SPOILER_TEXT_CHANGE,
|
||||||
|
@ -279,14 +278,6 @@ export const initialState: State = ImmutableMap({
|
||||||
|
|
||||||
export default function compose(state = initialState, action: AnyAction) {
|
export default function compose(state = initialState, action: AnyAction) {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case COMPOSE_SENSITIVITY_CHANGE:
|
|
||||||
return updateCompose(state, action.id, compose => compose.withMutations(map => {
|
|
||||||
if (!compose.spoiler) {
|
|
||||||
map.set('sensitive', !compose.sensitive);
|
|
||||||
}
|
|
||||||
|
|
||||||
map.set('idempotencyKey', uuid());
|
|
||||||
}));
|
|
||||||
case COMPOSE_TYPE_CHANGE:
|
case COMPOSE_TYPE_CHANGE:
|
||||||
return updateCompose(state, action.id, compose => compose.withMutations(map => {
|
return updateCompose(state, action.id, compose => compose.withMutations(map => {
|
||||||
map.set('content_type', action.value);
|
map.set('content_type', action.value);
|
||||||
|
|
Ładowanie…
Reference in New Issue