791d90c6b7
At present, the websocket pubsub tokens are present at the contact objects in chatwoot. A better approach would be to have these tokens at the contact_inbox object instead. This helps chatwoot to deliver the websocket events targetted to the specific widget connection, stop contact events from leaking into other chat sessions from the same contact. Fixes #1682 Fixes #1664 Co-authored-by: Pranav Raj S <pranav@chatwoot.com> Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
56 lines
1.1 KiB
JavaScript
56 lines
1.1 KiB
JavaScript
import MessageAPI from '../../api/message';
|
|
|
|
const state = {
|
|
uiFlags: {
|
|
isUpdating: false,
|
|
},
|
|
};
|
|
|
|
export const getters = {
|
|
getUIFlags: $state => $state.uiFlags,
|
|
};
|
|
|
|
export const actions = {
|
|
update: async (
|
|
{ commit, dispatch },
|
|
{ email, messageId, submittedValues }
|
|
) => {
|
|
commit('toggleUpdateStatus', true);
|
|
try {
|
|
await MessageAPI.update({
|
|
email,
|
|
messageId,
|
|
values: submittedValues,
|
|
});
|
|
commit(
|
|
'conversation/updateMessage',
|
|
{
|
|
id: messageId,
|
|
content_attributes: {
|
|
submitted_email: email,
|
|
submitted_values: email ? null : submittedValues,
|
|
},
|
|
},
|
|
{ root: true }
|
|
);
|
|
dispatch('contacts/get', {}, { root: true });
|
|
} catch (error) {
|
|
// Ignore error
|
|
}
|
|
commit('toggleUpdateStatus', false);
|
|
},
|
|
};
|
|
|
|
export const mutations = {
|
|
toggleUpdateStatus($state, status) {
|
|
$state.uiFlags.isUpdating = status;
|
|
},
|
|
};
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state,
|
|
getters,
|
|
actions,
|
|
mutations,
|
|
};
|