feat: remove usage of .last

This commit is contained in:
Shivam Mishra
2026-04-23 14:44:52 +05:30
parent 190416d765
commit 83e96956fc
6 changed files with 2 additions and 26 deletions
@@ -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;
@@ -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,
@@ -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', () => {
+1 -3
View File
@@ -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
-2
View File
@@ -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;
@@ -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;