diff --git a/webapp/channels/src/actions/views/drafts.test.ts b/webapp/channels/src/actions/views/drafts.test.ts index 361e92799b..4c706c2fc8 100644 --- a/webapp/channels/src/actions/views/drafts.test.ts +++ b/webapp/channels/src/actions/views/drafts.test.ts @@ -164,6 +164,19 @@ describe('draft actions', () => { describe('removeDraft', () => { it('calls setGlobalItem action correctly', async () => { + store = mockStore({ + ...initialState, + entities: { + ...initialState.entities, + general: { + ...initialState.entities.general, + config: { + ...initialState.entities.general.config, + AllowSyncedDrafts: 'false', + }, + }, + }, + }); await store.dispatch(removeDraft(key, channelId)); const testStore = mockStore(initialState); diff --git a/webapp/channels/src/actions/views/drafts.ts b/webapp/channels/src/actions/views/drafts.ts index 127227d7be..41921b728d 100644 --- a/webapp/channels/src/actions/views/drafts.ts +++ b/webapp/channels/src/actions/views/drafts.ts @@ -105,9 +105,6 @@ export function removeDraft(key: string, channelId: string, rootId = ''): Action // set draft to empty to re-render the component await dispatch(setGlobalItem(key, {message: '', fileInfos: [], uploadsInProgress: []})); - // remove draft from storage - await dispatch(removeGlobalItem(key)); - if (syncedDraftsAreAllowedAndEnabled(state)) { const connectionId = getConnectionId(getState()); @@ -119,6 +116,9 @@ export function removeDraft(key: string, channelId: string, rootId = ''): Action error, }; } + } else { + // only remove draft from storage for local drafts + await dispatch(removeGlobalItem(key)); } return {data: true}; };