diff --git a/app/javascript/dashboard/components/widgets/conversation/Message.vue b/app/javascript/dashboard/components/widgets/conversation/Message.vue index 391149bd0..e28815574 100644 --- a/app/javascript/dashboard/components/widgets/conversation/Message.vue +++ b/app/javascript/dashboard/components/widgets/conversation/Message.vue @@ -503,8 +503,8 @@ export default { }, handleReplyTo() { this.$store.dispatch('draftMessages/setInReplyTo', { - key: this.data.conversation_id, - inReplyTo: this.data.id, + conversationId: this.data.conversation_id, + inReplyToMessage: this.data.id, }); }, setupHighlightTimer() { diff --git a/app/javascript/dashboard/store/modules/draftMessages.js b/app/javascript/dashboard/store/modules/draftMessages.js index 89494839a..b41ff1b5a 100644 --- a/app/javascript/dashboard/store/modules/draftMessages.js +++ b/app/javascript/dashboard/store/modules/draftMessages.js @@ -15,8 +15,8 @@ export const getters = { get: _state => key => { return _state.records[key] || ''; }, - getInReplyTo: _state => key => { - return _state.inReplyTo[key]; + getInReplyTo: _state => conversationId => { + return _state.inReplyTo[conversationId]; }, getReplyEditorMode: _state => _state.replyEditorMode, }; @@ -28,11 +28,11 @@ export const actions = { delete: ({ commit }, { key }) => { commit(types.SET_DRAFT_MESSAGES, { key }); }, - setInReplyTo({ commit }, { key, inReplyTo }) { - commit(types.SET_IN_REPLY_TO, { key, inReplyTo }); + setInReplyTo({ commit }, { conversationId, inReplyToMessage }) { + commit(types.SET_IN_REPLY_TO, { conversationId, inReplyToMessage }); }, - deleteInReplyTo({ commit }, { key }) { - commit(types.REMOVE_IN_REPLY_TO, { key }); + deleteInReplyTo({ commit }, { conversationId }) { + commit(types.REMOVE_IN_REPLY_TO, { conversationId }); }, setReplyEditorMode: ({ commit }, { mode }) => { commit(types.SET_REPLY_EDITOR_MODE, { mode }); @@ -49,12 +49,13 @@ export const mutations = { Vue.set($state, 'records', updatedRecords); LocalStorage.set(LOCAL_STORAGE_KEYS.DRAFT_MESSAGES, $state.records); }, - [types.SET_IN_REPLY_TO]($state, { key, inReplyTo }) { - Vue.set($state.inReplyTo, key, inReplyTo); + [types.SET_IN_REPLY_TO]($state, { conversationId, inReplyToMessage }) { + Vue.set($state.inReplyTo, conversationId, inReplyToMessage); LocalStorage.set(LOCAL_STORAGE_KEYS.MESSAGE_IN_REPLY_TO, $state.inReplyTo); }, - [types.REMOVE_IN_REPLY_TO]($state, { key }) { - const { [key]: draftToBeRemoved, ...newRecords } = $state.inReplyTo; + [types.REMOVE_IN_REPLY_TO]($state, { conversationId }) { + const { [conversationId]: messageIdToBeRemoved, ...newRecords } = + $state.inReplyTo; Vue.set($state, 'inReplyTo', newRecords); LocalStorage.set(LOCAL_STORAGE_KEYS.DRAFT_MESSAGES, $state.inReplyTo); }, diff --git a/app/javascript/dashboard/store/modules/specs/draftMessages/actions.spec.js b/app/javascript/dashboard/store/modules/specs/draftMessages/actions.spec.js index 9a08fab29..c88783d4f 100644 --- a/app/javascript/dashboard/store/modules/specs/draftMessages/actions.spec.js +++ b/app/javascript/dashboard/store/modules/specs/draftMessages/actions.spec.js @@ -83,14 +83,14 @@ describe('#actions', () => { inReplyTo: {}, }, }, - { key: 45534, inReplyTo: 24332 } + { conversationId: 45534, inReplyToMessage: 24332 } ); expect(commit.mock.calls).toEqual([ [ types.SET_IN_REPLY_TO, { - key: 45534, - inReplyTo: 24332, + conversationId: 45534, + inReplyToMessage: 24332, }, ], ]); @@ -106,13 +106,13 @@ describe('#actions', () => { inReplyTo: {}, }, }, - { key: 45534 } + { conversationId: 45534 } ); expect(commit.mock.calls).toEqual([ [ types.REMOVE_IN_REPLY_TO, { - key: 45534, + conversationId: 45534, }, ], ]); diff --git a/app/javascript/dashboard/store/modules/specs/draftMessages/mutations.spec.js b/app/javascript/dashboard/store/modules/specs/draftMessages/mutations.spec.js index cbc1055f1..f62bae90e 100644 --- a/app/javascript/dashboard/store/modules/specs/draftMessages/mutations.spec.js +++ b/app/javascript/dashboard/store/modules/specs/draftMessages/mutations.spec.js @@ -37,8 +37,8 @@ describe('#mutations', () => { inReplyTo: {}, }; mutations[types.SET_IN_REPLY_TO](state, { - key: 1234, - inReplyTo: 9876, + conversationId: 1234, + inReplyToMessage: 9876, }); expect(state.inReplyTo).toEqual({ 1234: 9876, @@ -54,7 +54,7 @@ describe('#mutations', () => { }, }; mutations[types.REMOVE_IN_REPLY_TO](state, { - key: 1234, + conversationId: 1234, }); expect(state.inReplyTo).toEqual({}); });