From 1e0d926da47f9840e076e71537d4ea36e124aefa Mon Sep 17 00:00:00 2001 From: anjalinitd Date: Wed, 30 Mar 2022 15:11:28 +0530 Subject: [PATCH 1/6] Typing Indicator changes --- packages/api/src/types/Typing.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/api/src/types/Typing.ts b/packages/api/src/types/Typing.ts index 18210d7daf..d4b810610d 100644 --- a/packages/api/src/types/Typing.ts +++ b/packages/api/src/types/Typing.ts @@ -3,6 +3,7 @@ type Typing = { expireAt: number; name: string; role: 'bot' | 'user'; + tag?: string; }; export default Typing; From 67e71466e2249f597a4b1e6f47d696508171ffa2 Mon Sep 17 00:00:00 2001 From: anjalinitd Date: Wed, 30 Mar 2022 15:29:13 +0530 Subject: [PATCH 2/6] typing Indicator changes --- packages/api/src/hooks/useActiveTyping.ts | 8 +++++--- packages/api/src/types/Typing.ts | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/api/src/hooks/useActiveTyping.ts b/packages/api/src/hooks/useActiveTyping.ts index c1da42e957..b214ca4fc6 100644 --- a/packages/api/src/hooks/useActiveTyping.ts +++ b/packages/api/src/hooks/useActiveTyping.ts @@ -10,18 +10,20 @@ function useActiveTyping(expireAfter?: number): [{ [userId: string]: Typing }] { const [{ typingAnimationDuration }] = useStyleOptions(); const forceRender = useForceRender(); - const typing: { [userId: string]: { at: number; name: string; role: string } } = useSelector(({ typing }) => typing); + const typing: { [userId: string]: { at: number; name: string; role: string; tag: string } } = useSelector( + ({ typing }) => typing + ); if (typeof expireAfter !== 'number') { expireAfter = typingAnimationDuration; } const activeTyping: { [userId: string]: Typing } = Object.entries(typing).reduce( - (activeTyping, [id, { at, name, role }]) => { + (activeTyping, [id, { at, name, role, tag }]) => { const until = at + expireAfter; if (until > now) { - return { ...activeTyping, [id]: { at, expireAt: until, name, role } }; + return { ...activeTyping, [id]: { at, expireAt: until, name, role, tag } }; } return activeTyping; diff --git a/packages/api/src/types/Typing.ts b/packages/api/src/types/Typing.ts index d4b810610d..7150f9e4a5 100644 --- a/packages/api/src/types/Typing.ts +++ b/packages/api/src/types/Typing.ts @@ -3,7 +3,7 @@ type Typing = { expireAt: number; name: string; role: 'bot' | 'user'; - tag?: string; + tag: string; }; export default Typing; From ab623948fb02861032f0d245401a4d84e6dab837 Mon Sep 17 00:00:00 2001 From: anjalinitd Date: Thu, 31 Mar 2022 13:19:05 +0530 Subject: [PATCH 3/6] fixed test cases --- __tests__/hooks/useActiveTyping.js | 21 ++++++++++++++------- packages/api/src/hooks/useActiveTyping.ts | 2 +- packages/api/src/types/Typing.ts | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/__tests__/hooks/useActiveTyping.js b/__tests__/hooks/useActiveTyping.js index 0fc1a8feea..c4ccbcf5ea 100644 --- a/__tests__/hooks/useActiveTyping.js +++ b/__tests__/hooks/useActiveTyping.js @@ -37,7 +37,8 @@ test('getter should represent bot and user typing respectively', async () => { at: 0, expireAt: 5000, name: 'Happy Web Chat user', - role: 'user' + role: 'user', + tag: null } ]); @@ -51,7 +52,8 @@ test('getter should represent bot and user typing respectively', async () => { at: 0, expireAt: 5000, name: 'bot', - role: 'bot' + role: 'bot', + tag: null } ]); @@ -64,13 +66,15 @@ test('getter should represent bot and user typing respectively', async () => { at: 0, expireAt: 5000, name: 'bot', - role: 'bot' + role: 'bot', + tag: null }, { at: 0, expireAt: 5000, name: 'Happy Web Chat user', - role: 'user' + role: 'user', + tag: null } ]); }); @@ -102,7 +106,8 @@ test('getter should filter out inactive typing', async () => { at: 0, expireAt: 5000, name: 'Happy Web Chat user', - role: 'user' + role: 'user', + tag: null } ]); @@ -121,7 +126,8 @@ test('getter should filter out inactive typing', async () => { at: 3000, expireAt: 8000, name: 'Happy Web Chat user', - role: 'user' + role: 'user', + tag: null } ]); @@ -137,7 +143,8 @@ test('getter should filter out inactive typing', async () => { at: 3000, expireAt: 13000, name: 'Happy Web Chat user', - role: 'user' + role: 'user', + tag: null } ]); }); diff --git a/packages/api/src/hooks/useActiveTyping.ts b/packages/api/src/hooks/useActiveTyping.ts index b214ca4fc6..5da73e6c25 100644 --- a/packages/api/src/hooks/useActiveTyping.ts +++ b/packages/api/src/hooks/useActiveTyping.ts @@ -10,7 +10,7 @@ function useActiveTyping(expireAfter?: number): [{ [userId: string]: Typing }] { const [{ typingAnimationDuration }] = useStyleOptions(); const forceRender = useForceRender(); - const typing: { [userId: string]: { at: number; name: string; role: string; tag: string } } = useSelector( + const typing: { [userId: string]: { at: number; name: string; role: string; tag?: string } } = useSelector( ({ typing }) => typing ); diff --git a/packages/api/src/types/Typing.ts b/packages/api/src/types/Typing.ts index 7150f9e4a5..d4b810610d 100644 --- a/packages/api/src/types/Typing.ts +++ b/packages/api/src/types/Typing.ts @@ -3,7 +3,7 @@ type Typing = { expireAt: number; name: string; role: 'bot' | 'user'; - tag: string; + tag?: string; }; export default Typing; From 3d1b8a57ac3d8b9e9874a06066a89bce053650ad Mon Sep 17 00:00:00 2001 From: anjalinitd Date: Tue, 5 Apr 2022 17:21:55 +0530 Subject: [PATCH 4/6] updated tags and docs --- docs/HOOKS.md | 4 +++- packages/core/src/reducers/typing.js | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/HOOKS.md b/docs/HOOKS.md index 856d7034f0..c6e547cdd0 100644 --- a/docs/HOOKS.md +++ b/docs/HOOKS.md @@ -137,13 +137,14 @@ interface Typing { expireAt: number; name: string; role: 'bot' | 'user'; + tag: string; } useActiveTyping(expireAfter?: number): [{ [id: string]: Typing }] ``` -This hook will return a list of participants who are actively typing, including the start typing time (`at`) and expiration time (`expireAt`), the name and the role of the participant. +This hook will return a list of participants who are actively typing, including the start typing time (`at`) and expiration time (`expireAt`), the name and the role of the participant and a (`tag`) as an additional property we wish to pass to receiver.. If the participant sends a message after the typing activity, the participant will be explicitly removed from the list. If no messages or typing activities are received, the participant is considered inactive and not listed in the result. To keep the typing indicator active, participants should continuously send the typing activity. @@ -906,6 +907,7 @@ interface Typing { expireAt: number; name: string; role: 'bot' | 'user'; + tag: string; } useRenderTypingIndicator(): diff --git a/packages/core/src/reducers/typing.js b/packages/core/src/reducers/typing.js index 136d3a15e6..e4e23f00f3 100644 --- a/packages/core/src/reducers/typing.js +++ b/packages/core/src/reducers/typing.js @@ -12,7 +12,7 @@ export default function lastTyping(state = DEFAULT_STATE, { payload, type }) { if (type === INCOMING_ACTIVITY || type === POST_ACTIVITY_PENDING) { const { activity: { - from: { id, name, role }, + from: { id, name, role, tag }, type: activityType } } = payload; @@ -21,7 +21,8 @@ export default function lastTyping(state = DEFAULT_STATE, { payload, type }) { state = updateIn(state, [id], () => ({ at: Date.now(), name, - role + role, + tag })); } else if (activityType === 'message') { state = updateIn(state, [id]); From 082cee57ae75a2e03a5d2df153fb0c7440931566 Mon Sep 17 00:00:00 2001 From: anjalinitd Date: Wed, 6 Apr 2022 16:27:01 +0530 Subject: [PATCH 5/6] updated PR template --- .github/PULL_REQUEST_TEMPLATE.md | 6 ++++++ CHANGELOG.md | 1 + 2 files changed, 7 insertions(+) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 82e881a289..6ecea3c9fc 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -4,10 +4,14 @@ ## Changelog Entry +## Changed + +- Added a tag attribute for from object for typing indicator. ## Description +- BotFramework-webchat-adapter sends from object as part of typing indicator activity which is mapped to typing object in Botframeork-webchat. Added a new tag in adapter as well as webchat to pass tag to receiver side to indicate sender is typing in public/Internal panel. (We have a single adapter for two react webchat's one is public other is internal to distinguish between the two we need tag params) ## Design @@ -16,6 +20,8 @@ ## Specific Changes +- Added a tag attribute for typing object in api/hooks +- Mapped to tag for from object for any incoming_activity for typing indicator ## - diff --git a/CHANGELOG.md b/CHANGELOG.md index ae2fe264e2..c51aa51670 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Changed +- Added a tag attribute for from object for typing indicator - Bumped all dependencies to the latest versions, by [@compulim](https://github.com/compulim) in PR [#4195](https://github.com/microsoft/BotFramework-WebChat/pull/4195) - Production dependencies - [`@babel/runtime@7.17.2`](https://npmjs.com/package/@babel/runtime) From 9d37720ac2af3134471414831f5310de8f97c746 Mon Sep 17 00:00:00 2001 From: anjalinitd Date: Wed, 6 Apr 2022 16:35:19 +0530 Subject: [PATCH 6/6] remove unwanted changes --- .github/PULL_REQUEST_TEMPLATE.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 6ecea3c9fc..82e881a289 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -4,14 +4,10 @@ ## Changelog Entry -## Changed - -- Added a tag attribute for from object for typing indicator. ## Description -- BotFramework-webchat-adapter sends from object as part of typing indicator activity which is mapped to typing object in Botframeork-webchat. Added a new tag in adapter as well as webchat to pass tag to receiver side to indicate sender is typing in public/Internal panel. (We have a single adapter for two react webchat's one is public other is internal to distinguish between the two we need tag params) ## Design @@ -20,8 +16,6 @@ ## Specific Changes -- Added a tag attribute for typing object in api/hooks -- Mapped to tag for from object for any incoming_activity for typing indicator ## -