pl-fe: do not clear editor before sending post
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
cd3c35fcf9
commit
b9475efdec
2 changed files with 6 additions and 4 deletions
|
@ -343,11 +343,12 @@ const validateSchedule = (state: RootState, composeId: string) => {
|
||||||
interface SubmitComposeOpts {
|
interface SubmitComposeOpts {
|
||||||
history?: History;
|
history?: History;
|
||||||
force?: boolean;
|
force?: boolean;
|
||||||
|
onSuccess?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const submitCompose = (composeId: string, opts: SubmitComposeOpts = {}) =>
|
const submitCompose = (composeId: string, opts: SubmitComposeOpts = {}) =>
|
||||||
async (dispatch: AppDispatch, getState: () => RootState) => {
|
async (dispatch: AppDispatch, getState: () => RootState) => {
|
||||||
const { history, force = false } = opts;
|
const { history, force = false, onSuccess } = opts;
|
||||||
|
|
||||||
if (!isLoggedIn(getState)) return;
|
if (!isLoggedIn(getState)) return;
|
||||||
const state = getState();
|
const state = getState();
|
||||||
|
@ -372,7 +373,7 @@ const submitCompose = (composeId: string, opts: SubmitComposeOpts = {}) =>
|
||||||
useModalsStore.getState().openModal('MISSING_DESCRIPTION', {
|
useModalsStore.getState().openModal('MISSING_DESCRIPTION', {
|
||||||
onContinue: () => {
|
onContinue: () => {
|
||||||
useModalsStore.getState().closeModal('MISSING_DESCRIPTION');
|
useModalsStore.getState().closeModal('MISSING_DESCRIPTION');
|
||||||
dispatch(submitCompose(composeId, { history, force: true }));
|
dispatch(submitCompose(composeId, { history, force: true, onSuccess }));
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
@ -444,6 +445,7 @@ const submitCompose = (composeId: string, opts: SubmitComposeOpts = {}) =>
|
||||||
history.push('/conversations');
|
history.push('/conversations');
|
||||||
}
|
}
|
||||||
handleComposeSubmit(dispatch, getState, composeId, data, status, !!statusId);
|
handleComposeSubmit(dispatch, getState, composeId, data, status, !!statusId);
|
||||||
|
onSuccess?.();
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
dispatch(submitComposeFail(composeId, error));
|
dispatch(submitComposeFail(composeId, error));
|
||||||
});
|
});
|
||||||
|
|
|
@ -142,9 +142,9 @@ const ComposeForm = <ID extends string>({ id, shouldCondense, autoFocus, clickab
|
||||||
if (!canSubmit) return;
|
if (!canSubmit) return;
|
||||||
e?.preventDefault();
|
e?.preventDefault();
|
||||||
|
|
||||||
dispatch(submitCompose(id, { history })).then(() => {
|
dispatch(submitCompose(id, { history, onSuccess: () => {
|
||||||
editorRef.current?.dispatchCommand(CLEAR_EDITOR_COMMAND, undefined);
|
editorRef.current?.dispatchCommand(CLEAR_EDITOR_COMMAND, undefined);
|
||||||
}).catch(() => {});
|
} }));
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSuggestionsClearRequested = () => {
|
const onSuggestionsClearRequested = () => {
|
||||||
|
|
Loading…
Reference in a new issue