quiq-chat
Advanced tools
Comparing version 1.26.0 to 1.27.0
{ | ||
"name": "quiq-chat", | ||
"version": "1.26.0", | ||
"version": "1.27.0", | ||
"description": "Library to help with network requests to create a webchat client for Quiq Messaging", | ||
@@ -5,0 +5,0 @@ "main": "build/quiq-chat.js", |
@@ -7,2 +7,3 @@ // @flow | ||
ATTACHMENT: 'Attachment', | ||
FAILED: 'Failed', | ||
CHAT_MESSAGE: 'ChatMessage', | ||
@@ -9,0 +10,0 @@ JOIN: 'Join', |
@@ -88,2 +88,7 @@ // @flow | ||
onMessageSendFailure = (callback: (messageId: string) => void): QuiqChatClient => { | ||
this.callbacks.onMessageSendFailure = callback; | ||
return this; | ||
}; | ||
onAgentTyping = (callback: (typing: boolean) => void): QuiqChatClient => { | ||
@@ -257,3 +262,2 @@ this.callbacks.onAgentTyping = callback; | ||
} catch (e) { | ||
// Remove temporary attachment message, since this upload failed | ||
log.error(`An error sending attachment message: ${e.message}`, {exception: e}); | ||
@@ -411,2 +415,5 @@ throw e; | ||
break; | ||
case MessageTypes.FAILED: | ||
this._handleMessageFailure(message.data.id); | ||
break; | ||
case MessageTypes.JOIN: | ||
@@ -485,2 +492,15 @@ case MessageTypes.LEAVE: | ||
_handleMessageFailure = (failedMessageId: string) => { | ||
// Remove failed message and fire onMessageFailure callback | ||
const failedIdx = this.messages.findIndex(m => m.id === failedMessageId); | ||
if (failedIdx > -1) { | ||
// NOTE: splice mutates original array | ||
this.messages.splice(failedIdx, 1); | ||
} | ||
if (this.callbacks.onMessageSendFailure) { | ||
this.callbacks.onMessageSendFailure(failedMessageId); | ||
} | ||
}; | ||
_processNewMessages = ( | ||
@@ -487,0 +507,0 @@ newMessages: Array<ConversationMessage>, |
@@ -14,5 +14,7 @@ // @flow | ||
const form = new FormData(); | ||
// NOTE: This order is important! | ||
additionalFields.forEach(field => { | ||
form.append(field.name, field.value); | ||
}); | ||
form.append('Content-Type', file.type); | ||
form.append('file', file); | ||
@@ -34,4 +36,5 @@ | ||
if (req.status !== 200) { | ||
log.info(`Upload to S3 failed with code ${req.status}`); | ||
reject(); | ||
const error = `Upload to S3 failed with code ${req.status}`; | ||
log.info(error); | ||
reject(new Error(error)); | ||
} else { | ||
@@ -42,7 +45,9 @@ resolve(); | ||
req.addEventListener('abort', () => { | ||
log.info('S3 attachment upload aborted'); | ||
reject(); | ||
const error = 'S3 upload was aborted'; | ||
log.info(error); | ||
reject(new Error(error)); | ||
}); | ||
req.addEventListener('error', () => { | ||
log.error(`An error occurred uploading an attachment to S3`, { | ||
const error = 'An error occurred uploading attachment to S3'; | ||
log.error(error, { | ||
data: { | ||
@@ -55,3 +60,3 @@ requestStatus: req.statusText, | ||
}); | ||
reject(); | ||
reject(new Error(error)); | ||
}); | ||
@@ -58,0 +63,0 @@ |
@@ -43,2 +43,3 @@ // @flow | ||
onAgentTyping?: (typing: boolean) => void, | ||
onMessageSendFailure?: (messageId: string) => void, | ||
onError?: (error: ?ApiError) => void, | ||
@@ -45,0 +46,0 @@ onRetryableError?: (error: ?ApiError) => void, |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1927268
141
11838