feat: Add reply editor mode to the store (#7515)

This commit is contained in:
Muhsin Keloth
2023-07-13 14:56:53 +05:30
committed by GitHub
parent 19ff738211
commit 50a927bac2
6 changed files with 54 additions and 0 deletions

View File

@@ -1,17 +1,20 @@
import Vue from 'vue';
import types from '../mutation-types';
import { REPLY_EDITOR_MODES } from 'dashboard/components/widgets/WootWriter/constants';
import { LocalStorage } from 'shared/helpers/localStorage';
import { LOCAL_STORAGE_KEYS } from 'dashboard/constants/localStorage';
const state = {
records: LocalStorage.get(LOCAL_STORAGE_KEYS.DRAFT_MESSAGES) || {},
replyEditorMode: REPLY_EDITOR_MODES.REPLY,
};
export const getters = {
get: _state => key => {
return _state.records[key] || '';
},
getReplyEditorMode: _state => _state.replyEditorMode,
};
export const actions = {
@@ -21,6 +24,9 @@ export const actions = {
delete: ({ commit }, { key }) => {
commit(types.SET_DRAFT_MESSAGES, { key });
},
setReplyEditorMode: ({ commit }, { mode }) => {
commit(types.SET_REPLY_EDITOR_MODE, { mode });
},
};
export const mutations = {
@@ -33,6 +39,9 @@ export const mutations = {
Vue.set($state, 'records', updatedRecords);
LocalStorage.set(LOCAL_STORAGE_KEYS.DRAFT_MESSAGES, $state.records);
},
[types.SET_REPLY_EDITOR_MODE]($state, { mode }) {
Vue.set($state, 'replyEditorMode', mode);
},
};
export default {