quiq-chat
Advanced tools
Comparing version 1.58.1 to 1.59.0
{ | ||
"name": "quiq-chat", | ||
"version": "1.58.1", | ||
"version": "1.59.0", | ||
"descri1tion": | ||
@@ -5,0 +5,0 @@ "Library to help with network requests to create a webchat client for Quiq Messaging", |
@@ -35,2 +35,10 @@ // @flow | ||
export const noAgentsAvailableClass = 'noAgentsAvailable'; | ||
export const MessageFailureCodes = { | ||
/* eslint-disable no-useless-computed-key */ // Flow can't have numeric keys, so we have to compute these | ||
[11001]: 'UNKNOWN', | ||
[11002]: 'INFECTED_UPLOAD', | ||
[11003]: 'CONTENT_TYPE_NOT_ALLOWED', | ||
[11004]: 'UPLOAD_NOT_FOUND', | ||
[11005]: 'EMPTY_UPLOAD', | ||
/* eslint-enable no-useless-computed-key */ | ||
}; |
@@ -34,2 +34,3 @@ // @flow | ||
Author, | ||
MessageFailureData, | ||
} from './types'; | ||
@@ -41,2 +42,3 @@ import {setFetchMode} from 'quiqFetch'; | ||
import Raven from 'raven-js'; | ||
import {MessageFailureCodes} from 'appConstants'; | ||
@@ -118,3 +120,5 @@ Senty.init(); | ||
onMessageSendFailure = (callback: (messageId: string) => void): QuiqChatClient => { | ||
onMessageSendFailure = ( | ||
callback: (messageId: string, data: MessageFailureData) => void, | ||
): QuiqChatClient => { | ||
this.callbacks.onMessageSendFailure = callback; | ||
@@ -276,3 +280,3 @@ return this; | ||
} catch (e) { | ||
log.error(`An error sending attachment message: ${e.message}`, {exception: e}); | ||
log.error(`An occurred error sending attachment message: ${e.message}`, {exception: e}); | ||
throw e; | ||
@@ -491,3 +495,3 @@ } | ||
case MessageTypes.FAILED: | ||
this._handleMessageFailure(message.data.id); | ||
this._handleMessageFailure(message.data.id, message.data.errorCode); | ||
break; | ||
@@ -568,3 +572,3 @@ case MessageTypes.JOIN: | ||
_handleMessageFailure = (failedMessageId: string) => { | ||
_handleMessageFailure = (failedMessageId: string, code: number) => { | ||
// Remove failed message and fire onMessageFailure callback | ||
@@ -578,3 +582,5 @@ const failedIdx = this.messages.findIndex(m => m.id === failedMessageId); | ||
if (this.callbacks.onMessageSendFailure) { | ||
this.callbacks.onMessageSendFailure(failedMessageId); | ||
this.callbacks.onMessageSendFailure(failedMessageId, { | ||
reason: MessageFailureCodes[code] || 'UNKNOWN', | ||
}); | ||
} | ||
@@ -581,0 +587,0 @@ }; |
@@ -59,2 +59,6 @@ // @flow | ||
export type MessageFailureData = { | ||
reason: string, | ||
}; | ||
export type QuiqChatCallbacks = { | ||
@@ -64,3 +68,3 @@ onNewMessages?: (messages: Array<ConversationMessage>) => void, | ||
onAgentTyping?: (typing: boolean, author: Author) => void, | ||
onMessageSendFailure?: (messageId: string) => void, | ||
onMessageSendFailure?: (messageId: string, data: MessageFailureData) => void, | ||
onError?: (error: ?ApiError) => void, | ||
@@ -67,0 +71,0 @@ onErrorResolved?: () => 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 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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1890904
144
7693