botframework-webchat-core 4.14.0 → 4.15.1
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/.eslintrc.yml +4 -198
- package/.prettierrc.yml +1 -1
- package/lib/actions/setNotification.js +1 -1
- package/lib/createPromiseQueue.js +1 -1
- package/lib/createStore.d.ts.map +1 -1
- package/lib/createStore.js +5 -5
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +15 -3
- package/lib/reducers/activities.js +1 -1
- package/lib/reducers/clockSkewAdjustment.js +1 -1
- package/lib/reducers/lastTypingAt.js +1 -1
- package/lib/reducers/notifications.js +21 -14
- package/lib/reducers/typing.js +1 -1
- package/lib/sagas/connectSaga.js +14 -8
- package/lib/sagas/connectionStatusToNotificationSaga.js +1 -1
- package/lib/sagas/effects/forkPut.js +1 -1
- package/lib/sagas/markAllAsSpokenOnStopSpeakActivitySaga.js +1 -1
- package/lib/sagas/observeActivitySaga.js +1 -1
- package/lib/sagas/postActivitySaga.js +1 -1
- package/lib/sagas/queueIncomingActivitySaga.js +7 -3
- package/lib/sagas/sendMessageBackToPostActivitySaga.js +1 -1
- package/lib/sagas/sendTypingIndicatorOnSetSendBoxSaga.js +1 -1
- package/lib/sagas/speakActivityAndStartDictateOnIncomingActivityFromOthersSaga.js +1 -1
- package/lib/sagas/startSpeakActivityOnPostActivitySaga.js +1 -1
- package/lib/sagas/stopSpeakingActivityOnInputSaga.js +1 -1
- package/lib/sagas/submitSendBoxSaga.js +1 -1
- package/lib/selectors/combineSelectors.js +8 -3
- package/lib/types/external/DirectLineActivity.d.ts +1 -1
- package/lib/types/external/DirectLineActivity.d.ts.map +1 -1
- package/lib/types/external/DirectLineCardAction.d.ts +108 -1
- package/lib/types/external/DirectLineCardAction.d.ts.map +1 -1
- package/lib/utils/deleteKey.js +2 -3
- package/lib/utils/isForbiddenPropertyName.d.ts +2 -0
- package/lib/utils/isForbiddenPropertyName.d.ts.map +1 -0
- package/lib/utils/isForbiddenPropertyName.js +21 -0
- package/lib/utils/mime-wrapper.js +2 -4
- package/lib/utils/uniqueID.js +1 -1
- package/package.json +15 -22
- package/src/__tests__/detectSlowConnectionSaga.spec.js +1 -1
- package/src/__tests__/observeOnce.spec.js +3 -3
- package/src/actions/setNotification.js +8 -2
- package/src/createStore.ts +4 -4
- package/src/index.ts +2 -0
- package/src/reducers/notifications.js +22 -16
- package/src/sagas/connectSaga.js +9 -2
- package/src/sagas/connectionStatusToNotificationSaga.js +1 -1
- package/src/sagas/queueIncomingActivitySaga.js +40 -39
- package/src/sagas/sendMessageBackToPostActivitySaga.js +0 -1
- package/src/sagas/sendTypingIndicatorOnSetSendBoxSaga.js +1 -1
- package/src/sagas/speakActivityAndStartDictateOnIncomingActivityFromOthersSaga.js +1 -1
- package/src/sagas/startSpeakActivityOnPostActivitySaga.js +1 -1
- package/src/sagas/stopSpeakingActivityOnInputSaga.js +1 -1
- package/src/sagas/submitSendBoxSaga.js +1 -1
- package/src/selectors/combineSelectors.js +9 -1
- package/src/types/external/DirectLineActivity.ts +3 -1
- package/src/types/external/DirectLineCardAction.ts +125 -2
- package/src/utils/dateToLocaleISOString.chatham.spec.js +1 -0
- package/src/utils/dateToLocaleISOString.japan.spec.js +1 -0
- package/src/utils/dateToLocaleISOString.pacific.spec.js +1 -0
- package/src/utils/dateToLocaleISOString.utc.spec.js +2 -0
- package/src/utils/deleteKey.js +1 -3
- package/src/utils/isForbiddenPropertyName.spec.js +6 -0
- package/src/utils/isForbiddenPropertyName.ts +33 -0
- package/src/utils/mime-wrapper.js +1 -2
- package/src/utils/uniqueID.js +1 -6
- package/.eslintignore +0 -9
|
@@ -1,3 +1,110 @@
|
|
|
1
|
-
declare type
|
|
1
|
+
declare type CardActionWithImageAndTitle = {
|
|
2
|
+
image: string;
|
|
3
|
+
} | {
|
|
4
|
+
title: string;
|
|
5
|
+
} | {
|
|
6
|
+
image: string;
|
|
7
|
+
title: string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* A `call` action represents a telephone number that may be called.
|
|
11
|
+
*
|
|
12
|
+
* https://github.com/Microsoft/botframework-sdk/blob/main/specs/botframework-activity/botframework-activity.md#call
|
|
13
|
+
*/
|
|
14
|
+
declare type CallCardAction = CardActionWithImageAndTitle & {
|
|
15
|
+
type: 'call';
|
|
16
|
+
value: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* A `downloadFile` action represents a hyperlink to be downloaded.
|
|
20
|
+
*
|
|
21
|
+
* https://github.com/Microsoft/botframework-sdk/blob/main/specs/botframework-activity/botframework-activity.md#download-file-actions
|
|
22
|
+
*/
|
|
23
|
+
declare type DownloadFileCardAction = CardActionWithImageAndTitle & {
|
|
24
|
+
type: 'downloadFile';
|
|
25
|
+
value: string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* An `imBack` action represents a text response that is added to the chat feed.
|
|
29
|
+
*
|
|
30
|
+
* https://github.com/Microsoft/botframework-sdk/blob/main/specs/botframework-activity/botframework-activity.md#im-back
|
|
31
|
+
*/
|
|
32
|
+
declare type IMBackCardAction = CardActionWithImageAndTitle & {
|
|
33
|
+
type: 'imBack';
|
|
34
|
+
value: string;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* A `messageBack` action represents a text response to be sent via the chat system.
|
|
38
|
+
*
|
|
39
|
+
* https://github.com/Microsoft/botframework-sdk/blob/main/specs/botframework-activity/botframework-activity.md#message-back
|
|
40
|
+
*/
|
|
41
|
+
declare type MessageBackCardAction = CardActionWithImageAndTitle & {
|
|
42
|
+
displayText?: string;
|
|
43
|
+
text?: string;
|
|
44
|
+
type: 'messageBack';
|
|
45
|
+
value?: {
|
|
46
|
+
[key: string]: any;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* An `openUrl` action represents a hyperlink to be handled by the client.
|
|
51
|
+
*
|
|
52
|
+
* https://github.com/Microsoft/botframework-sdk/blob/main/specs/botframework-activity/botframework-activity.md#open-url-actions
|
|
53
|
+
*/
|
|
54
|
+
declare type OpenURLCardAction = CardActionWithImageAndTitle & {
|
|
55
|
+
type: 'openUrl';
|
|
56
|
+
value: string;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* A `playAudio` action represents audio media that may be played.
|
|
60
|
+
*
|
|
61
|
+
* https://github.com/Microsoft/botframework-sdk/blob/main/specs/botframework-activity/botframework-activity.md#play-audio
|
|
62
|
+
*/
|
|
63
|
+
declare type PlayAudioCardAction = CardActionWithImageAndTitle & {
|
|
64
|
+
type: 'playAudio';
|
|
65
|
+
value: string;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* A `playVideo` action represents video media that may be played.
|
|
69
|
+
*
|
|
70
|
+
* https://github.com/Microsoft/botframework-sdk/blob/main/specs/botframework-activity/botframework-activity.md#play-video
|
|
71
|
+
*/
|
|
72
|
+
declare type PlayVideoCardAction = CardActionWithImageAndTitle & {
|
|
73
|
+
type: 'playVideo';
|
|
74
|
+
value: string;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* A `postBack` action represents a text response that is not added to the chat feed.
|
|
78
|
+
*
|
|
79
|
+
* https://github.com/Microsoft/botframework-sdk/blob/main/specs/botframework-activity/botframework-activity.md#post-back
|
|
80
|
+
*/
|
|
81
|
+
declare type PostBackCardAction = CardActionWithImageAndTitle & {
|
|
82
|
+
type: 'postBack';
|
|
83
|
+
value: any;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* A `showImage` action represents an image that may be displayed.
|
|
87
|
+
*
|
|
88
|
+
* https://github.com/Microsoft/botframework-sdk/blob/main/specs/botframework-activity/botframework-activity.md#show-image-file-actions
|
|
89
|
+
*/
|
|
90
|
+
declare type ShowImageCardAction = CardActionWithImageAndTitle & {
|
|
91
|
+
type: 'showImage';
|
|
92
|
+
value: string;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* A `signin` action represents a hyperlink to be handled by the client's signin system.
|
|
96
|
+
*
|
|
97
|
+
* https://github.com/Microsoft/botframework-sdk/blob/main/specs/botframework-activity/botframework-activity.md#signin
|
|
98
|
+
*/
|
|
99
|
+
declare type SignInCardAction = CardActionWithImageAndTitle & {
|
|
100
|
+
type: 'signin';
|
|
101
|
+
value: string;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* A card action represents a clickable or interactive button for use within cards or as suggested actions. They are used to solicit input from users. Despite their name, card actions are not limited to use solely on cards.
|
|
105
|
+
*
|
|
106
|
+
* https://github.com/Microsoft/botframework-sdk/blob/main/specs/botframework-activity/botframework-activity.md#card-action
|
|
107
|
+
*/
|
|
108
|
+
declare type DirectLineCardAction = CallCardAction | DownloadFileCardAction | IMBackCardAction | MessageBackCardAction | OpenURLCardAction | PlayAudioCardAction | PlayVideoCardAction | PostBackCardAction | ShowImageCardAction | SignInCardAction;
|
|
2
109
|
export default DirectLineCardAction;
|
|
3
110
|
//# sourceMappingURL=DirectLineCardAction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DirectLineCardAction.d.ts","sourceRoot":"","sources":["../../../src/types/external/DirectLineCardAction.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DirectLineCardAction.d.ts","sourceRoot":"","sources":["../../../src/types/external/DirectLineCardAction.ts"],"names":[],"mappings":"AAAA,aAAK,2BAA2B,GAC5B;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GACjB;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GACjB;IACE,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEN;;;;GAIG;AACH,aAAK,cAAc,GAAG,2BAA2B,GAAG;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;GAIG;AACH,aAAK,sBAAsB,GAAG,2BAA2B,GAAG;IAC1D,IAAI,EA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rB,cAAc,GACd,sBAAsB,GACtB,gBAAgB,GAChB,qBAAqB,GACrB,iBAAiB,GACjB,mBAAmB,GACnB,mBAAmB,GACnB,kBAAkB,GAClB,mBAAmB,GACnB,gBAAgB,CAAC;AAErB,eAAe,oBAAoB,CAAC"}
|
package/lib/utils/deleteKey.js
CHANGED
|
@@ -17,14 +17,13 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _ty
|
|
|
17
17
|
|
|
18
18
|
function _toPrimitive(input, hint) { if ((0, _typeof2["default"])(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if ((0, _typeof2["default"])(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
19
19
|
|
|
20
|
-
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^deleted$" }] */
|
|
21
20
|
function deleteKey(map, key) {
|
|
22
21
|
if (!map) {
|
|
23
22
|
return map;
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
var
|
|
25
|
+
var _deleted = map[key],
|
|
27
26
|
nextMap = (0, _objectWithoutProperties2["default"])(map, [key].map(_toPropertyKey));
|
|
28
27
|
return nextMap;
|
|
29
28
|
}
|
|
30
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
29
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9kZWxldGVLZXkuanMiXSwibmFtZXMiOlsiZGVsZXRlS2V5IiwibWFwIiwia2V5IiwiX2RlbGV0ZWQiLCJuZXh0TWFwIl0sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQWUsU0FBU0EsU0FBVCxDQUFtQkMsR0FBbkIsRUFBd0JDLEdBQXhCLEVBQTZCO0FBQzFDLE1BQUksQ0FBQ0QsR0FBTCxFQUFVO0FBQ1IsV0FBT0EsR0FBUDtBQUNEOztBQUVELE1BQWVFLFFBQWYsR0FBd0NGLEdBQXhDLENBQVNDLEdBQVQ7QUFBQSxNQUE0QkUsT0FBNUIsNkNBQXdDSCxHQUF4QyxHQUFTQyxHQUFUO0FBRUEsU0FBT0UsT0FBUDtBQUNEIiwic291cmNlUm9vdCI6ImNvcmU6Ly8vIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IGRlZmF1bHQgZnVuY3Rpb24gZGVsZXRlS2V5KG1hcCwga2V5KSB7XG4gIGlmICghbWFwKSB7XG4gICAgcmV0dXJuIG1hcDtcbiAgfVxuXG4gIGNvbnN0IHsgW2tleV06IF9kZWxldGVkLCAuLi5uZXh0TWFwIH0gPSBtYXA7XG5cbiAgcmV0dXJuIG5leHRNYXA7XG59XG4iXX0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isForbiddenPropertyName.d.ts","sourceRoot":"","sources":["../../src/utils/isForbiddenPropertyName.ts"],"names":[],"mappings":"AA8BA,MAAM,CAAC,OAAO,UAAU,uBAAuB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAE7E"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = isForbiddenPropertyName;
|
|
9
|
+
|
|
10
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
+
|
|
12
|
+
var FORBIDDEN_PROPERTY_NAMES;
|
|
13
|
+
|
|
14
|
+
function getForbiddenPropertyNames() {
|
|
15
|
+
return FORBIDDEN_PROPERTY_NAMES || (FORBIDDEN_PROPERTY_NAMES = Object.freeze(Array.from(new Set([].concat((0, _toConsumableArray2["default"])(Object.getOwnPropertyNames(Object.prototype)), ['prototype'])))));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function isForbiddenPropertyName(propertyName) {
|
|
19
|
+
return getForbiddenPropertyNames().includes(propertyName);
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9pc0ZvcmJpZGRlblByb3BlcnR5TmFtZS50cyJdLCJuYW1lcyI6WyJGT1JCSURERU5fUFJPUEVSVFlfTkFNRVMiLCJnZXRGb3JiaWRkZW5Qcm9wZXJ0eU5hbWVzIiwiT2JqZWN0IiwiZnJlZXplIiwiQXJyYXkiLCJmcm9tIiwiU2V0IiwiZ2V0T3duUHJvcGVydHlOYW1lcyIsInByb3RvdHlwZSIsImlzRm9yYmlkZGVuUHJvcGVydHlOYW1lIiwicHJvcGVydHlOYW1lIiwiaW5jbHVkZXMiXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7O0FBQUEsSUFBSUEsd0JBQUo7O0FBRUEsU0FBU0MseUJBQVQsR0FBK0M7QUFDN0MsU0FDRUQsd0JBQXdCLEtBQ3ZCQSx3QkFBd0IsR0FBR0UsTUFBTSxDQUFDQyxNQUFQLENBQzFCQyxLQUFLLENBQUNDLElBQU4sQ0FDRSxJQUFJQyxHQUFKLCtDQWNLSixNQUFNLENBQUNLLG1CQUFQLENBQTJCTCxNQUFNLENBQUNNLFNBQWxDLENBZEwsSUFnQkUsV0FoQkYsR0FERixDQUQwQixDQURKLENBRDFCO0FBeUJEOztBQUVjLFNBQVNDLHVCQUFULENBQWlDQyxZQUFqQyxFQUFnRTtBQUM3RSxTQUFPVCx5QkFBeUIsR0FBR1UsUUFBNUIsQ0FBcUNELFlBQXJDLENBQVA7QUFDRCIsInNvdXJjZVJvb3QiOiJjb3JlOi8vLyIsInNvdXJjZXNDb250ZW50IjpbImxldCBGT1JCSURERU5fUFJPUEVSVFlfTkFNRVM7XG5cbmZ1bmN0aW9uIGdldEZvcmJpZGRlblByb3BlcnR5TmFtZXMoKTogc3RyaW5nW10ge1xuICByZXR1cm4gKFxuICAgIEZPUkJJRERFTl9QUk9QRVJUWV9OQU1FUyB8fFxuICAgIChGT1JCSURERU5fUFJPUEVSVFlfTkFNRVMgPSBPYmplY3QuZnJlZXplKFxuICAgICAgQXJyYXkuZnJvbShcbiAgICAgICAgbmV3IFNldChbXG4gICAgICAgICAgLy8gQXMtb2Ygd3JpdGluZywgYE9iamVjdC5wcm90b3R5cGVgIGluY2x1ZGVzOlxuICAgICAgICAgIC8vICAgX19kZWZpbmVHZXR0ZXJfX1xuICAgICAgICAgIC8vICAgX19kZWZpbmVTZXR0ZXJfX1xuICAgICAgICAgIC8vICAgX19sb29rdXBHZXR0ZXJfX1xuICAgICAgICAgIC8vICAgX19sb29rdXBTZXR0ZXJcbiAgICAgICAgICAvLyAgIF9fcHJvdG9fX1xuICAgICAgICAgIC8vICAgY29uc3RydWN0b3JcbiAgICAgICAgICAvLyAgIGhhc093blByb3BlcnR5XG4gICAgICAgICAgLy8gICBpc1Byb3RvdHlwZU9mXG4gICAgICAgICAgLy8gICBwcm9wZXJ0eUlzRW51bWVyYWJsZVxuICAgICAgICAgIC8vICAgdG9Mb2NhbGVTdHJpbmdcbiAgICAgICAgICAvLyAgIHRvU3RyaW5nXG4gICAgICAgICAgLy8gICB2YWx1ZU9mXG4gICAgICAgICAgLi4uT2JqZWN0LmdldE93blByb3BlcnR5TmFtZXMoT2JqZWN0LnByb3RvdHlwZSksXG5cbiAgICAgICAgICAncHJvdG90eXBlJ1xuICAgICAgICBdKVxuICAgICAgKVxuICAgICkpXG4gICk7XG59XG5cbmV4cG9ydCBkZWZhdWx0IGZ1bmN0aW9uIGlzRm9yYmlkZGVuUHJvcGVydHlOYW1lKHByb3BlcnR5TmFtZTogc3RyaW5nKTogYm9vbGVhbiB7XG4gIHJldHVybiBnZXRGb3JiaWRkZW5Qcm9wZXJ0eU5hbWVzKCkuaW5jbHVkZXMocHJvcGVydHlOYW1lKTtcbn1cbiJdfQ==
|
|
@@ -9,9 +9,7 @@ exports["default"] = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _Mime = _interopRequireDefault(require("mime/Mime"));
|
|
11
11
|
|
|
12
|
-
/* eslint no-undef: "off"*/
|
|
13
|
-
|
|
14
|
-
/* eslint node/global-require: "off"*/
|
|
12
|
+
/* eslint no-undef: "off" */
|
|
15
13
|
// We adopted the work from mime-wrapper, at https://github.com/marlon360/mime-wrapper.
|
|
16
14
|
// This file wraps the mime library constructor to include '.json' types. This is needed
|
|
17
15
|
// to support Angular CLI web projects, in which the webpack.config files are hidden away
|
|
@@ -46,4 +44,4 @@ var _Mime = _interopRequireDefault(require("mime/Mime"));
|
|
|
46
44
|
var _default = new _Mime["default"](require('mime/types/standard'), require('mime/types/other'));
|
|
47
45
|
|
|
48
46
|
exports["default"] = _default;
|
|
49
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
47
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9taW1lLXdyYXBwZXIuanMiXSwibmFtZXMiOlsiTWltZSIsInJlcXVpcmUiXSwibWFwcGluZ3MiOiI7Ozs7Ozs7OztBQW9DQTs7QUFwQ0E7QUFFQTtBQUVBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUVBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtlQUllLElBQUlBLGdCQUFKLENBQVNDLE9BQU8sQ0FBQyxxQkFBRCxDQUFoQixFQUF5Q0EsT0FBTyxDQUFDLGtCQUFEL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RklUTkVTUyBGT1IgQSBQQVJUSUNVTEFSIFBVUlBPU0UgQU5EIE5PTklORlJJTkdFTUVOVC4gSU4gTk8gRVZFTlQgU0hBTEwgVEhFXG4vLyBBVVRIT1JTIE9SIENPUFlSSUdIVCBIT0xERVJTIEJFIExJQUJMRSBGT1IgQU5ZIENMQUlNLCBEQU1BR0VTIE9SIE9USEVSXG4vLyBMSUFCSUxJVFksIFdIRVRIRVIgSU4gQU4gQUNUSU9OIE9GIENPTlRSQUNULCBUT1JUIE9SIE9USEVSV0lTRSwgQVJJU0lORyBGUk9NLFxuLy8gT1VUIE9GIE9SIElOIENPTk5FQ1RJT04gV0lUSCBUSEUgU09GVFdBUkUgT1IgVEhFIFVTRSBPUiBPVEhFUiBERUFMSU5HUyBJTiBUSEVcbi8vIFNPRlRXQVJFLlxuXG5pbXBvcnQgTWltZSBmcm9tICdtaW1lL01pbWUnO1xuXG5leHBvcnQgZGVmYXVsdCBuZXcgTWltZShyZXF1aXJlKCdtaW1lL3R5cGVzL3N0YW5kYXJkJyksIHJlcXVpcmUoJ21pbWUvdHlwZXMvb3RoZXInKSk7XG4iXX0=
|
package/lib/utils/uniqueID.js
CHANGED
|
@@ -13,4 +13,4 @@ var _mathRandom = _interopRequireDefault(require("math-random"));
|
|
|
13
13
|
function uniqueID() {
|
|
14
14
|
return Date.now() + (0, _mathRandom["default"])().toString(36).substr(2);
|
|
15
15
|
}
|
|
16
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
16
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy91bmlxdWVJRC5qcyJdLCJuYW1lcyI6WyJ1bmlxdWVJRCIsIkRhdGUiLCJub3ciLCJ0b1N0cmluZyIsInN1YnN0ciJdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7O0FBRUE7O0FBRkE7QUFJZSxTQUFTQSxRQUFULEdBQW9CO0FBQ2pDLFNBQU9DLElBQUksQ0FBQ0MsR0FBTCxLQUFhLDhCQUFTQyxRQUFULENBQWtCLEVBQWxCLEVBQXNCQyxNQUF0QixDQUE2QixDQUE3QixDQUFwQjtBQUNEIiwic291cmNlUm9vdCI6ImNvcmU6Ly8vIiwic291cmNlc0NvbnRlbnQiOlsiLyogZXNsaW50IG5vLW1hZ2ljLW51bWJlcnM6IFtcImVycm9yXCIsIHsgXCJpZ25vcmVcIjogWzIsIDM2XSB9XSAqL1xuXG5pbXBvcnQgcmFuZG9tIGZyb20gJ21hdGgtcmFuZG9tJztcblxuZXhwb3J0IGRlZmF1bHQgZnVuY3Rpb24gdW5pcXVlSUQoKSB7XG4gIHJldHVybiBEYXRlLm5vdygpICsgcmFuZG9tKCkudG9TdHJpbmcoMzYpLnN1YnN0cigyKTtcbn1cbiJdfQ==
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "botframework-webchat-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.15.1",
|
|
4
4
|
"description": "Core of botframework-webchat",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -22,40 +22,33 @@
|
|
|
22
22
|
"build:typescript": "tsc --project src/tsconfig.json",
|
|
23
23
|
"eslint": "npm run precommit",
|
|
24
24
|
"precommit": "npm run precommit:eslint -- src && npm run precommit:typecheck",
|
|
25
|
-
"precommit:eslint": "eslint",
|
|
25
|
+
"precommit:eslint": "../../node_modules/.bin/eslint --report-unused-disable-directives --max-warnings 0",
|
|
26
26
|
"precommit:typecheck": "tsc --project ./src --emitDeclarationOnly false --esModuleInterop true --noEmit --pretty false",
|
|
27
|
-
"prettier": "prettier --check src/**/*.{js,ts,tsx}",
|
|
28
27
|
"prestart": "npm run build:babel",
|
|
29
28
|
"start": "concurrently --kill-others --names \"babel,tsc\" \"npm run start:babel\" \"npm run start:typescript\"",
|
|
30
29
|
"start:babel": "npm run build:babel -- --skip-initial-build --watch",
|
|
31
30
|
"start:typescript": "npm run build:typescript -- --watch"
|
|
32
31
|
},
|
|
33
32
|
"devDependencies": {
|
|
34
|
-
"@babel/cli": "^7.
|
|
35
|
-
"@babel/core": "^7.
|
|
36
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
37
|
-
"@babel/preset-env": "^7.
|
|
38
|
-
"@babel/preset-typescript": "^7.
|
|
39
|
-
"@types/node": "^
|
|
40
|
-
"@typescript-eslint/eslint-plugin": "^4.21.0",
|
|
41
|
-
"@typescript-eslint/parser": "^4.21.0",
|
|
33
|
+
"@babel/cli": "^7.14.5",
|
|
34
|
+
"@babel/core": "^7.14.6",
|
|
35
|
+
"@babel/plugin-transform-runtime": "^7.14.5",
|
|
36
|
+
"@babel/preset-env": "^7.14.7",
|
|
37
|
+
"@babel/preset-typescript": "^7.14.5",
|
|
38
|
+
"@types/node": "^16.3.1",
|
|
42
39
|
"babel-plugin-istanbul": "^6.0.0",
|
|
43
40
|
"babel-plugin-transform-inline-environment-variables": "^0.4.3",
|
|
44
|
-
"botframework-directlinejs": "
|
|
45
|
-
"concurrently": "^6.0
|
|
46
|
-
"
|
|
47
|
-
"eslint-plugin-node": "^11.1.0",
|
|
48
|
-
"eslint-plugin-prettier": "^3.3.1",
|
|
49
|
-
"prettier": "^2.2.1",
|
|
50
|
-
"typescript": "^4.2.3"
|
|
41
|
+
"botframework-directlinejs": "0.15.1",
|
|
42
|
+
"concurrently": "^6.3.0",
|
|
43
|
+
"typescript": "^4.3.5"
|
|
51
44
|
},
|
|
52
45
|
"dependencies": {
|
|
53
|
-
"@babel/runtime": "7.
|
|
54
|
-
"
|
|
46
|
+
"@babel/runtime": "7.15.4",
|
|
47
|
+
"jwt-decode": "3.1.2",
|
|
55
48
|
"math-random": "2.0.1",
|
|
56
49
|
"mime": "2.5.2",
|
|
57
|
-
"p-defer": "
|
|
58
|
-
"p-defer-es5": "
|
|
50
|
+
"p-defer": "4.0.0",
|
|
51
|
+
"p-defer-es5": "2.0.1",
|
|
59
52
|
"redux": "4.0.5",
|
|
60
53
|
"redux-devtools-extension": "2.13.9",
|
|
61
54
|
"redux-saga": "1.1.3",
|
|
@@ -36,7 +36,7 @@ describe('observeOnce', () => {
|
|
|
36
36
|
|
|
37
37
|
test('should unsubscribe after first next', () =>
|
|
38
38
|
new Promise((resolve, reject) => {
|
|
39
|
-
runSaga(inputOutput, function*() {
|
|
39
|
+
runSaga(inputOutput, function* () {
|
|
40
40
|
try {
|
|
41
41
|
const [result] = yield all([observeOnce(observable), call(() => onNext('Hello, World!'))]);
|
|
42
42
|
|
|
@@ -53,7 +53,7 @@ describe('observeOnce', () => {
|
|
|
53
53
|
|
|
54
54
|
test('should unsubscribe and throw after first error', () =>
|
|
55
55
|
new Promise((resolve, reject) => {
|
|
56
|
-
runSaga(inputOutput, function*() {
|
|
56
|
+
runSaga(inputOutput, function* () {
|
|
57
57
|
try {
|
|
58
58
|
try {
|
|
59
59
|
yield all([observeOnce(observable), call(() => onError(new Error('Hello, World!')))]);
|
|
@@ -75,7 +75,7 @@ describe('observeOnce', () => {
|
|
|
75
75
|
|
|
76
76
|
test('should unsubscribe after complete', () =>
|
|
77
77
|
new Promise((resolve, reject) => {
|
|
78
|
-
runSaga(inputOutput, function*() {
|
|
78
|
+
runSaga(inputOutput, function* () {
|
|
79
79
|
try {
|
|
80
80
|
const [result] = yield all([observeOnce(observable), call(() => onComplete())]);
|
|
81
81
|
|
|
@@ -4,12 +4,18 @@ const SET_NOTIFICATION = 'WEB_CHAT/SET_NOTIFICATION';
|
|
|
4
4
|
|
|
5
5
|
export default function setNotification({ alt, data, id, level, message }) {
|
|
6
6
|
if (!id || typeof id !== 'string') {
|
|
7
|
-
console.warn(
|
|
7
|
+
console.warn(
|
|
8
|
+
'botframework-webchat: The "id" argument passed to "setNotification" must be a string; defaulting to a random value.'
|
|
9
|
+
);
|
|
10
|
+
|
|
8
11
|
id = uniqueID();
|
|
9
12
|
}
|
|
10
13
|
|
|
11
14
|
if (!level || typeof level !== 'string') {
|
|
12
|
-
console.warn(
|
|
15
|
+
console.warn(
|
|
16
|
+
'botframework-webchat: The "level" argument passed to "setNotification" must be a string; defaulting to "info".'
|
|
17
|
+
);
|
|
18
|
+
|
|
13
19
|
level = 'info';
|
|
14
20
|
}
|
|
15
21
|
|
package/src/createStore.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
2
|
-
// This is for the racing between sagaMiddleware and store
|
|
3
|
-
/* eslint no-use-before-define: "off" */
|
|
4
|
-
|
|
5
1
|
import { applyMiddleware, createStore as createReduxStore, Store } from 'redux';
|
|
6
2
|
import { composeWithDevTools } from 'redux-devtools-extension';
|
|
7
3
|
import createSagaMiddleware from 'redux-saga';
|
|
@@ -30,6 +26,8 @@ function createEnhancerAndSagaMiddleware(getStore, ...middlewares) {
|
|
|
30
26
|
}
|
|
31
27
|
|
|
32
28
|
export default function createStore(initialState?, ...middlewares): Store {
|
|
29
|
+
// We are sure the "getStore" (first argument) is not called on "createEnhancerAndSagaMiddleware()".
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
33
31
|
const { enhancer, sagaMiddleware } = createEnhancerAndSagaMiddleware(() => store, ...middlewares);
|
|
34
32
|
const store = createReduxStore(reducer, initialState || {}, enhancer);
|
|
35
33
|
|
|
@@ -39,6 +37,8 @@ export default function createStore(initialState?, ...middlewares): Store {
|
|
|
39
37
|
}
|
|
40
38
|
|
|
41
39
|
export function withDevTools(initialState?, ...middlewares): Store {
|
|
40
|
+
// We are sure the "getStore" (first argument) is not called on "createEnhancerAndSagaMiddleware()".
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
42
42
|
const { enhancer, sagaMiddleware } = createEnhancerAndSagaMiddleware(() => store, ...middlewares);
|
|
43
43
|
const store = createReduxStore(reducer, initialState || {}, composeWithDevTools(enhancer));
|
|
44
44
|
|
package/src/index.ts
CHANGED
|
@@ -19,6 +19,7 @@ import DirectLineVideoCard from './types/external/DirectLineVideoCard';
|
|
|
19
19
|
import disconnect from './actions/disconnect';
|
|
20
20
|
import dismissNotification from './actions/dismissNotification';
|
|
21
21
|
import emitTypingIndicator from './actions/emitTypingIndicator';
|
|
22
|
+
import isForbiddenPropertyName from './utils/isForbiddenPropertyName';
|
|
22
23
|
import markActivity from './actions/markActivity';
|
|
23
24
|
import OneOrMany from './types/OneOrMany';
|
|
24
25
|
import postActivity from './actions/postActivity';
|
|
@@ -54,6 +55,7 @@ export {
|
|
|
54
55
|
disconnect,
|
|
55
56
|
dismissNotification,
|
|
56
57
|
emitTypingIndicator,
|
|
58
|
+
isForbiddenPropertyName,
|
|
57
59
|
markActivity,
|
|
58
60
|
postActivity,
|
|
59
61
|
sendEvent,
|
|
@@ -3,6 +3,7 @@ import updateIn from 'simple-update-in';
|
|
|
3
3
|
import { DISMISS_NOTIFICATION } from '../actions/dismissNotification';
|
|
4
4
|
import { SAGA_ERROR } from '../actions/sagaError';
|
|
5
5
|
import { SET_NOTIFICATION } from '../actions/setNotification';
|
|
6
|
+
import isForbiddenPropertyName from '../utils/isForbiddenPropertyName';
|
|
6
7
|
|
|
7
8
|
const DEFAULT_STATE = {};
|
|
8
9
|
|
|
@@ -15,23 +16,28 @@ export default function notifications(state = DEFAULT_STATE, { payload, type })
|
|
|
15
16
|
state = updateIn(state, ['connectivitystatus', 'message'], () => 'javascripterror');
|
|
16
17
|
} else if (type === SET_NOTIFICATION) {
|
|
17
18
|
const { alt, data, id, level, message } = payload;
|
|
18
|
-
const notification = state[id];
|
|
19
19
|
|
|
20
|
-
if (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
20
|
+
if (!isForbiddenPropertyName(id)) {
|
|
21
|
+
// Mitigated through denylisting.
|
|
22
|
+
// eslint-disable-next-line security/detect-object-injection
|
|
23
|
+
const notification = state[id];
|
|
24
|
+
|
|
25
|
+
if (
|
|
26
|
+
!notification ||
|
|
27
|
+
alt !== notification.alt ||
|
|
28
|
+
!Object.is(data, notification.data) ||
|
|
29
|
+
level !== notification.level ||
|
|
30
|
+
message !== notification.message
|
|
31
|
+
) {
|
|
32
|
+
state = updateIn(state, [id], () => ({
|
|
33
|
+
alt,
|
|
34
|
+
data,
|
|
35
|
+
id,
|
|
36
|
+
level,
|
|
37
|
+
message,
|
|
38
|
+
timestamp: now
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
35
41
|
}
|
|
36
42
|
}
|
|
37
43
|
|
package/src/sagas/connectSaga.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { call, cancel, cancelled, fork, put, race, take } from 'redux-saga/effects';
|
|
4
4
|
|
|
5
5
|
import { ConnectionStatus } from 'botframework-directlinejs';
|
|
6
|
-
import
|
|
6
|
+
import decode from 'jwt-decode';
|
|
7
7
|
|
|
8
8
|
import { CONNECT } from '../actions/connect';
|
|
9
9
|
import createPromiseQueue from '../createPromiseQueue';
|
|
@@ -39,7 +39,14 @@ function* observeAndPutConnectionStatusUpdate(directLine) {
|
|
|
39
39
|
// TODO: [P2] We should move this check and rectification to DirectLineJS.
|
|
40
40
|
function rectifyUserID(directLine, userIDFromAction) {
|
|
41
41
|
const { token } = directLine;
|
|
42
|
-
|
|
42
|
+
|
|
43
|
+
let userIDFromToken;
|
|
44
|
+
|
|
45
|
+
// TODO: Add test to make sure "jwt-decode" work as expected.
|
|
46
|
+
try {
|
|
47
|
+
userIDFromToken = (decode(token) || {}).user;
|
|
48
|
+
// eslint-disable-next-line no-empty
|
|
49
|
+
} catch (err) {}
|
|
43
50
|
|
|
44
51
|
const result = {
|
|
45
52
|
fromAction: userIDFromAction,
|
|
@@ -50,51 +50,52 @@ function* waitForActivityId(replyToId, initialActivities) {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
function* queueIncomingActivity({ userID }) {
|
|
53
|
-
yield takeEveryAndSelect(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
53
|
+
yield takeEveryAndSelect(
|
|
54
|
+
QUEUE_INCOMING_ACTIVITY,
|
|
55
|
+
activitiesSelector,
|
|
56
|
+
function* queueIncomingActivity({ payload: { activity } }, initialActivities) {
|
|
57
|
+
// This is for resolving an accessibility issue.
|
|
58
|
+
// If the incoming activity has "replyToId" field, hold on it until the activity replied to is in the transcript, then release this one.
|
|
59
|
+
const { replyToId } = activity;
|
|
60
|
+
const initialBotActivities = initialActivities.filter(({ from: { role } }) => role === 'bot');
|
|
61
|
+
|
|
62
|
+
// To speed up the first activity render time, we do not delay the first activity from the bot.
|
|
63
|
+
// Even if it is the first activity from the bot, the bot might be "replying" to the "conversationUpdate" event.
|
|
64
|
+
// Thus, the "replyToId" will always be there even it is the first activity in the conversation.
|
|
65
|
+
if (replyToId && initialBotActivities.length) {
|
|
66
|
+
// Either the activity replied to is in the transcript or after timeout.
|
|
67
|
+
const result = yield race({
|
|
68
|
+
_: waitForActivityId(replyToId, initialActivities),
|
|
69
|
+
timeout: call(sleep, REPLY_TIMEOUT)
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
if ('timeout' in result) {
|
|
73
|
+
console.warn(
|
|
74
|
+
`botframework-webchat: Timed out while waiting for activity "${replyToId}" which activity "${activity.id}" is replying to.`,
|
|
75
|
+
{
|
|
76
|
+
activity,
|
|
77
|
+
replyToId
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
}
|
|
80
81
|
}
|
|
81
|
-
}
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
yield put(incomingActivity(activity));
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
// Update suggested actions
|
|
86
|
+
// TODO: [P3] We could put this logic inside reducer to minimize number of actions dispatched.
|
|
87
|
+
const messageActivities = yield select(activitiesOfType('message'));
|
|
88
|
+
const lastMessageActivity = messageActivities[messageActivities.length - 1];
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
if (activityFromBot(lastMessageActivity)) {
|
|
91
|
+
const { suggestedActions: { actions, to } = {} } = lastMessageActivity;
|
|
92
92
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
// If suggested actions is not destined to anyone, or is destined to the user, show it.
|
|
94
|
+
// In other words, if suggested actions is destined to someone else, don't show it.
|
|
95
|
+
yield put(setSuggestedActions(to && to.length && !to.includes(userID) ? null : actions));
|
|
96
|
+
}
|
|
96
97
|
}
|
|
97
|
-
|
|
98
|
+
);
|
|
98
99
|
}
|
|
99
100
|
|
|
100
101
|
export default function* queueIncomingActivitySaga() {
|
|
@@ -3,7 +3,6 @@ import postActivity from '../actions/postActivity';
|
|
|
3
3
|
import { SEND_MESSAGE_BACK } from '../actions/sendMessageBack';
|
|
4
4
|
import whileConnected from './effects/whileConnected';
|
|
5
5
|
|
|
6
|
-
|
|
7
6
|
// https://github.com/microsoft/botframework-sdk/blob/main/specs/botframework-activity/botframework-activity.md#message-back
|
|
8
7
|
function* postActivityWithMessageBack({ payload: { displayText, text, value } }) {
|
|
9
8
|
yield put(
|
|
@@ -34,7 +34,7 @@ function* sendTypingIndicatorOnSetSendBox() {
|
|
|
34
34
|
// When the user type, and then post the activity at t = 1500, we still have a pending typing indicator at t = 3000.
|
|
35
35
|
// This code is to cancel the typing indicator at t = 3000.
|
|
36
36
|
(type === POST_ACTIVITY && payload.activity.type !== 'typing'),
|
|
37
|
-
function*({ payload, type }) {
|
|
37
|
+
function* ({ payload, type }) {
|
|
38
38
|
if (type === SET_SEND_BOX) {
|
|
39
39
|
const interval = SEND_INTERVAL - Date.now() + lastSend;
|
|
40
40
|
|
|
@@ -16,7 +16,7 @@ function* speakActivityAndStartDictateOnIncomingActivityFromOthers({ userID }) {
|
|
|
16
16
|
// In Direct Line Speech, we do not know the user ID, but "role" is filled with "bot" or "user".
|
|
17
17
|
// Here, we do two checks: the speakable activity must not have user ID, and must not have role === 'user'
|
|
18
18
|
type === INCOMING_ACTIVITY && payload.activity.from.id !== userID && payload.activity.from.role !== 'user',
|
|
19
|
-
function*({ payload: { activity } }) {
|
|
19
|
+
function* ({ payload: { activity } }) {
|
|
20
20
|
const shouldSpeakIncomingActivity = yield select(shouldSpeakIncomingActivitySelector);
|
|
21
21
|
const shouldSpeak = speakableActivity(activity) && shouldSpeakIncomingActivity;
|
|
22
22
|
|
|
@@ -8,7 +8,7 @@ function* startSpeakActivityOnPostActivity() {
|
|
|
8
8
|
yield takeEvery(
|
|
9
9
|
({ meta, payload, type }) =>
|
|
10
10
|
type === POST_ACTIVITY_PENDING && meta.method === 'speech' && payload.activity.type === 'message',
|
|
11
|
-
function*() {
|
|
11
|
+
function* () {
|
|
12
12
|
yield put(startSpeakingActivity());
|
|
13
13
|
}
|
|
14
14
|
);
|
|
@@ -14,7 +14,7 @@ function* stopSpeakingActivityOnInput() {
|
|
|
14
14
|
// So, right now, we are using best-effort by listening to POST_ACTIVITY_PENDING with a "message" event
|
|
15
15
|
// We filter out speech because we will call startSpeakingActivity() for POST_ACTIVITY_PENDING dispatched by speech
|
|
16
16
|
(type === POST_ACTIVITY_PENDING && meta.method !== 'speech' && payload.activity.type === 'message'),
|
|
17
|
-
function*() {
|
|
17
|
+
function* () {
|
|
18
18
|
yield put(stopSpeakingActivity());
|
|
19
19
|
}
|
|
20
20
|
);
|
|
@@ -7,7 +7,7 @@ import setSendBox from '../actions/setSendBox';
|
|
|
7
7
|
import whileConnected from './effects/whileConnected';
|
|
8
8
|
|
|
9
9
|
function* submitSendBox() {
|
|
10
|
-
yield takeEvery(SUBMIT_SEND_BOX, function*({ payload: { channelData, method } }) {
|
|
10
|
+
yield takeEvery(SUBMIT_SEND_BOX, function* ({ payload: { channelData, method } }) {
|
|
11
11
|
const sendBoxValue = yield select(sendBoxValueSelector);
|
|
12
12
|
|
|
13
13
|
if (sendBoxValue) {
|