forked from microsoft/BotFramework-WebChat
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathactivityMiddleware.ts
More file actions
38 lines (29 loc) · 1.76 KB
/
activityMiddleware.ts
File metadata and controls
38 lines (29 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// TODO: This is moved from /api, need to revisit/rewrite everything in this file.
import { type WebChatActivity } from 'botframework-webchat-core';
import { type ReactNode } from 'react';
import { type LegacyRenderAttachment } from './attachmentMiddleware';
type LegacyActivityProps = {
children?: never | undefined;
hideTimestamp: boolean;
renderActivityStatus: (options: { hideTimestamp: boolean }) => ReactNode;
renderAvatar: false | (() => Exclude<ReactNode, boolean | null | undefined>);
showCallout: boolean;
};
type LegacyActivityComponent = (props: LegacyActivityProps) => Exclude<ReactNode, boolean | null | undefined>;
type LegacyActivityComponentFactoryOptions = {
activity: WebChatActivity;
};
type LegacyActivityComponentFactory = (
options: LegacyActivityComponentFactoryOptions
) => LegacyActivityComponent | false;
// TODO: [P2] This is inherited from our older signature (pre-hook) which requires passing "renderAttachment" argument.
// With hooks, the middleware should not need "renderAttachment", they can grab it from "useCreateAttachmentRenderer" hook.
type LegacyRenderActivity = (
renderAttachment: LegacyRenderAttachment,
{ hideTimestamp, renderActivityStatus, renderAvatar, showCallout }: LegacyActivityProps
) => Exclude<ReactNode, boolean>;
type LegacyActivityRenderer = (options: LegacyActivityComponentFactoryOptions) => LegacyRenderActivity | false;
// The middleware created by the web developer, are using the legacy signature (with "renderAttachment" argument).
type LegacyActivityEnhancer = (next: LegacyActivityRenderer) => LegacyActivityRenderer;
type LegacyActivityMiddleware = () => LegacyActivityEnhancer;
export type { LegacyActivityComponentFactory, LegacyActivityMiddleware, LegacyActivityProps, LegacyActivityRenderer };