submitCompose: accept an options object
This commit is contained in:
parent
7863e6225e
commit
181df09039
|
@ -299,8 +299,15 @@ const validateSchedule = (state: RootState, composeId: string) => {
|
|||
return schedule.getTime() > fiveMinutesFromNow.getTime();
|
||||
};
|
||||
|
||||
const submitCompose = (composeId: string, routerHistory?: History, force = false) =>
|
||||
interface SubmitComposeOpts {
|
||||
history?: History;
|
||||
force?: boolean;
|
||||
}
|
||||
|
||||
const submitCompose = (composeId: string, opts: SubmitComposeOpts = {}) =>
|
||||
(dispatch: AppDispatch, getState: () => RootState) => {
|
||||
const { history, force = false } = opts;
|
||||
|
||||
if (!isLoggedIn(getState)) return;
|
||||
const state = getState();
|
||||
|
||||
|
@ -324,7 +331,7 @@ const submitCompose = (composeId: string, routerHistory?: History, force = false
|
|||
dispatch(openModal('MISSING_DESCRIPTION', {
|
||||
onContinue: () => {
|
||||
dispatch(closeModal('MISSING_DESCRIPTION'));
|
||||
dispatch(submitCompose(composeId, routerHistory, true));
|
||||
dispatch(submitCompose(composeId, { history, force: true }));
|
||||
},
|
||||
}));
|
||||
return;
|
||||
|
@ -361,8 +368,8 @@ const submitCompose = (composeId: string, routerHistory?: History, force = false
|
|||
}
|
||||
|
||||
dispatch(createStatus(params, idempotencyKey, statusId)).then(function(data) {
|
||||
if (!statusId && data.visibility === 'direct' && getState().conversations.mounted <= 0 && routerHistory) {
|
||||
routerHistory.push('/messages');
|
||||
if (!statusId && data.visibility === 'direct' && getState().conversations.mounted <= 0 && history) {
|
||||
history.push('/messages');
|
||||
}
|
||||
handleComposeSubmit(dispatch, getState, composeId, data, status, !!statusId);
|
||||
}).catch(function(error) {
|
||||
|
|
|
@ -152,7 +152,7 @@ const ComposeForm = <ID extends string>({ id, shouldCondense, autoFocus, clickab
|
|||
return;
|
||||
}
|
||||
|
||||
dispatch(submitCompose(id, history));
|
||||
dispatch(submitCompose(id, { history }));
|
||||
editorRef.current?.dispatchCommand(CLEAR_EDITOR_COMMAND, undefined);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue