Skip to content

Commit 19831c9

Browse files
authored
Complete deprecation of activityMiddleware.nextVisibleActivity and activityMiddleware.sameTimestampGroup (#5565)
* Remove deprecated nextVisibleActivity * Update PR number
1 parent 3db56b7 commit 19831c9

File tree

11 files changed

+45
-73
lines changed

11 files changed

+45
-73
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Notes: web developers are advised to use [`~` (tilde range)](https://github.com/
4444
- `activityMiddleware` is being deprecated in favor of [`polymiddleware`](./docs/MIDDLEWARE.md). It will be removed on or after 2027-08-16, related to PR [#5515](https://github.com/microsoft/BotFramework-WebChat/pull/5515)
4545
- Root-level (unconnected) `Claim` entity is being deprecated, in PR [#5564](https://github.com/microsoft/BotFramework-WebChat/pull/5564), by [@compulim](https://github.com/compulim). It will be removed on or after 2027-08-29
4646
- Use `entities[@id=""][@type="Message"].citation[@type="Claim"]` instead
47+
- `activityStatusMiddleware.nextVisibleActivity` and `activityStatusMiddleware.sameTimestampGroup` is removed after deprecation, in PR [#5565](https://github.com/microsoft/BotFramework-WebChat/issues/5565), by [@compulim](https://github.com/compulim)
4748

4849
### Added
4950

@@ -296,6 +297,8 @@ Notes: web developers are advised to use [`~` (tilde range)](https://github.com/
296297
- `activityMiddleware` is being deprecated in favor of [`polymiddleware`](./docs/MIDDLEWARE.md). It will be removed on or after 2027-08-16, related to PR [#5515](https://github.com/microsoft/BotFramework-WebChat/pull/5515)
297298
- Root-level (unconnected) `Claim` entity is being deprecated, in PR [#5564](https://github.com/microsoft/BotFramework-WebChat/pull/5564), by [@compulim](https://github.com/compulim). It will be removed on or after 2027-08-29
298299
- Use `entities[@id=""][@type="Message"].citation[@type="Claim"]` instead
300+
- `activityStatusMiddleware.nextVisibleActivity` and `activityStatusMiddleware.sameTimestampGroup` is being deprecated and will be removed on or after 2022-07-22, in PR [#4362](https://github.com/microsoft/BotFramework-WebChat/issues/4362), by [@compulim](https://github.com/compulim)
301+
- Completed deprecation, in PR [#5565](https://github.com/microsoft/BotFramework-WebChat/issues/5565), by [@compulim](https://github.com/compulim)
299302

300303
### Samples
301304

__tests__/html/transcript.legacyActivityMiddleware.passwordInput.html

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en-US">
33
<head>
44
<link href="/assets/activityGrouping.css" rel="stylesheet" type="text/css" />
@@ -58,10 +58,10 @@
5858
}
5959
} = window;
6060

61-
const PasswordInputActivity = ({ activity, nextVisibleActivity }) => {
61+
const PasswordInputActivity = ({ activity }) => {
6262
const [twoFACode, setTwoFACode] = useState('');
6363
const [submitted, setSubmitted] = useState(false);
64-
const renderActivityStatus = useCreateActivityStatusRenderer()({ activity, nextVisibleActivity });
64+
const renderActivityStatus = useCreateActivityStatusRenderer()({ activity });
6565
const sendPostBack = useSendPostBack();
6666

6767
const handleCodeChange = useCallback(
@@ -101,15 +101,18 @@
101101
);
102102
};
103103

104-
const activityMiddleware = () => next => (...args) => {
105-
const [{ activity, nextVisibleActivity }] = args;
104+
const activityMiddleware =
105+
() =>
106+
next =>
107+
(...args) => {
108+
const [{ activity }] = args;
106109

107-
if (activity.type === 'password-input') {
108-
return () => <PasswordInputActivity activity={activity} nextVisibleActivity={nextVisibleActivity} />;
109-
}
110+
if (activity.type === 'password-input') {
111+
return () => <PasswordInputActivity activity={activity} />;
112+
}
110113

111-
return next(...args);
112-
};
114+
return next(...args);
115+
};
113116

114117
run(async function () {
115118
const now = Date.now();

__tests__/html2/activityGrouping/activityGrouping.legacyActivityStatusMiddleware.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en-US">
33
<head>
44
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
@@ -38,8 +38,8 @@
3838
activity: {
3939
from: { role }
4040
},
41-
sendState,
42-
sameTimestampGroup
41+
hideTimestamp,
42+
sendState
4343
}
4444
] = args;
4545

@@ -56,7 +56,7 @@
5656
<span className="activity-status__send-failed">Send failed.</span>
5757
</span>
5858
);
59-
} else if (!sameTimestampGroup) {
59+
} else if (!hideTimestamp) {
6060
return (
6161
<span className="activity-status">
6262
<span className="activity-status__timestamp-pretext">{role === 'user' ? 'User at ' : 'Bot at '}</span>

docs/HOOKS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,8 @@ This hook will return a function that, when called with a `Date` object, `number
959959
960960
## `useRenderActivity`
961961
962+
> Deprecation notes: this hook is being deprecated and replaced by `useBuildRenderActivityCallback`, it will be removed on or after 2027-08-16.
963+
962964
<!-- prettier-ignore-start -->
963965
```js
964966
useRenderActivity(

packages/api-middleware/src/internal/createActivityPolymiddlewareFromLegacy.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ function createActivityPolymiddlewareFromLegacy(
9696
);
9797

9898
return ({ activity }) => {
99-
// TODO: [P1] `nextVisibleActivity` is deprecated and should be removed.
100-
const legacyResult = legacyHandler({ activity, nextVisibleActivity: undefined as any });
99+
const legacyResult = legacyHandler({ activity });
101100

102101
if (!legacyResult) {
103102
// Legacy cannot fallback to poly middleware due to signature incompatibility.

packages/api-middleware/src/legacy/activityMiddleware.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ type LegacyActivityComponent = (props: LegacyActivityProps) => Exclude<ReactNode
1616

1717
type LegacyActivityComponentFactoryOptions = {
1818
activity: WebChatActivity;
19-
nextVisibleActivity: WebChatActivity;
2019
};
2120

2221
type LegacyActivityComponentFactory = (
Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,29 @@
11
/* eslint react/prop-types: "off" */
22
/* eslint react/require-default-props: "off" */
33

4-
import type { WebChatActivity } from 'botframework-webchat-core';
4+
import { type WebChatActivity } from 'botframework-webchat-core';
55
import React, { memo, useMemo, type ReactNode } from 'react';
66

77
import useGetKeyByActivity from '../hooks/useGetKeyByActivity';
88
import useSendStatusByActivityKey from '../hooks/useSendStatusByActivityKey';
9-
import type { RenderActivityStatus } from '../types/ActivityStatusMiddleware';
10-
import type { SendStatus } from '../types/SendStatus';
9+
import { type RenderActivityStatus } from '../types/ActivityStatusMiddleware';
10+
import { type SendStatus } from '../types/SendStatus';
1111
import useWebChatAPIContext from './internal/useWebChatAPIContext';
1212

1313
type ActivityStatusContainerCoreProps = Readonly<{
1414
activity: WebChatActivity;
1515
hideTimestamp: boolean;
16-
nextVisibleActivity: WebChatActivity;
1716
sendStatus: SendStatus;
1817
}>;
1918

2019
const ActivityStatusContainerCore = memo(
21-
({ activity, hideTimestamp, nextVisibleActivity, sendStatus }: ActivityStatusContainerCoreProps) => {
20+
({ activity, hideTimestamp, sendStatus }: ActivityStatusContainerCoreProps) => {
2221
const { activityStatusRenderer: createActivityStatusRenderer }: { activityStatusRenderer: RenderActivityStatus } =
2322
useWebChatAPIContext();
2423

2524
return createActivityStatusRenderer({
2625
activity,
2726
hideTimestamp,
28-
nextVisibleActivity, // "nextVisibleActivity" is for backward compatibility, please remove this line on or after 2022-07-22.
29-
sameTimestampGroup: hideTimestamp, // "sameTimestampGroup" is for backward compatibility, please remove this line on or after 2022-07-22.
3027
sendState: sendStatus === 'send failed' || sendStatus === 'sent' ? sendStatus : 'sending'
3128
});
3229
}
@@ -35,45 +32,28 @@ const ActivityStatusContainerCore = memo(
3532
type ActivityStatusContainerProps = Readonly<{
3633
activity: WebChatActivity;
3734
hideTimestamp: boolean;
38-
nextVisibleActivity: WebChatActivity;
3935
}>;
4036

41-
const ActivityStatusContainer = memo(
42-
({ activity, hideTimestamp, nextVisibleActivity }: ActivityStatusContainerProps) => {
43-
const [sendStatusByActivityKey] = useSendStatusByActivityKey();
44-
const getKeyByActivity = useGetKeyByActivity();
37+
const ActivityStatusContainer = memo(({ activity, hideTimestamp }: ActivityStatusContainerProps) => {
38+
const [sendStatusByActivityKey] = useSendStatusByActivityKey();
39+
const getKeyByActivity = useGetKeyByActivity();
4540

46-
const key = getKeyByActivity(activity);
41+
const key = getKeyByActivity(activity);
4742

48-
const sendStatus = (typeof key === 'string' && sendStatusByActivityKey.get(key)) || 'sent';
43+
const sendStatus = (typeof key === 'string' && sendStatusByActivityKey.get(key)) || 'sent';
4944

50-
return (
51-
<ActivityStatusContainerCore
52-
activity={activity}
53-
hideTimestamp={hideTimestamp}
54-
nextVisibleActivity={nextVisibleActivity}
55-
sendStatus={sendStatus}
56-
/>
57-
);
58-
}
59-
);
45+
return <ActivityStatusContainerCore activity={activity} hideTimestamp={hideTimestamp} sendStatus={sendStatus} />;
46+
});
6047

6148
export type ActivityStatusRenderer = (renderOptions: {
6249
activity: WebChatActivity;
63-
nextVisibleActivity: WebChatActivity;
6450
}) => (props?: { hideTimestamp?: boolean }) => ReactNode;
6551

6652
export default function useCreateActivityStatusRenderer(): ActivityStatusRenderer {
6753
return useMemo<ActivityStatusRenderer>(
6854
() =>
69-
({ activity, nextVisibleActivity }) =>
70-
({ hideTimestamp } = {}) => (
71-
<ActivityStatusContainer
72-
activity={activity}
73-
hideTimestamp={hideTimestamp}
74-
nextVisibleActivity={nextVisibleActivity}
75-
/>
76-
),
55+
({ activity }) =>
56+
({ hideTimestamp } = {}) => <ActivityStatusContainer activity={activity} hideTimestamp={hideTimestamp} />,
7757
[]
7858
);
7959
}

packages/api/src/legacy/LegacyActivityBridge.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,7 @@ function LegacyActivityBridge(props: LegacyActivityBridgeComponentProps) {
3232
const renderAvatarRaw = useCreateAvatarRenderer();
3333

3434
const renderActivityStatus = useMemo(
35-
() =>
36-
createActivityStatusRenderer(
37-
Object.freeze({
38-
activity,
39-
nextVisibleActivity: undefined
40-
})
41-
),
35+
() => createActivityStatusRenderer(Object.freeze({ activity })),
4236
[activity, createActivityStatusRenderer]
4337
);
4438
const renderAvatar = useMemo(

packages/api/src/types/ActivityStatusMiddleware.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { ReactElement } from 'react';
21
import type { WebChatActivity } from 'botframework-webchat-core';
2+
import type { ReactElement } from 'react';
33

44
import type { SendStatus } from '../types/SendStatus';
55

@@ -8,14 +8,6 @@ type RenderActivityStatusOptions = {
88
activity: WebChatActivity;
99
hideTimestamp: boolean;
1010
sendState: SendStatus;
11-
12-
// "nextVisibleActivity" is for backward compatibility, please remove this line on or after 2022-07-22.
13-
/** @deprecated */
14-
nextVisibleActivity: WebChatActivity;
15-
16-
// "sameTimestampGroup" is for backward compatibility, please remove this line on or after 2022-07-22.
17-
/** @deprecated */
18-
sameTimestampGroup: boolean;
1911
};
2012

2113
type RenderActivityStatus = (options: RenderActivityStatusOptions) => ReactElement;

samples/05.custom-components/f.password-input/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282

8383
const { useCallback, useState } = window.React;
8484

85-
const PasswordInputActivity = ({ activity, nextVisibleActivity }) => {
85+
const PasswordInputActivity = ({ activity }) => {
8686
const [twoFACode, setTwoFACode] = useState('');
8787
const [submitted, setSubmitted] = useState(false);
8888
const renderActivityStatus = useCreateActivityStatusRenderer()({ activity, sendState: 'sent' });
@@ -140,13 +140,13 @@
140140
const activityMiddleware =
141141
() =>
142142
next =>
143-
({ activity, nextVisibleActivity, ...otherArgs }) => {
143+
({ activity, ...otherArgs }) => {
144144
const { name, type } = activity;
145145

146146
if (type === 'event' && name === 'passwordInput') {
147-
return () => <PasswordInputActivity activity={activity} nextVisibleActivity={nextVisibleActivity} />;
147+
return () => <PasswordInputActivity activity={activity} />;
148148
} else {
149-
return next({ activity, nextVisibleActivity, ...otherArgs });
149+
return next({ activity, ...otherArgs });
150150
}
151151
};
152152

0 commit comments

Comments
 (0)