diff --git a/app/soapbox/actions/compose.ts b/app/soapbox/actions/compose.ts index d37330d28..d2559c1f7 100644 --- a/app/soapbox/actions/compose.ts +++ b/app/soapbox/actions/compose.ts @@ -258,11 +258,10 @@ const submitCompose = (routerHistory: History, force = false) => return; } - if (to && status) { - const mentions: string[] | null = status.match(/(?:^|\s|\.)@([a-z0-9_]+(?:@[a-z0-9\.\-]+)?)/gi); // not a perfect regex + const mentions: string[] | null = status.match(/(?:^|\s)@([a-z\d_-]+(?:@[^@\s]+)?)/gi); - if (mentions) - to = to.union(mentions.map(mention => mention.trim().slice(1))); + if (mentions) { + to = to.union(mentions.map(mention => mention.trim().slice(1))); } dispatch(submitComposeRequest()); diff --git a/app/soapbox/reducers/compose.ts b/app/soapbox/reducers/compose.ts index d2fd1b3fe..c15e26270 100644 --- a/app/soapbox/reducers/compose.ts +++ b/app/soapbox/reducers/compose.ts @@ -104,7 +104,7 @@ export const ReducerRecord = ImmutableRecord({ suggestion_token: null as string | null, tagHistory: ImmutableList(), text: '', - to: null as ImmutableOrderedSet | null, + to: ImmutableOrderedSet(), }); type State = ReturnType; @@ -145,24 +145,6 @@ function clearAll(state: State) { privacy: state.default_privacy, 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) { @@ -369,7 +351,7 @@ export default function compose(state = ReducerRecord({ idempotencyKey: uuid(), case COMPOSE_QUOTE: return state.withMutations(map => { map.set('quote', action.status.get('id')); - map.set('to', null); + map.set('to', ImmutableOrderedSet()); map.set('text', ''); map.set('privacy', privacyPreference(action.status.visibility, state.default_privacy)); map.set('focusDate', new Date());