Fix: Hide prechat for sessions inititated with setUser (#1914)
This commit is contained in:
committed by
GitHub
parent
484c32fae3
commit
3043ee5058
@@ -1,7 +1,27 @@
|
||||
import ContactsAPI from '../../api/contacts';
|
||||
import { refreshActionCableConnector } from '../../helpers/actionCable';
|
||||
|
||||
const state = {
|
||||
currentUser: {},
|
||||
};
|
||||
|
||||
const SET_CURRENT_USER = 'SET_CURRENT_USER';
|
||||
|
||||
export const getters = {
|
||||
getCurrentUser(_state) {
|
||||
return _state.currentUser;
|
||||
},
|
||||
};
|
||||
|
||||
export const actions = {
|
||||
get: async ({ commit }) => {
|
||||
try {
|
||||
const { data } = await ContactsAPI.get();
|
||||
commit(SET_CURRENT_USER, data);
|
||||
} catch (error) {
|
||||
// Ignore error
|
||||
}
|
||||
},
|
||||
update: async ({ dispatch }, { identifier, user: userObject }) => {
|
||||
try {
|
||||
const user = {
|
||||
@@ -14,6 +34,7 @@ export const actions = {
|
||||
data: { pubsub_token: pubsubToken },
|
||||
} = await ContactsAPI.update(identifier, user);
|
||||
|
||||
dispatch('get');
|
||||
if (userObject.identifier_hash) {
|
||||
dispatch('conversation/clearConversations', {}, { root: true });
|
||||
dispatch('conversation/fetchOldConversations', {}, { root: true });
|
||||
@@ -33,10 +54,17 @@ export const actions = {
|
||||
},
|
||||
};
|
||||
|
||||
export const mutations = {
|
||||
[SET_CURRENT_USER]($state, user) {
|
||||
const { currentUser } = $state;
|
||||
$state.currentUser = { ...currentUser, ...user };
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {},
|
||||
getters: {},
|
||||
state,
|
||||
getters,
|
||||
actions,
|
||||
mutations: {},
|
||||
mutations,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user