feat: Add pending message on dashboard (#1547)

This commit is contained in:
Nithin David Thomas
2020-12-25 13:15:01 +05:30
committed by GitHub
parent 3e61ea5cfa
commit 7c62d3629c
17 changed files with 260 additions and 53 deletions

View File

@@ -4,6 +4,7 @@ import Vue from 'vue';
import * as types from '../../mutation-types';
import getters, { getSelectedChatConversation } from './getters';
import actions from './actions';
import { findPendingMessageIndex } from './helpers';
import wootConstants from '../../../constants';
const state = {
@@ -85,17 +86,16 @@ export const mutations = {
selectedChatId: conversationId,
});
if (!chat) return;
const previousMessageIndex = chat.messages.findIndex(
m => m.id === message.id
);
if (previousMessageIndex === -1) {
const pendingMessageIndex = findPendingMessageIndex(chat, message);
if (pendingMessageIndex !== -1) {
Vue.set(chat.messages, pendingMessageIndex, message);
} else {
chat.messages.push(message);
chat.timestamp = message.created_at;
if (selectedChatId === conversationId) {
window.bus.$emit('scrollToMessage');
}
} else {
chat.messages[previousMessageIndex] = message;
}
},