@microsoft/omnichannel-chat-widget 0.1.0-main.8e79cb8 → 0.1.0-main.a72fbb6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -0
- package/lib/cjs/common/Constants.js +14 -0
- package/lib/cjs/common/telemetry/TelemetryConstants.js +18 -2
- package/lib/cjs/common/utils.js +49 -3
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +19 -3
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +0 -1
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +10 -1
- package/lib/cjs/components/headerstateful/HeaderStateful.js +2 -2
- package/lib/cjs/components/livechatwidget/common/createMarkdown.js +31 -30
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +11 -2
- package/lib/cjs/components/livechatwidget/common/endChat.js +52 -20
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +16 -3
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +15 -15
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
- package/lib/cjs/components/livechatwidget/common/startChat.js +124 -84
- package/lib/cjs/components/livechatwidget/interfaces/IAuthProps.js +1 -0
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +172 -89
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +4 -8
- package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +17 -1
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +80 -0
- package/lib/cjs/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +14 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +16 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +52 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +98 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +117 -0
- package/lib/cjs/contexts/common/ConversationState.js +3 -2
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +2 -0
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +2 -2
- package/lib/cjs/contexts/createReducer.js +8 -0
- package/lib/cjs/controller/componentController.js +3 -3
- package/lib/esm/common/Constants.js +14 -0
- package/lib/esm/common/telemetry/TelemetryConstants.js +18 -2
- package/lib/esm/common/utils.js +37 -1
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +21 -6
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +0 -1
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +8 -2
- package/lib/esm/components/headerstateful/HeaderStateful.js +2 -2
- package/lib/esm/components/livechatwidget/common/createMarkdown.js +31 -30
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +11 -2
- package/lib/esm/components/livechatwidget/common/endChat.js +53 -20
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +15 -5
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +17 -16
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
- package/lib/esm/components/livechatwidget/common/startChat.js +125 -86
- package/lib/esm/components/livechatwidget/interfaces/IAuthProps.js +1 -0
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +168 -91
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -8
- package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +17 -1
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +72 -0
- package/lib/esm/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +5 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +16 -2
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +41 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +94 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +107 -0
- package/lib/esm/contexts/common/ConversationState.js +3 -2
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +2 -0
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +2 -2
- package/lib/esm/contexts/createReducer.js +8 -0
- package/lib/esm/controller/componentController.js +3 -3
- package/lib/types/common/Constants.d.ts +7 -0
- package/lib/types/common/interfaces/IContextDataStore.d.ts +1 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +18 -3
- package/lib/types/common/telemetry/TelemetryHelper.d.ts +1 -1
- package/lib/types/common/utils.d.ts +3 -0
- package/lib/types/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/endChat.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +5 -4
- package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/startChat.d.ts +4 -2
- package/lib/types/components/livechatwidget/common/startProactiveChat.d.ts +1 -1
- package/lib/types/components/livechatwidget/interfaces/IAuthProps.d.ts +4 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +2 -0
- package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +0 -1
- package/lib/types/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.d.ts +3 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.d.ts +5 -0
- package/lib/types/contexts/common/ConversationState.d.ts +3 -2
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -1
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +3 -1
- package/package.json +2 -2
package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js
CHANGED
|
@@ -105,8 +105,14 @@ const beautifyChatTranscripts = (chatTranscripts, renderMarkDown, attachmentMess
|
|
|
105
105
|
let fileAttachmentName = TranscriptConstants.DefaultFileAttachmentName;
|
|
106
106
|
let dialogColor = TranscriptConstants.CustomerDialogColor;
|
|
107
107
|
let fontColor = TranscriptConstants.CustomerFontColor;
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
const isSystemMessage = value.tags && value.tags.toLowerCase().indexOf(Constants.systemMessageTag) !== -1;
|
|
109
|
+
const isControlMessage = value.isControlMessage && value.isControlMessage === true;
|
|
110
|
+
const isAdaptiveCard = value.contentType && value.contentType.toLowerCase() === TranscriptConstants.AdaptiveCardType;
|
|
111
|
+
const isInternalMessage = value.deliveryMode && value.deliveryMode.toLowerCase() === TranscriptConstants.InternalMode;
|
|
112
|
+
const isHiddenMessage = value.tags && value.tags.toLowerCase().indexOf(Constants.hiddenTag.toLowerCase()) !== -1;
|
|
113
|
+
const shouldIgnoreMessage = isSystemMessage || isControlMessage || isAdaptiveCard || isInternalMessage || isHiddenMessage;
|
|
114
|
+
|
|
115
|
+
if (shouldIgnoreMessage) {
|
|
110
116
|
return;
|
|
111
117
|
} else if (value.from) {
|
|
112
118
|
if (value.from.application) {
|
|
@@ -58,8 +58,8 @@ export const HeaderStateful = props => {
|
|
|
58
58
|
});
|
|
59
59
|
},
|
|
60
60
|
...(headerProps === null || headerProps === void 0 ? void 0 : headerProps.controlProps),
|
|
61
|
-
hideTitle: state.appStates.conversationState === ConversationState.Loading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP = headerProps.controlProps) === null || _headerProps$controlP === void 0 ? void 0 : _headerProps$controlP.hideTitle),
|
|
62
|
-
hideIcon: state.appStates.conversationState === ConversationState.Loading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP2 = headerProps.controlProps) === null || _headerProps$controlP2 === void 0 ? void 0 : _headerProps$controlP2.hideIcon),
|
|
61
|
+
hideTitle: state.appStates.conversationState === ConversationState.Loading || state.appStates.conversationState === ConversationState.PostchatLoading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP = headerProps.controlProps) === null || _headerProps$controlP === void 0 ? void 0 : _headerProps$controlP.hideTitle),
|
|
62
|
+
hideIcon: state.appStates.conversationState === ConversationState.Loading || state.appStates.conversationState === ConversationState.PostchatLoading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP2 = headerProps.controlProps) === null || _headerProps$controlP2 === void 0 ? void 0 : _headerProps$controlP2.hideIcon),
|
|
63
63
|
hideCloseButton: state.appStates.conversationState === ConversationState.Loading || state.appStates.conversationState === ConversationState.Prechat || state.appStates.conversationState === ConversationState.ReconnectChat || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP3 = headerProps.controlProps) === null || _headerProps$controlP3 === void 0 ? void 0 : _headerProps$controlP3.hideCloseButton)
|
|
64
64
|
};
|
|
65
65
|
const outOfOfficeControlProps = {
|
|
@@ -13,26 +13,40 @@ export const createMarkdown = (disableMarkdownMessageFormatting, disableNewLineM
|
|
|
13
13
|
breaks: !disableNewLineMarkdownSupport
|
|
14
14
|
}); // ToDo: Commenting below usage of plugin until deferred bug is resolved: https://github.com/mayashavin/markdown-it-slack/issues/1
|
|
15
15
|
// markdown.use(MarkdownSlack);
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
} else {
|
|
17
|
+
markdown = new MarkdownIt(Constants.Zero, {
|
|
18
|
+
html: true,
|
|
19
|
+
linkify: true,
|
|
20
|
+
breaks: !disableNewLineMarkdownSupport
|
|
21
|
+
});
|
|
22
|
+
markdown.enable(["entity", // Rule to process html entity - {, ¯, "
|
|
23
|
+
"linkify", // Rule to replace link-like texts with link nodes
|
|
24
|
+
"html_block", // Rule to process html blocks and paragraphs
|
|
25
|
+
"html_inline", // Rule to process html tags
|
|
26
|
+
"newline" // Rule to proceess '\n'
|
|
27
|
+
]);
|
|
28
|
+
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
29
|
|
|
19
|
-
markdown.use(MarkdownItForInline, "url_new_win", "link_open", function (tokens, idx, env) {
|
|
20
|
-
const targetAttrIndex = tokens[idx].attrIndex(Constants.Target); // Put a transparent pixel instead of the "open in new window" icon, so developers can easily modify the icon in CSS.
|
|
21
30
|
|
|
22
|
-
|
|
31
|
+
markdown.use(MarkdownItForInline, "url_new_win", "link_open", function (tokens, idx, env) {
|
|
32
|
+
const targetAttrIndex = tokens[idx].attrIndex(Constants.Target); // Put a transparent pixel instead of the "open in new window" icon, so developers can easily modify the icon in CSS.
|
|
23
33
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
34
|
+
const TRANSPARENT_GIF = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
|
|
35
|
+
|
|
36
|
+
if (~targetAttrIndex) {
|
|
37
|
+
tokens[idx].attrs[targetAttrIndex][1] = Constants.Blank;
|
|
38
|
+
} else {
|
|
39
|
+
tokens[idx].attrPush([Constants.Target, Constants.Blank]);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const relAttrIndex = tokens[idx].attrIndex(Constants.TargetRelationship);
|
|
29
43
|
|
|
30
|
-
|
|
44
|
+
if (~relAttrIndex) {
|
|
45
|
+
tokens[idx].attrs[relAttrIndex][1] = Constants.TargetRelationshipAttributes;
|
|
46
|
+
} else {
|
|
47
|
+
tokens[idx].attrPush([Constants.TargetRelationship, Constants.TargetRelationshipAttributes]);
|
|
31
48
|
|
|
32
|
-
if (
|
|
33
|
-
tokens[idx].attrs[relAttrIndex][1] = Constants.TargetRelationshipAttributes;
|
|
34
|
-
} else {
|
|
35
|
-
tokens[idx].attrPush([Constants.TargetRelationship, Constants.TargetRelationshipAttributes]);
|
|
49
|
+
if (!disableMarkdownMessageFormatting) {
|
|
36
50
|
tokens[idx].attrPush([Constants.Title, defaultMarkdownLocalizedTexts.MARKDOWN_EXTERNAL_LINK_ALT]); // eslint-disable-next-line quotes
|
|
37
51
|
|
|
38
52
|
const iconTokens = markdown.parseInline(``, env)[0].children;
|
|
@@ -42,20 +56,7 @@ export const createMarkdown = (disableMarkdownMessageFormatting, disableNewLineM
|
|
|
42
56
|
tokens.splice(idx + 2, 0, ...iconTokens);
|
|
43
57
|
}
|
|
44
58
|
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
markdown = new MarkdownIt(Constants.Zero, {
|
|
48
|
-
html: true,
|
|
49
|
-
linkify: true,
|
|
50
|
-
breaks: !disableNewLineMarkdownSupport
|
|
51
|
-
});
|
|
52
|
-
markdown.enable(["entity", // Rule to process html entity - {, ¯, "
|
|
53
|
-
"linkify", // Rule to replace link-like texts with link nodes
|
|
54
|
-
"html_block", // Rule to process html blocks and paragraphs
|
|
55
|
-
"html_inline", // Rule to process html tags
|
|
56
|
-
"newline" // Rule to proceess '\n'
|
|
57
|
-
]);
|
|
58
|
-
}
|
|
59
|
-
|
|
59
|
+
}
|
|
60
|
+
});
|
|
60
61
|
return markdown;
|
|
61
62
|
};
|
|
@@ -316,7 +316,9 @@ export const dummyDefaultProps = {
|
|
|
316
316
|
hideChatTextContainer: false,
|
|
317
317
|
hideChatSubtitle: false,
|
|
318
318
|
hideChatTitle: false,
|
|
319
|
-
hideNotificationBubble: true
|
|
319
|
+
hideNotificationBubble: true,
|
|
320
|
+
unreadMessageString: "new messages",
|
|
321
|
+
largeUnreadMessageString: "99+"
|
|
320
322
|
},
|
|
321
323
|
styleProps: {
|
|
322
324
|
generalStyleProps: {
|
|
@@ -1411,7 +1413,6 @@ export const dummyDefaultProps = {
|
|
|
1411
1413
|
startNewChatButtonClassName: undefined
|
|
1412
1414
|
}
|
|
1413
1415
|
},
|
|
1414
|
-
authClientFunction: undefined,
|
|
1415
1416
|
isReconnectEnabled: undefined,
|
|
1416
1417
|
reconnectId: undefined,
|
|
1417
1418
|
redirectInSameWindow: undefined
|
|
@@ -1676,7 +1677,15 @@ export const dummyDefaultProps = {
|
|
|
1676
1677
|
MIDDLEWARE_MESSAGE_RETRY: "Retry",
|
|
1677
1678
|
PRECHAT_REQUIRED_FIELD_MISSING_MESSAGE: "{0} field is required",
|
|
1678
1679
|
MARKDOWN_EXTERNAL_LINK_ALT: "Opens in a new window; external."
|
|
1680
|
+
},
|
|
1681
|
+
botMagicCode: {
|
|
1682
|
+
disabled: false,
|
|
1683
|
+
fwdUrl: ""
|
|
1679
1684
|
}
|
|
1680
1685
|
},
|
|
1686
|
+
authProps: {
|
|
1687
|
+
authClientFunction: undefined,
|
|
1688
|
+
setAuthTokenProviderToChatSdk: undefined
|
|
1689
|
+
},
|
|
1681
1690
|
telemetryConfig: undefined
|
|
1682
1691
|
};
|
|
@@ -7,21 +7,38 @@ import { WebChatStoreLoader } from "../../webchatcontainerstateful/webchatcontro
|
|
|
7
7
|
import { defaultWebChatContainerStatefulProps } from "../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps";
|
|
8
8
|
import { PostChatSurveyMode } from "../../postchatsurveypanestateful/enums/PostChatSurveyMode";
|
|
9
9
|
import { Constants } from "../../../common/Constants";
|
|
10
|
-
import { getWidgetEndChatEventName } from "../../../common/utils"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
+
import { addDelayInMs, getWidgetEndChatEventName } from "../../../common/utils"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
11
|
|
|
12
12
|
const prepareEndChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state) => {
|
|
13
|
-
var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4;
|
|
13
|
+
var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4, _conversationDetails;
|
|
14
14
|
|
|
15
15
|
const isPostChatEnabled = (_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.msdyn_postconversationsurveyenable;
|
|
16
|
-
const postChatSurveyMode = (_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : (_state$domainStates$l4 = _state$domainStates$l3.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l4 === void 0 ? void 0 : _state$domainStates$l4.msdyn_postconversationsurveymode;
|
|
17
|
-
const conversationDetails = await chatSDK.getConversationDetails();
|
|
16
|
+
const postChatSurveyMode = (_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : (_state$domainStates$l4 = _state$domainStates$l3.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l4 === void 0 ? void 0 : _state$domainStates$l4.msdyn_postconversationsurveymode; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
let conversationDetails = undefined;
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
conversationDetails = await chatSDK.getConversationDetails();
|
|
22
|
+
} catch (erorr) {
|
|
23
|
+
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
24
|
+
Event: TelemetryEvent.GetConversationDetailsException,
|
|
25
|
+
ExceptionDetails: {
|
|
26
|
+
exception: `Failed to get conversation details: ${erorr}`
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (isPostChatEnabled === "true" && ((_conversationDetails = conversationDetails) === null || _conversationDetails === void 0 ? void 0 : _conversationDetails.canRenderPostChat) === Constants.truePascal) {
|
|
20
32
|
const skipEndChatSDK = false;
|
|
21
33
|
const skipCloseChat = true;
|
|
22
34
|
await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat, true);
|
|
23
35
|
|
|
24
36
|
if (postChatSurveyMode === PostChatSurveyMode.Embed) {
|
|
37
|
+
dispatch({
|
|
38
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
39
|
+
payload: ConversationState.PostchatLoading
|
|
40
|
+
});
|
|
41
|
+
await addDelayInMs(Constants.PostChatLoadingDurationInMs);
|
|
25
42
|
const loadPostChatEvent = {
|
|
26
43
|
eventName: BroadcastEvent.LoadPostChatSurvey
|
|
27
44
|
};
|
|
@@ -32,9 +49,11 @@ const prepareEndChat = async (props, chatSDK, setAdapter, setWebChatStyles, disp
|
|
|
32
49
|
payload: ConversationState.InActive
|
|
33
50
|
});
|
|
34
51
|
}
|
|
35
|
-
|
|
36
|
-
|
|
52
|
+
|
|
53
|
+
return;
|
|
37
54
|
}
|
|
55
|
+
|
|
56
|
+
await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, true);
|
|
38
57
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
58
|
|
|
40
59
|
|
|
@@ -44,16 +63,7 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
|
|
|
44
63
|
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
45
64
|
Event: TelemetryEvent.EndChatSDKCall
|
|
46
65
|
});
|
|
47
|
-
await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat());
|
|
48
|
-
|
|
49
|
-
dispatch({
|
|
50
|
-
type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
51
|
-
payload: undefined
|
|
52
|
-
});
|
|
53
|
-
dispatch({
|
|
54
|
-
type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
55
|
-
payload: undefined
|
|
56
|
-
});
|
|
66
|
+
await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat());
|
|
57
67
|
} catch (ex) {
|
|
58
68
|
TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
|
|
59
69
|
Event: TelemetryEvent.EndChatSDKCallFailed,
|
|
@@ -63,7 +73,21 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
|
|
|
63
73
|
});
|
|
64
74
|
postMessageToOtherTab = false;
|
|
65
75
|
}
|
|
66
|
-
}
|
|
76
|
+
} // Need to clear these states immediately when chat ended from OC.
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
dispatch({
|
|
80
|
+
type: LiveChatWidgetActionType.SET_CUSTOM_CONTEXT,
|
|
81
|
+
payload: undefined
|
|
82
|
+
});
|
|
83
|
+
dispatch({
|
|
84
|
+
type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
85
|
+
payload: undefined
|
|
86
|
+
});
|
|
87
|
+
dispatch({
|
|
88
|
+
type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
89
|
+
payload: undefined
|
|
90
|
+
});
|
|
67
91
|
|
|
68
92
|
if (!skipCloseChat) {
|
|
69
93
|
try {
|
|
@@ -91,8 +115,17 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
|
|
|
91
115
|
type: LiveChatWidgetActionType.SET_AUDIO_NOTIFICATION,
|
|
92
116
|
payload: null
|
|
93
117
|
});
|
|
94
|
-
|
|
95
|
-
|
|
118
|
+
dispatch({
|
|
119
|
+
type: LiveChatWidgetActionType.SET_UNREAD_MESSAGE_COUNT,
|
|
120
|
+
payload: 0
|
|
121
|
+
});
|
|
122
|
+
dispatch({
|
|
123
|
+
type: LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
|
|
124
|
+
payload: {
|
|
125
|
+
proactiveChatBodyTitle: "",
|
|
126
|
+
proactiveChatEnablePrechat: false,
|
|
127
|
+
proactiveChatInNewWindow: false
|
|
128
|
+
}
|
|
96
129
|
});
|
|
97
130
|
|
|
98
131
|
if (postMessageToOtherTab) {
|
|
@@ -7,7 +7,7 @@ import { PostChatSurveyMode } from "../../postchatsurveypanestateful/enums/PostC
|
|
|
7
7
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
8
8
|
import { WebChatStoreLoader } from "../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader";
|
|
9
9
|
import attachmentProcessingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware";
|
|
10
|
-
import { changeLanguageCodeFormatForWebChat } from "../../../common/utils";
|
|
10
|
+
import { addDelayInMs, changeLanguageCodeFormatForWebChat } from "../../../common/utils";
|
|
11
11
|
import channelDataMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware";
|
|
12
12
|
import { createActivityMiddleware } from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware";
|
|
13
13
|
import createAttachmentMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware";
|
|
@@ -26,10 +26,13 @@ import gifUploadMiddleware from "../../webchatcontainerstateful/webchatcontrolle
|
|
|
26
26
|
import htmlPlayerMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlPlayerMiddleware";
|
|
27
27
|
import htmlTextMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware";
|
|
28
28
|
import preProcessingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware";
|
|
29
|
-
import sanitizationMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware";
|
|
29
|
+
import sanitizationMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware";
|
|
30
|
+
import { createCardActionMiddleware } from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware";
|
|
31
|
+
import createMessageTimeStampMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware";
|
|
32
|
+
import { Constants } from "../../../common/Constants"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
33
|
|
|
31
34
|
export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles) => {
|
|
32
|
-
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4, _state$domainStates$l8, _state$domainStates$l9, _props$webChatContain7, _props$webChatContain8, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain9, _props$webChatContain10, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain11, _props$webChatContain12, _defaultWebChatContai, _props$webChatContain13, _props$webChatContain14, _props$webChatContain15, _props$webChatContain16, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain17, _props$webChatContain18, _defaultWebChatContai2, _props$webChatContain19, _props$webChatContain20, _defaultWebChatContai3, _props$webChatContain21;
|
|
35
|
+
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4, _state$domainStates$l8, _state$domainStates$l9, _props$webChatContain7, _props$webChatContain8, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain9, _props$webChatContain10, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain11, _props$webChatContain12, _defaultWebChatContai, _props$webChatContain13, _props$webChatContain14, _props$webChatContain15, _props$webChatContain16, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain17, _props$webChatContain18, _defaultWebChatContai2, _props$webChatContain19, _props$webChatContain20, _defaultWebChatContai3, _props$webChatContain21, _props$webChatContain22;
|
|
33
36
|
|
|
34
37
|
const localizedTexts = { ...defaultMiddlewareLocalizedTexts,
|
|
35
38
|
...((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.localizedTexts)
|
|
@@ -63,6 +66,12 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
|
|
|
63
66
|
|
|
64
67
|
if (isPostChatEnabled === "true") {
|
|
65
68
|
if (postChatSurveyMode === PostChatSurveyMode.Embed) {
|
|
69
|
+
WebChatStoreLoader.store = null;
|
|
70
|
+
dispatch({
|
|
71
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
72
|
+
payload: ConversationState.PostchatLoading
|
|
73
|
+
});
|
|
74
|
+
await addDelayInMs(Constants.PostChatLoadingDurationInMs);
|
|
66
75
|
const loadPostChatEvent = {
|
|
67
76
|
eventName: BroadcastEvent.LoadPostChatSurvey
|
|
68
77
|
};
|
|
@@ -91,7 +100,7 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
|
|
|
91
100
|
};
|
|
92
101
|
|
|
93
102
|
webChatStore = createStore({}, //initial state
|
|
94
|
-
preProcessingMiddleware, attachmentProcessingMiddleware, createAttachmentUploadValidatorMiddleware((_state$domainStates$l5 = state.domainStates.liveChatConfig) === null || _state$domainStates$l5 === void 0 ? void 0 : _state$domainStates$l5.allowedFileExtensions, (_state$domainStates$l6 = state.domainStates.liveChatConfig) === null || _state$domainStates$l6 === void 0 ? void 0 : _state$domainStates$l6.maxUploadFileSize, localizedTexts), channelDataMiddleware, createConversationEndMiddleware(conversationEndCallback), createDataMaskingMiddleware((_state$domainStates$l7 = state.domainStates.liveChatConfig) === null || _state$domainStates$l7 === void 0 ? void 0 : _state$domainStates$l7.DataMaskingInfo), gifUploadMiddleware, htmlPlayerMiddleware, htmlTextMiddleware, createMaxMessageSizeValidator(localizedTexts), sanitizationMiddleware, // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
103
|
+
preProcessingMiddleware, attachmentProcessingMiddleware, createAttachmentUploadValidatorMiddleware((_state$domainStates$l5 = state.domainStates.liveChatConfig) === null || _state$domainStates$l5 === void 0 ? void 0 : _state$domainStates$l5.allowedFileExtensions, (_state$domainStates$l6 = state.domainStates.liveChatConfig) === null || _state$domainStates$l6 === void 0 ? void 0 : _state$domainStates$l6.maxUploadFileSize, localizedTexts), channelDataMiddleware, createConversationEndMiddleware(conversationEndCallback), createDataMaskingMiddleware((_state$domainStates$l7 = state.domainStates.liveChatConfig) === null || _state$domainStates$l7 === void 0 ? void 0 : _state$domainStates$l7.DataMaskingInfo), createMessageTimeStampMiddleware, gifUploadMiddleware, htmlPlayerMiddleware, htmlTextMiddleware, createMaxMessageSizeValidator(localizedTexts), sanitizationMiddleware, // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
95
104
|
...(((_props$webChatContain6 = props.webChatContainerProps) === null || _props$webChatContain6 === void 0 ? void 0 : _props$webChatContain6.storeMiddlewares) ?? []));
|
|
96
105
|
WebChatStoreLoader.store = webChatStore;
|
|
97
106
|
} // Initialize the remaining Web Chat props
|
|
@@ -109,7 +118,8 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
|
|
|
109
118
|
groupActivitiesMiddleware: (_props$webChatContain17 = props.webChatContainerProps) !== null && _props$webChatContain17 !== void 0 && (_props$webChatContain18 = _props$webChatContain17.renderingMiddlewareProps) !== null && _props$webChatContain18 !== void 0 && _props$webChatContain18.disableGroupActivitiesMiddleware ? undefined : (_defaultWebChatContai2 = defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai2 === void 0 ? void 0 : _defaultWebChatContai2.groupActivitiesMiddleware,
|
|
110
119
|
typingIndicatorMiddleware: (_props$webChatContain19 = props.webChatContainerProps) !== null && _props$webChatContain19 !== void 0 && (_props$webChatContain20 = _props$webChatContain19.renderingMiddlewareProps) !== null && _props$webChatContain20 !== void 0 && _props$webChatContain20.disableTypingIndicatorMiddleware ? undefined : (_defaultWebChatContai3 = defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai3 === void 0 ? void 0 : _defaultWebChatContai3.typingIndicatorMiddleware,
|
|
111
120
|
onTelemetry: createWebChatTelemetry(),
|
|
112
|
-
|
|
121
|
+
cardActionMiddleware: createCardActionMiddleware(((_props$webChatContain21 = props.webChatContainerProps) === null || _props$webChatContain21 === void 0 ? void 0 : _props$webChatContain21.botMagicCode) || undefined),
|
|
122
|
+
...((_props$webChatContain22 = props.webChatContainerProps) === null || _props$webChatContain22 === void 0 ? void 0 : _props$webChatContain22.webChatProps)
|
|
113
123
|
};
|
|
114
124
|
return webChatProps;
|
|
115
125
|
};
|
|
@@ -3,8 +3,9 @@ import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/teleme
|
|
|
3
3
|
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
4
4
|
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
5
5
|
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
6
|
-
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
6
|
+
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
7
7
|
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
9
|
const getChatReconnectContext = async (chatSDK, reconnectId) => {
|
|
9
10
|
try {
|
|
10
11
|
if (reconnectId) {
|
|
@@ -29,9 +30,9 @@ const getChatReconnectContext = async (chatSDK, reconnectId) => {
|
|
|
29
30
|
|
|
30
31
|
|
|
31
32
|
const getReconnectIdForAuthenticatedChat = async (props, chatSDK) => {
|
|
32
|
-
var _props$reconnectChatP, _props$
|
|
33
|
+
var _props$reconnectChatP, _props$authProps;
|
|
33
34
|
|
|
34
|
-
if ((_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.isReconnectEnabled && (_props$
|
|
35
|
+
if ((_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.isReconnectEnabled && (_props$authProps = props.authProps) !== null && _props$authProps !== void 0 && _props$authProps.authClientFunction // TODO: Implement this after storage is in place
|
|
35
36
|
|
|
36
37
|
/* && !isLoadWithState() */
|
|
37
38
|
) {
|
|
@@ -46,27 +47,27 @@ const getReconnectIdForAuthenticatedChat = async (props, chatSDK) => {
|
|
|
46
47
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
48
|
|
|
48
49
|
|
|
49
|
-
const handleUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat, redirectInSameWindow) => {
|
|
50
|
+
const handleUnauthenticatedReconnectChat = async (chatSDK, authProps, dispatch, setAdapter, reconnectId, initStartChat, redirectInSameWindow) => {
|
|
50
51
|
const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
|
|
51
52
|
|
|
52
53
|
if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
|
|
53
|
-
await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow);
|
|
54
|
+
await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, authProps, dispatch, setAdapter, initStartChat, redirectInSameWindow);
|
|
54
55
|
} else {
|
|
55
|
-
await setReconnectIdAndStartChat(chatSDK, dispatch, setAdapter, reconnectId, initStartChat);
|
|
56
|
+
await setReconnectIdAndStartChat(chatSDK, authProps, dispatch, setAdapter, reconnectId, initStartChat);
|
|
56
57
|
}
|
|
57
58
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
58
59
|
|
|
59
60
|
|
|
60
|
-
const startUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat) => {
|
|
61
|
+
const startUnauthenticatedReconnectChat = async (chatSDK, authProps, dispatch, setAdapter, reconnectId, initStartChat) => {
|
|
61
62
|
const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
|
|
62
63
|
|
|
63
64
|
if (!shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
|
|
64
|
-
await setReconnectIdAndStartChat(chatSDK, dispatch, setAdapter, reconnectId, initStartChat);
|
|
65
|
+
await setReconnectIdAndStartChat(chatSDK, authProps, dispatch, setAdapter, reconnectId, initStartChat);
|
|
65
66
|
}
|
|
66
67
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
67
68
|
|
|
68
69
|
|
|
69
|
-
const setReconnectIdAndStartChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat) => {
|
|
70
|
+
const setReconnectIdAndStartChat = async (chatSDK, authProps, dispatch, setAdapter, reconnectId, initStartChat) => {
|
|
70
71
|
const startUnauthenticatedReconnectChat = {
|
|
71
72
|
eventName: BroadcastEvent.StartUnauthenticatedReconnectChat
|
|
72
73
|
};
|
|
@@ -82,7 +83,7 @@ const setReconnectIdAndStartChat = async (chatSDK, dispatch, setAdapter, reconne
|
|
|
82
83
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
83
84
|
payload: ConversationState.Loading
|
|
84
85
|
});
|
|
85
|
-
await initStartChat(chatSDK, dispatch, setAdapter, optionalParams);
|
|
86
|
+
await initStartChat(chatSDK, authProps, dispatch, setAdapter, optionalParams);
|
|
86
87
|
};
|
|
87
88
|
|
|
88
89
|
const redirectPage = (redirectURL, redirectInSameWindow) => {
|
|
@@ -104,7 +105,7 @@ const shouldRedirectOrStartNewChat = reconnectAvailabilityResponse => {
|
|
|
104
105
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
105
106
|
|
|
106
107
|
|
|
107
|
-
const startNewChatEmptyRedirectionUrl = async (chatSDK, dispatch, setAdapter, initStartChat) => {
|
|
108
|
+
const startNewChatEmptyRedirectionUrl = async (chatSDK, authProps, dispatch, setAdapter, initStartChat) => {
|
|
108
109
|
const startUnauthenticatedReconnectChat = {
|
|
109
110
|
eventName: BroadcastEvent.StartUnauthenticatedReconnectChat
|
|
110
111
|
};
|
|
@@ -127,25 +128,25 @@ const startNewChatEmptyRedirectionUrl = async (chatSDK, dispatch, setAdapter, in
|
|
|
127
128
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
128
129
|
payload: ConversationState.Loading
|
|
129
130
|
});
|
|
130
|
-
await initStartChat(chatSDK, dispatch, setAdapter);
|
|
131
|
+
await initStartChat(chatSDK, authProps, dispatch, setAdapter);
|
|
131
132
|
}
|
|
132
133
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
133
134
|
|
|
134
135
|
|
|
135
|
-
const handleRedirectUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, initStartChat, reconnectId, redirectInSameWindow) => {
|
|
136
|
+
const handleRedirectUnauthenticatedReconnectChat = async (chatSDK, authProps, dispatch, setAdapter, initStartChat, reconnectId, redirectInSameWindow) => {
|
|
136
137
|
const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
|
|
137
138
|
|
|
138
139
|
if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
|
|
139
|
-
await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow);
|
|
140
|
+
await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, authProps, dispatch, setAdapter, initStartChat, redirectInSameWindow);
|
|
140
141
|
}
|
|
141
142
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
142
143
|
|
|
143
144
|
|
|
144
|
-
const redirectOrStartNewChat = async (reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow) => {
|
|
145
|
+
const redirectOrStartNewChat = async (reconnectAvailabilityResponse, chatSDK, authProps, dispatch, setAdapter, initStartChat, redirectInSameWindow) => {
|
|
145
146
|
if (reconnectAvailabilityResponse.redirectURL) {
|
|
146
147
|
redirectPage(reconnectAvailabilityResponse.redirectURL, redirectInSameWindow);
|
|
147
148
|
} else {
|
|
148
|
-
await startNewChatEmptyRedirectionUrl(chatSDK, dispatch, setAdapter, initStartChat);
|
|
149
|
+
await startNewChatEmptyRedirectionUrl(chatSDK, authProps, dispatch, setAdapter, initStartChat);
|
|
149
150
|
}
|
|
150
151
|
};
|
|
151
152
|
|
|
@@ -29,10 +29,6 @@ export const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, persist
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
BroadcastService.getMessageByEventName("LoadPostChatSurvey").subscribe(msg => {
|
|
32
|
-
dispatch({
|
|
33
|
-
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
34
|
-
payload: ConversationState.Loading
|
|
35
|
-
});
|
|
36
32
|
dispatch({
|
|
37
33
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
38
34
|
payload: ConversationState.Postchat
|