pl-fe: do not clear editor before sending post

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2024-10-26 22:47:12 +02:00
parent cd3c35fcf9
commit b9475efdec
2 changed files with 6 additions and 4 deletions

View file

@ -343,11 +343,12 @@ const validateSchedule = (state: RootState, composeId: string) => {
interface SubmitComposeOpts {
history?: History;
force?: boolean;
onSuccess?: () => void;
}
const submitCompose = (composeId: string, opts: SubmitComposeOpts = {}) =>
async (dispatch: AppDispatch, getState: () => RootState) => {
const { history, force = false } = opts;
const { history, force = false, onSuccess } = opts;
if (!isLoggedIn(getState)) return;
const state = getState();
@ -372,7 +373,7 @@ const submitCompose = (composeId: string, opts: SubmitComposeOpts = {}) =>
useModalsStore.getState().openModal('MISSING_DESCRIPTION', {
onContinue: () => {
useModalsStore.getState().closeModal('MISSING_DESCRIPTION');
dispatch(submitCompose(composeId, { history, force: true }));
dispatch(submitCompose(composeId, { history, force: true, onSuccess }));
},
});
return;
@ -444,6 +445,7 @@ const submitCompose = (composeId: string, opts: SubmitComposeOpts = {}) =>
history.push('/conversations');
}
handleComposeSubmit(dispatch, getState, composeId, data, status, !!statusId);
onSuccess?.();
}).catch((error) => {
dispatch(submitComposeFail(composeId, error));
});

View file

@ -142,9 +142,9 @@ const ComposeForm = <ID extends string>({ id, shouldCondense, autoFocus, clickab
if (!canSubmit) return;
e?.preventDefault();
dispatch(submitCompose(id, { history })).then(() => {
dispatch(submitCompose(id, { history, onSuccess: () => {
editorRef.current?.dispatchCommand(CLEAR_EDITOR_COMMAND, undefined);
}).catch(() => {});
} }));
};
const onSuggestionsClearRequested = () => {