|
|
@ -1,6 +1,7 @@
|
|
|
|
import { initIncomingMessage } from './dataMessage';
|
|
|
|
import { initIncomingMessage } from './dataMessage';
|
|
|
|
import { toNumber } from 'lodash';
|
|
|
|
import { toNumber } from 'lodash';
|
|
|
|
import { ConversationController } from '../session/conversations';
|
|
|
|
import { ConversationController } from '../session/conversations';
|
|
|
|
|
|
|
|
import { MessageController } from '../session/messages';
|
|
|
|
|
|
|
|
|
|
|
|
export async function onError(ev: any) {
|
|
|
|
export async function onError(ev: any) {
|
|
|
|
const { error } = ev;
|
|
|
|
const { error } = ev;
|
|
|
@ -10,14 +11,6 @@ export async function onError(ev: any) {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
if (ev.proto) {
|
|
|
|
if (ev.proto) {
|
|
|
|
if (error && error.name === 'MessageCounterError') {
|
|
|
|
|
|
|
|
if (ev.confirm) {
|
|
|
|
|
|
|
|
ev.confirm();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ignore this message. It is likely a duplicate delivery
|
|
|
|
|
|
|
|
// because the server lost our ack the first time.
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
const envelope = ev.proto;
|
|
|
|
const envelope = ev.proto;
|
|
|
|
|
|
|
|
|
|
|
|
const message = initIncomingMessage(envelope);
|
|
|
|
const message = initIncomingMessage(envelope);
|
|
|
@ -41,6 +34,12 @@ export async function onError(ev: any) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
conversation.updateLastMessage();
|
|
|
|
conversation.updateLastMessage();
|
|
|
|
|
|
|
|
MessageController.getInstance().register(message.id, message);
|
|
|
|
|
|
|
|
window.Whisper.events.trigger('messageAdded', {
|
|
|
|
|
|
|
|
conversationKey: conversation.id,
|
|
|
|
|
|
|
|
messageModel: message,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
conversation.notify(message);
|
|
|
|
conversation.notify(message);
|
|
|
|
|
|
|
|
|
|
|
|
if (ev.confirm) {
|
|
|
|
if (ev.confirm) {
|
|
|
|