trigger new message onError while handling a request

pull/1495/head
Audric Ackermann 4 years ago
parent 7054385d4a
commit 1d85a6dc5f
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -1,6 +1,7 @@
import { initIncomingMessage } from './dataMessage';
import { toNumber } from 'lodash';
import { ConversationController } from '../session/conversations';
import { MessageController } from '../session/messages';
export async function onError(ev: any) {
const { error } = ev;
@ -10,19 +11,11 @@ export async function onError(ev: any) {
);
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 message = initIncomingMessage(envelope);
message.saveErrors(error || new Error('Error was null'));
await message.saveErrors(error || new Error('Error was null'));
const id = message.get('conversationId');
const conversation = await ConversationController.getInstance().getOrCreateAndWait(
id,
@ -42,6 +35,12 @@ export async function onError(ev: any) {
conversation.updateLastMessage();
await conversation.notify(message);
MessageController.getInstance().register(message.id, message);
window.Whisper.events.trigger('messageAdded', {
conversationKey: conversation.id,
messageModel: message,
});
if (ev.confirm) {
ev.confirm();

Loading…
Cancel
Save