feat: remove usage of .last
This commit is contained in:
@@ -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', () => {
|
||||
|
||||
Reference in New Issue
Block a user