/
senderAction.ts
51 lines (45 loc) · 1.84 KB
/
senderAction.ts
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
39
40
41
42
43
44
45
46
47
48
49
50
51
import { makeUnitSegment, UnitSegment } from '@machinat/core/renderer';
import { makeMessengerComponent } from '../utils';
import type { MessengerComponent, SenderActionValue } from '../types';
const MARK_SEEN_VALUE = { sender_action: 'mark_seen' as const };
const TYPING_OFF_VALUE = { sender_action: 'typing_off' as const };
const TYPING_ON_VALUE = { sender_action: 'typing_on' as const };
/**
* Display the confirmation icon.
* @category Component
* @props `{}`
* @guides Check official [doc](https://developers.facebook.com/docs/messenger-platform/send-messages/sender-actions)
* and [reference](https://developers.facebook.com/docs/messenger-platform/reference/send-api/).
*/
export const MarkSeen: MessengerComponent<
{},
UnitSegment<SenderActionValue>
> = makeMessengerComponent(function MarkSeen(node, path) {
return [makeUnitSegment(node, path, MARK_SEEN_VALUE)];
});
/**
* Display the typing bubble.
* @category Component
* @props `{}`
* @guides Check official [doc](https://developers.facebook.com/docs/messenger-platform/send-messages/sender-actions)
* and [reference](https://developers.facebook.com/docs/messenger-platform/reference/send-api/).
*/
export const TypingOn: MessengerComponent<
{},
UnitSegment<SenderActionValue>
> = makeMessengerComponent(function TypingOn(node, path) {
return [makeUnitSegment(node, path, TYPING_ON_VALUE)];
});
/**
* Remove the typing bubble.
* @category Component
* @props `{}`
* @guides Check official [doc](https://developers.facebook.com/docs/messenger-platform/send-messages/sender-actions)
* and [reference](https://developers.facebook.com/docs/messenger-platform/reference/send-api/).
*/
export const TypingOff: MessengerComponent<
{},
UnitSegment<SenderActionValue>
> = makeMessengerComponent(function TypingOff(node, path) {
return [makeUnitSegment(node, path, TYPING_OFF_VALUE)];
});