feat: update compact json method

This commit is contained in:
Shivam Mishra
2025-03-13 14:40:29 +05:30
parent 09c0660adb
commit d467e82cda
@@ -8,6 +8,21 @@ import { BUS_EVENTS } from '../../../../shared/constants/busEvents';
import { emitter } from 'shared/helpers/mitt';
import * as Sentry from '@sentry/vue';
const makeCompactJson = obj => {
// get rid of irrelevant data
const { messages, additional_attributes, sla_events, ...remaining } = obj;
const strinRep = JSON.stringify(remaining);
// replace active storage URLs with a placeholder
const activeStorageUrlRegex =
/https?:\/\/[^/]+\/rails\/active_storage[^\s]+/g;
const replacedStr = strinRep.replace(
activeStorageUrlRegex,
'[ACTIVE_STORAGE_URL]'
);
return replacedStr;
};
const state = {
allConversations: [],
attachments: {},
@@ -212,21 +227,6 @@ export const mutations = {
const { allConversations } = _state;
const index = allConversations.findIndex(c => c.id === conversation.id);
const makeCompactJson = obj => {
// get rid of messages
const { messages, ...remaining } = obj;
const strinRep = JSON.stringify(remaining);
// replace active storage URLs with a placeholder
const activeStorageUrlRegex =
/https?:\/\/[^/]+\/rails\/active_storage[^\s]+/g;
const replacedStr = strinRep.replace(
activeStorageUrlRegex,
'[ACTIVE_STORAGE_URL]'
);
return replacedStr;
};
if (index > -1) {
const selectedConversation = allConversations[index];