mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 03:57:52 +00:00
refactor: better variable names
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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);
|
||||
},
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
],
|
||||
]);
|
||||
|
||||
@@ -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({});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user