diff --git a/app/javascript/dashboard/helper/commons.js b/app/javascript/dashboard/helper/commons.js index 3be7538bb..f2ec1651a 100644 --- a/app/javascript/dashboard/helper/commons.js +++ b/app/javascript/dashboard/helper/commons.js @@ -1,18 +1,6 @@ -/* eslint no-param-reassign: 0 */ - import getUuid from 'widget/helpers/uuid'; import { MESSAGE_STATUS, MESSAGE_TYPE } from 'shared/constants/messages'; -export default () => { - if (!Array.prototype.last) { - Object.assign(Array.prototype, { - last() { - return this[this.length - 1]; - }, - }); - } -}; - export const isEmptyObject = obj => Object.keys(obj).length === 0 && obj.constructor === Object; diff --git a/app/javascript/dashboard/store/modules/conversations/actions.js b/app/javascript/dashboard/store/modules/conversations/actions.js index 09497c4c7..317139cda 100644 --- a/app/javascript/dashboard/store/modules/conversations/actions.js +++ b/app/javascript/dashboard/store/modules/conversations/actions.js @@ -181,7 +181,7 @@ const actions = { ); if (!selectedChat) return; const { messages } = selectedChat; - const lastMessage = messages.last(); + const lastMessage = messages[messages.length - 1]; if (!lastMessage) return; commit(types.SET_LAST_MESSAGE_ID_IN_SYNC_CONVERSATION, { conversationId, diff --git a/app/javascript/dashboard/store/modules/specs/conversations/getters.spec.js b/app/javascript/dashboard/store/modules/specs/conversations/getters.spec.js index 7b6c38456..706350d75 100644 --- a/app/javascript/dashboard/store/modules/specs/conversations/getters.spec.js +++ b/app/javascript/dashboard/store/modules/specs/conversations/getters.spec.js @@ -1,4 +1,3 @@ -import commonHelpers from '../../../../helper/commons'; import getters from '../../conversations/getters'; /* Order of conversations in the fixture is as follows: @@ -9,9 +8,6 @@ import getters from '../../conversations/getters'; */ import conversations from './conversations.fixtures'; -// loads .last() helper -commonHelpers(); - describe('#getters', () => { describe('#getAllConversations', () => { it('returns conversations ordered by lastActivityAt in descending order if no sort order is available', () => { diff --git a/app/javascript/entrypoints/dashboard.js b/app/javascript/entrypoints/dashboard.js index d0c6c808d..5d62146e7 100644 --- a/app/javascript/entrypoints/dashboard.js +++ b/app/javascript/entrypoints/dashboard.js @@ -13,7 +13,7 @@ import App from 'dashboard/App.vue'; import i18nMessages from 'dashboard/i18n'; import createAxios from 'dashboard/helper/APIHelper'; -import commonHelpers, { isJSONValid } from 'dashboard/helper/commons'; +import { isJSONValid } from 'dashboard/helper/commons'; import { sync } from 'vuex-router-sync'; import { createPinia } from 'pinia'; import router, { initalizeRouter } from 'dashboard/routes'; @@ -97,8 +97,6 @@ app.component('fluent-icon', FluentIcon); app.directive('resize', vResizeObserver); app.directive('on-clickaway', onClickaway); -// load common helpers into js -commonHelpers(); window.WootConstants = constants; window.axios = createAxios(axios); // [VITE] Disabled this we don't need it, we can use `useEmitter` directly diff --git a/app/javascript/entrypoints/ui.js b/app/javascript/entrypoints/ui.js index 69b03bf5b..1283a3622 100644 --- a/app/javascript/entrypoints/ui.js +++ b/app/javascript/entrypoints/ui.js @@ -13,7 +13,6 @@ import store from '../dashboard/store'; import constants from '../dashboard/constants/globals'; import axios from 'axios'; import createAxios from '../ui/axios'; -import commonHelpers from '../dashboard/helper/commons'; import vueActionCable from '../dashboard/helper/actionCable'; import MessageList from '../ui/MessageList.vue'; @@ -29,7 +28,6 @@ const i18n = createI18n({ }); export const init = async () => { - commonHelpers(); // eslint-disable-next-line no-underscore-dangle window.__CHATWOOT_STORE__ = store; window.WootConstants = constants; diff --git a/app/javascript/react-components/src/components/ChatwootProvider.jsx b/app/javascript/react-components/src/components/ChatwootProvider.jsx index fcb82df4d..1379e8c70 100644 --- a/app/javascript/react-components/src/components/ChatwootProvider.jsx +++ b/app/javascript/react-components/src/components/ChatwootProvider.jsx @@ -4,7 +4,6 @@ import store from '../../../dashboard/store'; import constants from '../../../dashboard/constants/globals'; import axios from 'axios'; import createAxios from '../../../ui/axios'; -import commonHelpers from '../../../dashboard/helper/commons'; import vueActionCable from '../../../dashboard/helper/actionCable'; const ChatwootContext = createContext(); @@ -72,9 +71,6 @@ export const ChatwootProvider = ({ window.__WOOT_ISOLATED_SHELL__ = true; /* eslint-enable no-underscore-dangle */ - // Initialize common helpers - commonHelpers(); - // Set up global objects // eslint-disable-next-line no-underscore-dangle window.WootConstants = constants;