From d467e82cdafaa5b703c527abe5c1d173beccfee6 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Thu, 13 Mar 2025 14:40:29 +0530 Subject: [PATCH] feat: update compact json method --- .../store/modules/conversations/index.js | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/app/javascript/dashboard/store/modules/conversations/index.js b/app/javascript/dashboard/store/modules/conversations/index.js index 9a2fc4501..d873516fb 100644 --- a/app/javascript/dashboard/store/modules/conversations/index.js +++ b/app/javascript/dashboard/store/modules/conversations/index.js @@ -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];