Skip to content

Commit b61887c

Browse files
committed
Use isActionRequireReview
1 parent 7ae503b commit b61887c

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

packages/component/src/ActivityFeedback/providers/ActivityFeedbackComposer.tsx

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { hooks } from 'botframework-webchat-api';
2-
import { reactNode, validateProps } from 'botframework-webchat-react-valibot';
32
import {
43
getOrgSchemaMessage,
54
parseAction,
65
type OrgSchemaAction,
76
type WebChatActivity
87
} from 'botframework-webchat-core';
8+
import { reactNode, validateProps } from 'botframework-webchat-react-valibot';
99
import random from 'math-random';
1010
import React, { memo, useCallback, useMemo, useRef, useState, type Dispatch, type SetStateAction } from 'react';
1111
import { wrapWith } from 'react-wrap-with';
@@ -19,6 +19,7 @@ import getDisclaimerFromFeedbackLoop from '../private/getDisclaimerFromFeedbackL
1919
import hasFeedbackLoop from '../private/hasFeedbackLoop';
2020
import ActivityFeedbackContext, { type ActivityFeedbackContextType } from './private/ActivityFeedbackContext';
2121
import { ActivityFeedbackFocusPropagationScope, usePropagateActivityFeedbackFocus } from './private/FocusPropagation';
22+
import isActionRequireReview from '../private/isActionRequireReview';
2223

2324
const { usePonyfill, usePostActivity } = hooks;
2425

@@ -45,12 +46,10 @@ function ActivityFeedbackComposer(props: ActivityFeedbackComposerProps) {
4546
const [{ clearTimeout, setTimeout }] = usePonyfill();
4647
const [feedbackText, setFeedbackText, feedbackTextRef] = useStateWithRef<string | undefined>();
4748

48-
const isFeedbackLoopEnabled = useMemo(() => hasFeedbackLoop(activityFromProps), [activityFromProps]);
49-
5049
const activity: WebChatActivity = useMemo(
5150
() =>
5251
// Force enable feedback loop until service fixed their issue.
53-
isFeedbackLoopEnabled
52+
hasFeedbackLoop(activityFromProps)
5453
? Object.freeze({
5554
...activityFromProps,
5655
entities: [
@@ -86,7 +85,7 @@ function ActivityFeedbackComposer(props: ActivityFeedbackComposerProps) {
8685
]
8786
})
8887
: activityFromProps,
89-
[activityFromProps, isFeedbackLoopEnabled]
88+
[activityFromProps]
9089
);
9190

9291
const activityRef = useRefFrom(activity);
@@ -223,7 +222,7 @@ function ActivityFeedbackComposer(props: ActivityFeedbackComposerProps) {
223222
const isLegacyAction = action['@type'] === 'VoteAction';
224223

225224
// TODO: We should update this to use W3C Hydra.1
226-
if (isFeedbackLoopEnabled) {
225+
if (isActionRequireReview(action)) {
227226
postActivity({
228227
name: 'message/submitAction',
229228
replyToId: activityRef.current.id,
@@ -244,15 +243,7 @@ function ActivityFeedbackComposer(props: ActivityFeedbackComposerProps) {
244243
} as any);
245244
}
246245
},
247-
[
248-
actionsRef,
249-
actionStateRef,
250-
activityRef,
251-
feedbackTextRef,
252-
isFeedbackLoopEnabled,
253-
postActivity,
254-
setActionStateWithRefresh
255-
]
246+
[actionsRef, actionStateRef, activityRef, feedbackTextRef, postActivity, setActionStateWithRefresh]
256247
);
257248

258249
const selectedAction = useMemo<OrgSchemaAction | undefined>(

0 commit comments

Comments
 (0)