Merge branch 'to-fix' into 'develop'

Always send the "to" field

See merge request soapbox-pub/soapbox-fe!1679
This commit is contained in:
Alex Gleason 2022-07-26 15:48:47 +00:00
commit a984bfd76a
2 changed files with 5 additions and 24 deletions

View File

@ -258,10 +258,9 @@ const submitCompose = (routerHistory: History, force = false) =>
return; return;
} }
if (to && status) { const mentions: string[] | null = status.match(/(?:^|\s)@([a-z\d_-]+(?:@[^@\s]+)?)/gi);
const mentions: string[] | null = status.match(/(?:^|\s|\.)@([a-z0-9_]+(?:@[a-z0-9\.\-]+)?)/gi); // not a perfect regex
if (mentions) if (mentions) {
to = to.union(mentions.map(mention => mention.trim().slice(1))); to = to.union(mentions.map(mention => mention.trim().slice(1)));
} }

View File

@ -104,7 +104,7 @@ export const ReducerRecord = ImmutableRecord({
suggestion_token: null as string | null, suggestion_token: null as string | null,
tagHistory: ImmutableList<string>(), tagHistory: ImmutableList<string>(),
text: '', text: '',
to: null as ImmutableOrderedSet<string> | null, to: ImmutableOrderedSet<string>(),
}); });
type State = ReturnType<typeof ReducerRecord>; type State = ReturnType<typeof ReducerRecord>;
@ -145,24 +145,6 @@ function clearAll(state: State) {
privacy: state.default_privacy, privacy: state.default_privacy,
idempotencyKey: uuid(), idempotencyKey: uuid(),
}); });
// state.withMutations(map => {
// map.set('id', null);
// map.set('text', '');
// map.set('to', ImmutableOrderedSet());
// map.set('spoiler', false);
// map.set('spoiler_text', '');
// map.set('content_type', state.COMPOSE_SUBMIT_SUCCESS);
// map.set('is_submitting', false);
// map.set('is_changing_upload', false);
// map.set('in_reply_to', null);
// map.set('quote', null);
// map.set('privacy', state.default_privacy);
// map.set('sensitive', false);
// map.set('media_attachments', ImmutableList());
// map.set('poll', null);
// map.set('idempotencyKey', uuid());
// map.set('schedule', null);
// });
} }
function appendMedia(state: State, media: APIEntity) { function appendMedia(state: State, media: APIEntity) {
@ -369,7 +351,7 @@ export default function compose(state = ReducerRecord({ idempotencyKey: uuid(),
case COMPOSE_QUOTE: case COMPOSE_QUOTE:
return state.withMutations(map => { return state.withMutations(map => {
map.set('quote', action.status.get('id')); map.set('quote', action.status.get('id'));
map.set('to', null); map.set('to', ImmutableOrderedSet());
map.set('text', ''); map.set('text', '');
map.set('privacy', privacyPreference(action.status.visibility, state.default_privacy)); map.set('privacy', privacyPreference(action.status.visibility, state.default_privacy));
map.set('focusDate', new Date()); map.set('focusDate', new Date());