added error handling to message sending
This commit is contained in:
parent
f95b14d4e9
commit
4b20c33ec1
@ -235,7 +235,7 @@ function populateMessages(userName, passphrase) {
|
|||||||
$(chatAreaNew).append(DOMPurify.sanitize(msgContainer));
|
$(chatAreaNew).append(DOMPurify.sanitize(msgContainer));
|
||||||
})
|
})
|
||||||
|
|
||||||
|
scrollChatAreaAnimated(2400);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -301,6 +301,7 @@ document.getElementById('chatMessageForm').addEventListener('submit', function(e
|
|||||||
let context = { fromUser: username, message: md.render(messageContent), time: new Date().toLocaleString() };
|
let context = { fromUser: username, message: md.render(messageContent), time: new Date().toLocaleString() };
|
||||||
let msgContainer = msgContainerSendTemplate(context);
|
let msgContainer = msgContainerSendTemplate(context);
|
||||||
$(chatAreaNew).append(DOMPurify.sanitize(msgContainer));
|
$(chatAreaNew).append(DOMPurify.sanitize(msgContainer));
|
||||||
|
scrollChatAreaAnimated(2400);
|
||||||
let messageCipher = sjcl.encrypt(passphraseInput.value, messageContent, { mode: "gcm", ts: 128, adata: "", iter: iterations });
|
let messageCipher = sjcl.encrypt(passphraseInput.value, messageContent, { mode: "gcm", ts: 128, adata: "", iter: iterations });
|
||||||
let messageCipherJson = JSON.parse(messageCipher);
|
let messageCipherJson = JSON.parse(messageCipher);
|
||||||
let chatMessageDTO = {
|
let chatMessageDTO = {
|
||||||
@ -326,7 +327,11 @@ function messageSend(chatMessageDTO) {
|
|||||||
headers: headers,
|
headers: headers,
|
||||||
body: chatMessageDTO
|
body: chatMessageDTO
|
||||||
})
|
})
|
||||||
.then(response => console.log(response));
|
.then(response => {
|
||||||
|
console.log(response);
|
||||||
|
return response;
|
||||||
|
})
|
||||||
|
.then(response => fetchErrorHandler(response));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -411,4 +416,10 @@ function fetchErrorHandler(response) {
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function scrollChatAreaAnimated(delay) {
|
||||||
|
$(chatAreaNew).stop().animate({
|
||||||
|
scrollTop: $(chatAreaNew)[0].scrollHeight
|
||||||
|
}, delay);
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user