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));
|
||||
})
|
||||
|
||||
|
||||
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 msgContainer = msgContainerSendTemplate(context);
|
||||
$(chatAreaNew).append(DOMPurify.sanitize(msgContainer));
|
||||
scrollChatAreaAnimated(2400);
|
||||
let messageCipher = sjcl.encrypt(passphraseInput.value, messageContent, { mode: "gcm", ts: 128, adata: "", iter: iterations });
|
||||
let messageCipherJson = JSON.parse(messageCipher);
|
||||
let chatMessageDTO = {
|
||||
@ -326,7 +327,11 @@ function messageSend(chatMessageDTO) {
|
||||
headers: headers,
|
||||
body: chatMessageDTO
|
||||
})
|
||||
.then(response => console.log(response));
|
||||
.then(response => {
|
||||
console.log(response);
|
||||
return response;
|
||||
})
|
||||
.then(response => fetchErrorHandler(response));
|
||||
}
|
||||
|
||||
|
||||
@ -412,3 +417,9 @@ function fetchErrorHandler(response) {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function scrollChatAreaAnimated(delay) {
|
||||
$(chatAreaNew).stop().animate({
|
||||
scrollTop: $(chatAreaNew)[0].scrollHeight
|
||||
}, delay);
|
||||
}
|
Loading…
Reference in New Issue
Block a user