@planningcenter/chat-react-native 3.2.0-rc.25 → 3.2.0-rc.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/conversation/message_form/message_form_attachment_image.d.ts +13 -0
- package/build/components/conversation/message_form/message_form_attachment_image.d.ts.map +1 -0
- package/build/components/conversation/message_form/message_form_attachment_image.js +78 -0
- package/build/components/conversation/message_form/message_form_attachment_image.js.map +1 -0
- package/build/components/conversation/message_form.d.ts.map +1 -1
- package/build/components/conversation/message_form.js +128 -16
- package/build/components/conversation/message_form.js.map +1 -1
- package/build/components/conversations/conversation_actions.d.ts +2 -2
- package/build/components/conversations/conversation_actions.d.ts.map +1 -1
- package/build/components/conversations/conversation_actions.js.map +1 -1
- package/build/components/conversations/conversation_preview.d.ts +3 -1
- package/build/components/conversations/conversation_preview.d.ts.map +1 -1
- package/build/components/conversations/conversation_preview.js +2 -2
- package/build/components/conversations/conversation_preview.js.map +1 -1
- package/build/components/group_conversation_list.d.ts +19 -0
- package/build/components/group_conversation_list.d.ts.map +1 -0
- package/build/components/group_conversation_list.js +48 -0
- package/build/components/group_conversation_list.js.map +1 -0
- package/build/components/index.d.ts +1 -0
- package/build/components/index.d.ts.map +1 -1
- package/build/components/index.js +1 -0
- package/build/components/index.js.map +1 -1
- package/build/contexts/conversations_context.js +1 -1
- package/build/contexts/conversations_context.js.map +1 -1
- package/build/hooks/attachments/supported_extensions.d.ts +2 -0
- package/build/hooks/attachments/supported_extensions.d.ts.map +1 -0
- package/build/hooks/attachments/supported_extensions.js +48 -0
- package/build/hooks/attachments/supported_extensions.js.map +1 -0
- package/build/hooks/index.d.ts +4 -0
- package/build/hooks/index.d.ts.map +1 -1
- package/build/hooks/index.js +4 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/use_api.d.ts +2 -2
- package/build/hooks/use_api.d.ts.map +1 -1
- package/build/hooks/use_api.js.map +1 -1
- package/build/hooks/use_attachment_uploader.d.ts +26 -0
- package/build/hooks/use_attachment_uploader.d.ts.map +1 -0
- package/build/hooks/use_attachment_uploader.js +111 -0
- package/build/hooks/use_attachment_uploader.js.map +1 -0
- package/build/hooks/use_upload_client.d.ts +28 -0
- package/build/hooks/use_upload_client.d.ts.map +1 -0
- package/build/hooks/use_upload_client.js +32 -0
- package/build/hooks/use_upload_client.js.map +1 -0
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/navigation/index.d.ts +2 -2
- package/build/navigation/index.d.ts.map +1 -1
- package/build/navigation/index.js +2 -2
- package/build/navigation/index.js.map +1 -1
- package/build/screens/conversation_new/components/groups_form.d.ts +3 -1
- package/build/screens/conversation_new/components/groups_form.d.ts.map +1 -1
- package/build/screens/conversation_new/components/groups_form.js +7 -9
- package/build/screens/conversation_new/components/groups_form.js.map +1 -1
- package/build/screens/conversation_new/conversation_new_screen.d.ts.map +1 -1
- package/build/screens/conversation_new/conversation_new_screen.js +2 -2
- package/build/screens/conversation_new/conversation_new_screen.js.map +1 -1
- package/build/screens/conversation_screen.d.ts.map +1 -1
- package/build/screens/conversation_screen.js +27 -2
- package/build/screens/conversation_screen.js.map +1 -1
- package/build/screens/conversations/conversations_screen.js +1 -1
- package/build/screens/conversations/conversations_screen.js.map +1 -1
- package/build/utils/native_adapters/configuration.d.ts +4 -1
- package/build/utils/native_adapters/configuration.d.ts.map +1 -1
- package/build/utils/native_adapters/configuration.js +13 -1
- package/build/utils/native_adapters/configuration.js.map +1 -1
- package/build/utils/native_adapters/image_picker.d.ts +25 -0
- package/build/utils/native_adapters/image_picker.d.ts.map +1 -0
- package/build/utils/native_adapters/image_picker.js +9 -0
- package/build/utils/native_adapters/image_picker.js.map +1 -0
- package/build/utils/native_adapters/index.d.ts +1 -0
- package/build/utils/native_adapters/index.d.ts.map +1 -1
- package/build/utils/native_adapters/index.js +1 -0
- package/build/utils/native_adapters/index.js.map +1 -1
- package/build/utils/upload_uri.d.ts +23 -0
- package/build/utils/upload_uri.d.ts.map +1 -0
- package/build/utils/upload_uri.js +60 -0
- package/build/utils/upload_uri.js.map +1 -0
- package/package.json +2 -2
- package/src/components/conversation/message_form/message_form_attachment_image.tsx +121 -0
- package/src/components/conversation/message_form.tsx +197 -31
- package/src/components/conversations/conversation_actions.tsx +2 -2
- package/src/components/conversations/conversation_preview.tsx +8 -2
- package/src/components/group_conversation_list.tsx +82 -0
- package/src/components/index.tsx +1 -0
- package/src/contexts/conversations_context.tsx +1 -1
- package/src/hooks/attachments/supported_extensions.ts +47 -0
- package/src/hooks/index.ts +4 -0
- package/src/hooks/use_api.ts +2 -2
- package/src/hooks/use_attachment_uploader.ts +179 -0
- package/src/hooks/use_upload_client.ts +67 -0
- package/src/index.tsx +1 -0
- package/src/navigation/index.tsx +2 -5
- package/src/screens/conversation_new/components/groups_form.tsx +11 -11
- package/src/screens/conversation_new/conversation_new_screen.tsx +6 -2
- package/src/screens/conversation_screen.tsx +31 -1
- package/src/screens/conversations/conversations_screen.tsx +1 -1
- package/src/utils/native_adapters/configuration.ts +15 -1
- package/src/utils/native_adapters/image_picker.ts +31 -0
- package/src/utils/native_adapters/index.ts +1 -0
- package/src/utils/upload_uri.ts +69 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleSheet, View } from 'react-native';
|
|
3
|
+
import { useConversations } from '../hooks/use_conversations';
|
|
4
|
+
import { ConversationPreview } from './conversations/conversation_preview';
|
|
5
|
+
import { useTheme } from '../hooks';
|
|
6
|
+
import { Icon, Text } from './display';
|
|
7
|
+
/**
|
|
8
|
+
* GroupConversations is a component that displays a list of conversations
|
|
9
|
+
* for a specific group.
|
|
10
|
+
*
|
|
11
|
+
* Originally designed for use in CCA.
|
|
12
|
+
*/
|
|
13
|
+
export const GroupConversations = ({ limit, onConversationPress, style, ListHeaderComponent, ListOverflowFooterComponent, chat_group_graph_id, }) => {
|
|
14
|
+
const styles = useStyles();
|
|
15
|
+
const { conversations = [] } = useConversations({
|
|
16
|
+
chat_group_graph_id,
|
|
17
|
+
group_source_app_name: undefined,
|
|
18
|
+
});
|
|
19
|
+
return (<View style={style}>
|
|
20
|
+
<>{ListHeaderComponent}</>
|
|
21
|
+
{conversations.length === 0 && (<View style={styles.listEmpty}>
|
|
22
|
+
<Icon size={24} name="general.textMessage" style={styles.listEmptyIcon}/>
|
|
23
|
+
<Text variant="secondary">No conversations found</Text>
|
|
24
|
+
</View>)}
|
|
25
|
+
{conversations.slice(0, limit).map(conversation => (<ConversationPreview style={styles.conversation} key={conversation.id} showBadges={false} conversation={conversation} onPress={() => onConversationPress(conversation)}/>))}
|
|
26
|
+
{conversations.length > (limit || 0) && <>{ListOverflowFooterComponent}</>}
|
|
27
|
+
</View>);
|
|
28
|
+
};
|
|
29
|
+
const useStyles = () => {
|
|
30
|
+
const { colors } = useTheme();
|
|
31
|
+
return StyleSheet.create({
|
|
32
|
+
constainer: {},
|
|
33
|
+
conversation: {
|
|
34
|
+
borderBottomWidth: 0,
|
|
35
|
+
},
|
|
36
|
+
listItem: { color: colors.fillColorNeutral020 },
|
|
37
|
+
listEmpty: {
|
|
38
|
+
justifyContent: 'center',
|
|
39
|
+
alignItems: 'center',
|
|
40
|
+
paddingVertical: 16,
|
|
41
|
+
gap: 8,
|
|
42
|
+
},
|
|
43
|
+
listEmptyIcon: {
|
|
44
|
+
color: colors.fillColorNeutral020,
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=group_conversation_list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group_conversation_list.js","sourceRoot":"","sources":["../../src/components/group_conversation_list.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,UAAU,EAAE,IAAI,EAAa,MAAM,cAAc,CAAA;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAA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Y,CAAC,CAAC,YAAY,CAAC,CAC3B,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC,EACjD,CACH,CAAC,CACF;MAAA,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,KAAK,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,2BAA2B,CAAC,GAAG,CAC5E;IAAA,EAAE,IAAI,CAAC,CACR,CAAA;AACH,CAAC,CAAA;AAED,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAA;IAC7B,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,UAAU,EAAE,EAAE;QACd,YAAY,EAAE;YACZ,iBAAiB,EAAE,CAAC;SACrB;QACD,QAAQ,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,mBAAmB,EAAE;QAC/C,SAAS,EAAE;YACT,cAAc,EAAE,QAAQ;YACxB,UAAU,EAAE,QAAQ;YACpB,eAAe,EAAE,EAAE;YACnB,GAAG,EAAE,CAAC;SACP;QACD,aAAa,EAAE;YACb,KAAK,EAAE,MAAM,CAAC,mBAAmB;SAClC;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import React from 'react'\nimport { StyleSheet, View, ViewStyle } from 'react-native'\nimport { useConversations } from '../hooks/use_conversations'\nimport { ConversationPreview } from './conversations/conversation_preview'\nimport { ConversationRequestArgs } from '../utils/request/conversation'\nimport { useTheme } from '../hooks'\nimport { Icon, Text } from './display'\n\ninterface GroupConversationsProps extends Partial<ConversationRequestArgs> {\n limit?: number\n onConversationPress: (conversation: any) => void\n style?: ViewStyle\n ListHeaderComponent?:\n | React.ComponentType<any>\n | React.ReactElement<any, string | React.JSXElementConstructor<any>>\n ListOverflowFooterComponent?:\n | React.ComponentType<any>\n | React.ReactElement<any, string | React.JSXElementConstructor<any>>\n}\n\n/**\n * GroupConversations is a component that displays a list of conversations\n * for a specific group.\n *\n * Originally designed for use in CCA.\n */\nexport const GroupConversations = ({\n limit,\n onConversationPress,\n style,\n ListHeaderComponent,\n ListOverflowFooterComponent,\n chat_group_graph_id,\n}: GroupConversationsProps) => {\n const styles = useStyles()\n const { conversations = [] } = useConversations({\n chat_group_graph_id,\n group_source_app_name: undefined,\n })\n\n return (\n <View style={style}>\n <>{ListHeaderComponent}</>\n {conversations.length === 0 && (\n <View style={styles.listEmpty}>\n <Icon size={24} name=\"general.textMessage\" style={styles.listEmptyIcon} />\n <Text variant=\"secondary\">No conversations found</Text>\n </View>\n )}\n {conversations.slice(0, limit).map(conversation => (\n <ConversationPreview\n style={styles.conversation}\n key={conversation.id}\n showBadges={false}\n conversation={conversation}\n onPress={() => onConversationPress(conversation)}\n />\n ))}\n {conversations.length > (limit || 0) && <>{ListOverflowFooterComponent}</>}\n </View>\n )\n}\n\nconst useStyles = () => {\n const { colors } = useTheme()\n return StyleSheet.create({\n constainer: {},\n conversation: {\n borderBottomWidth: 0,\n },\n listItem: { color: colors.fillColorNeutral020 },\n listEmpty: {\n justifyContent: 'center',\n alignItems: 'center',\n paddingVertical: 16,\n gap: 8,\n },\n listEmptyIcon: {\n color: colors.fillColorNeutral020,\n },\n })\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.tsx"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAA;AAC7C,cAAc,uBAAuB,CAAA;AACrC,cAAc,WAAW,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.tsx"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAA;AAC7C,cAAc,uBAAuB,CAAA;AACrC,cAAc,WAAW,CAAA;AACzB,cAAc,2BAA2B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.tsx"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAA;AAC7C,cAAc,uBAAuB,CAAA;AACrC,cAAc,WAAW,CAAA","sourcesContent":["export * from './conversations/conversations'\nexport * from './page/error_boundary'\nexport * from './display'\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.tsx"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAA;AAC7C,cAAc,uBAAuB,CAAA;AACrC,cAAc,WAAW,CAAA;AACzB,cAAc,2BAA2B,CAAA","sourcesContent":["export * from './conversations/conversations'\nexport * from './page/error_boundary'\nexport * from './display'\nexport * from './group_conversation_list'\n"]}
|
|
@@ -18,7 +18,7 @@ const ConversationsContext = createContext({
|
|
|
18
18
|
setActiveConversationId: () => { },
|
|
19
19
|
...defaultQueryValue,
|
|
20
20
|
});
|
|
21
|
-
export const ConversationsContextProvider = ({ children, args, }) => {
|
|
21
|
+
export const ConversationsContextProvider = ({ children, args = {}, }) => {
|
|
22
22
|
const [activeConversationId, setActiveConversationId] = useState();
|
|
23
23
|
const { chat_group_graph_id, group_source_app_name } = args;
|
|
24
24
|
const query = useConversations({ chat_group_graph_id, group_source_app_name });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversations_context.js","sourceRoot":"","sources":["../../src/contexts/conversations_context.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAqB,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAE9F,OAAO,EAAE,gBAAgB,EAAyB,MAAM,4BAA4B,CAAA;AAOpF,OAAO,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAA;AAQnF,MAAM,iBAAiB,GAA0B;IAC/C,aAAa,EAAE,EAAE;IACjB,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;IACpC,KAAK,EAAE,IAAI;IACX,OAAO,EAAE,KAAK;IACd,aAAa;IACb,WAAW,EAAE,KAAK;IAClB,UAAU,EAAE,KAAK;IACjB,SAAS,EAAE,KAAK;IAChB,YAAY,EAAE,KAAK;CACpB,CAAA;AAED,MAAM,oBAAoB,GAAG,aAAa,CAA4B;IACpE,IAAI,EAAE,EAAE;IACR,oBAAoB,EAAE,SAAS;IAC/B,uBAAuB,EAAE,GAAG,EAAE,GAAE,CAAC;IACjC,GAAG,iBAAiB;CACrB,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,EAC3C,QAAQ,EACR,IAAI,
|
|
1
|
+
{"version":3,"file":"conversations_context.js","sourceRoot":"","sources":["../../src/contexts/conversations_context.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAqB,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAE9F,OAAO,EAAE,gBAAgB,EAAyB,MAAM,4BAA4B,CAAA;AAOpF,OAAO,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAA;AAQnF,MAAM,iBAAiB,GAA0B;IAC/C,aAAa,EAAE,EAAE;IACjB,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;IACpC,KAAK,EAAE,IAAI;IACX,OAAO,EAAE,KAAK;IACd,aAAa;IACb,WAAW,EAAE,KAAK;IAClB,UAAU,EAAE,KAAK;IACjB,SAAS,EAAE,KAAK;IAChB,YAAY,EAAE,KAAK;CACpB,CAAA;AAED,MAAM,oBAAoB,GAAG,aAAa,CAA4B;IACpE,IAAI,EAAE,EAAE;IACR,oBAAoB,EAAE,SAAS;IAC/B,uBAAuB,EAAE,GAAG,EAAE,GAAE,CAAC;IACjC,GAAG,iBAAiB;CACrB,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,EAC3C,QAAQ,EACR,IAAI,GAAG,EAAE,GAC8C,EAAE,EAAE;IAC3D,MAAM,CAAC,oBAAoB,EAAE,uBAAuB,CAAC,GAAG,QAAQ,EAAsB,CAAA;IACtF,MAAM,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,GAAG,IAAI,CAAA;IAE3D,MAAM,KAAK,GAAG,gBAAgB,CAAC,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,CAAC,CAAA;IAE9E,MAAM,KAAK,GAAG,OAAO,CACnB,GAAG,EAAE,CAAC,CAAC;QACL,IAAI;QACJ,oBAAoB;QACpB,uBAAuB;QACvB,GAAG,KAAK;KACT,CAAC,EACF,CAAC,IAAI,EAAE,oBAAoB,EAAE,KAAK,CAAC,CACpC,CAAA;IAED,0BAA0B,CAAC,IAAI,CAAC,CAAA;IAEhC,OAAO,CAAC,oBAAoB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,oBAAoB,CAAC,QAAQ,CAAC,CAAA;AAChG,CAAC,CAAA;AAED,SAAS,aAAa,CACpB,QAA+B;IAI/B,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAA;AAC9C,CAAC;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAA","sourcesContent":["import React, { createContext, PropsWithChildren, useContext, useMemo, useState } from 'react'\nimport { ConversationFiltersParams } from '../screens/conversation_filters/screen_props'\nimport { useConversations, UseConversationsValue } from '../hooks/use_conversations'\nimport {\n FetchNextPageOptions,\n InfiniteQueryObserverResult,\n InfiniteData,\n} from '@tanstack/react-query'\nimport { ApiCollection, ConversationResource } from '../types'\nimport { useConversationsJoltEvents } from '../hooks/use_conversations_jolt_events'\n\ninterface ConversationsContextValue extends UseConversationsValue {\n activeConversationId?: number\n setActiveConversationId: (_id: number) => void\n args: ConversationFiltersParams\n}\n\nconst defaultQueryValue: UseConversationsValue = {\n conversations: [],\n refetch: () => Promise.resolve(null),\n error: null,\n isError: false,\n fetchNextPage,\n hasNextPage: false,\n isFetching: false,\n isFetched: false,\n isRefetching: false,\n}\n\nconst ConversationsContext = createContext<ConversationsContextValue>({\n args: {},\n activeConversationId: undefined,\n setActiveConversationId: () => {},\n ...defaultQueryValue,\n})\n\nexport const ConversationsContextProvider = ({\n children,\n args = {},\n}: PropsWithChildren<{ args: ConversationFiltersParams }>) => {\n const [activeConversationId, setActiveConversationId] = useState<number | undefined>()\n const { chat_group_graph_id, group_source_app_name } = args\n\n const query = useConversations({ chat_group_graph_id, group_source_app_name })\n\n const value = useMemo(\n () => ({\n args,\n activeConversationId,\n setActiveConversationId,\n ...query,\n }),\n [args, activeConversationId, query]\n )\n\n useConversationsJoltEvents(args)\n\n return <ConversationsContext.Provider value={value}>{children}</ConversationsContext.Provider>\n}\n\nfunction fetchNextPage(\n _options?: FetchNextPageOptions\n): Promise<\n InfiniteQueryObserverResult<InfiniteData<ApiCollection<ConversationResource>, unknown>, Response>\n> {\n throw new Error('Function not implemented.')\n}\n\nexport const useConversationsContext = () => useContext(ConversationsContext)\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supported_extensions.d.ts","sourceRoot":"","sources":["../../../src/hooks/attachments/supported_extensions.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,UA8ChC,CAAA"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export const SUPPORTED_EXTENSIONS = [
|
|
2
|
+
'.3ga',
|
|
3
|
+
'.3gp',
|
|
4
|
+
'.aac',
|
|
5
|
+
'.amr',
|
|
6
|
+
'.avi',
|
|
7
|
+
'.bmp',
|
|
8
|
+
'.doc',
|
|
9
|
+
'.docx',
|
|
10
|
+
'.gif',
|
|
11
|
+
'.h263',
|
|
12
|
+
'.h264',
|
|
13
|
+
'.heic',
|
|
14
|
+
'.heif',
|
|
15
|
+
'.jpeg',
|
|
16
|
+
'.jpg',
|
|
17
|
+
'.key',
|
|
18
|
+
'.m4a',
|
|
19
|
+
'.m4b',
|
|
20
|
+
'.m4p',
|
|
21
|
+
'.m4r',
|
|
22
|
+
'.m4v',
|
|
23
|
+
'.mkv',
|
|
24
|
+
'.mov',
|
|
25
|
+
'.mp3',
|
|
26
|
+
'.mp4',
|
|
27
|
+
'.mp4-latm',
|
|
28
|
+
'.mpeg',
|
|
29
|
+
'.mpeg4',
|
|
30
|
+
'.mpg',
|
|
31
|
+
'.numbers',
|
|
32
|
+
'.ogg',
|
|
33
|
+
'.pages',
|
|
34
|
+
'.pdf',
|
|
35
|
+
'.png',
|
|
36
|
+
'.ppt',
|
|
37
|
+
'.pptx',
|
|
38
|
+
'.rtf',
|
|
39
|
+
'.txt',
|
|
40
|
+
'.vcf',
|
|
41
|
+
'.wav',
|
|
42
|
+
'.webm',
|
|
43
|
+
'.webp',
|
|
44
|
+
'.wmv',
|
|
45
|
+
'.xls',
|
|
46
|
+
'.xlsx',
|
|
47
|
+
];
|
|
48
|
+
//# sourceMappingURL=supported_extensions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supported_extensions.js","sourceRoot":"","sources":["../../../src/hooks/attachments/supported_extensions.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,OAAO;IACP,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,WAAW;IACX,OAAO;IACP,QAAQ;IACR,MAAM;IACN,UAAU;IACV,MAAM;IACN,QAAQ;IACR,MAAM;IACN,MAAM;IACN,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,OAAO;IACP,OAAO;IACP,MAAM;IACN,MAAM;IACN,OAAO;CACR,CAAA","sourcesContent":["export const SUPPORTED_EXTENSIONS = [\n '.3ga',\n '.3gp',\n '.aac',\n '.amr',\n '.avi',\n '.bmp',\n '.doc',\n '.docx',\n '.gif',\n '.h263',\n '.h264',\n '.heic',\n '.heif',\n '.jpeg',\n '.jpg',\n '.key',\n '.m4a',\n '.m4b',\n '.m4p',\n '.m4r',\n '.m4v',\n '.mkv',\n '.mov',\n '.mp3',\n '.mp4',\n '.mp4-latm',\n '.mpeg',\n '.mpeg4',\n '.mpg',\n '.numbers',\n '.ogg',\n '.pages',\n '.pdf',\n '.png',\n '.ppt',\n '.pptx',\n '.rtf',\n '.txt',\n '.vcf',\n '.wav',\n '.webm',\n '.webp',\n '.wmv',\n '.xls',\n '.xlsx',\n]\n"]}
|
package/build/hooks/index.d.ts
CHANGED
|
@@ -6,4 +6,8 @@ export * from './use_font_scale';
|
|
|
6
6
|
export * from './use_create_android_ripple_color';
|
|
7
7
|
export * from './use_chat_permissions';
|
|
8
8
|
export * from './use_api_client';
|
|
9
|
+
export * from './use_groups_groups';
|
|
10
|
+
export * from './use_groups';
|
|
11
|
+
export * from './use_api';
|
|
12
|
+
export * from './use_api_client';
|
|
9
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,kBAAkB,CAAA;AAChC,cAAc,mCAAmC,CAAA;AACjD,cAAc,wBAAwB,CAAA;AACtC,cAAc,kBAAkB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,kBAAkB,CAAA;AAChC,cAAc,mCAAmC,CAAA;AACjD,cAAc,wBAAwB,CAAA;AACtC,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,kBAAkB,CAAA"}
|
package/build/hooks/index.js
CHANGED
|
@@ -6,4 +6,8 @@ export * from './use_font_scale';
|
|
|
6
6
|
export * from './use_create_android_ripple_color';
|
|
7
7
|
export * from './use_chat_permissions';
|
|
8
8
|
export * from './use_api_client';
|
|
9
|
+
export * from './use_groups_groups';
|
|
10
|
+
export * from './use_groups';
|
|
11
|
+
export * from './use_api';
|
|
12
|
+
export * from './use_api_client';
|
|
9
13
|
//# sourceMappingURL=index.js.map
|
package/build/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,kBAAkB,CAAA;AAChC,cAAc,mCAAmC,CAAA;AACjD,cAAc,wBAAwB,CAAA;AACtC,cAAc,kBAAkB,CAAA","sourcesContent":["export * from './use_async_storage'\nexport * from './use_theme'\nexport * from './use_suspense_api'\nexport * from './use_current_person'\nexport * from './use_font_scale'\nexport * from './use_create_android_ripple_color'\nexport * from './use_chat_permissions'\nexport * from './use_api_client'\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,kBAAkB,CAAA;AAChC,cAAc,mCAAmC,CAAA;AACjD,cAAc,wBAAwB,CAAA;AACtC,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,kBAAkB,CAAA","sourcesContent":["export * from './use_async_storage'\nexport * from './use_theme'\nexport * from './use_suspense_api'\nexport * from './use_current_person'\nexport * from './use_font_scale'\nexport * from './use_create_android_ripple_color'\nexport * from './use_chat_permissions'\nexport * from './use_api_client'\nexport * from './use_groups_groups'\nexport * from './use_groups'\nexport * from './use_api'\nexport * from './use_api_client'\n"]}
|
package/build/hooks/use_api.d.ts
CHANGED
|
@@ -175,8 +175,8 @@ export declare const useApiGet: <T extends ResourceObject | ResourceObject[]>(ar
|
|
|
175
175
|
links?: Record<string, string> | undefined;
|
|
176
176
|
meta?: Record<string, unknown> | undefined;
|
|
177
177
|
};
|
|
178
|
-
export type
|
|
179
|
-
export declare const useApiPaginator: <T extends ResourceObject>(args: ApiGetOptions, opts?:
|
|
178
|
+
export type PaginatorOptions = Omit<AnyUseSuspenseInfiniteQueryOptions, 'getNextPageParam' | 'initialPageParam' | 'queryFn' | 'queryKey'>;
|
|
179
|
+
export declare const useApiPaginator: <T extends ResourceObject>(args: ApiGetOptions, opts?: PaginatorOptions) => {
|
|
180
180
|
data: T[];
|
|
181
181
|
error: ApiError;
|
|
182
182
|
isError: true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_api.d.ts","sourceRoot":"","sources":["../../src/hooks/use_api.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kCAAkC,EAClC,YAAY,EAGb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC/E,OAAO,EAAE,UAAU,EAAe,MAAM,uBAAuB,CAAA;AAC/D,OAAO,EAAE,GAAG,EAAgB,MAAM,kBAAkB,CAAA;AAGpD,UAAU,aAAc,SAAQ,UAAU;IACx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IAErE,OAAO,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,CAAA;AAC3B,CAAC,CAAA","sourcesContent":["import {\n AnyUseSuspenseInfiniteQueryOptions,\n InfiniteData,\n useInfiniteQuery,\n useQuery,\n} from '@tanstack/react-query'\nimport { ApiCollection, ApiError, ApiResource, ResourceObject } from '../types'\nimport { GetRequest, RequestData } from '../utils/client/types'\nimport { App, useApiClient } from './use_api_client'\nimport { getRequestQueryKey, RequestQueryKey } from './use_suspense_api'\n\ninterface ApiGetOptions extends GetRequest {\n app?: App\n enabled?: boolean\n}\n\nexport const useApiGet = <T extends ResourceObject | ResourceObject[]>(args: ApiGetOptions) => {\n type Resource = ApiResource<T>\n const apiClient = useApiClient()\n\n const { data, ...query } = useQuery<Resource, ApiError>({\n queryKey: getRequestQueryKey(args),\n queryFn: ({ queryKey }) => {\n const [url, d, headers, app = 'chat'] = queryKey as RequestQueryKey\n\n return apiClient[app].get({ url, data: d, headers }) as Promise<Resource>\n },\n enabled: args.enabled,\n })\n\n return { ...data, ...query }\n}\n\ntype NextMeta = Partial<{\n offset: string\n idLt: string\n}>\n\nexport type PaginatorOptions = Omit<\n AnyUseSuspenseInfiniteQueryOptions,\n 'getNextPageParam' | 'initialPageParam' | 'queryFn' | 'queryKey'\n>\n\nexport const useApiPaginator = <T extends ResourceObject>(\n args: ApiGetOptions,\n opts?: PaginatorOptions\n) => {\n const apiClient = useApiClient()\n const query = useInfiniteQuery<\n ApiCollection<T>,\n ApiError,\n InfiniteData<ApiCollection<T>>,\n any,\n Partial<RequestData> | undefined\n >({\n queryKey: getRequestQueryKey(args),\n queryFn: ({ pageParam }) => {\n const pageParmWhere = pageParam?.where || {}\n const argsWhere = args.data.where || {}\n const where = { ...argsWhere, ...pageParmWhere }\n const app = args.app || 'chat'\n const offset = pageParam?.offset || args.data.offset\n const data = { ...args.data, where, offset }\n\n return apiClient[app].get<ApiCollection<T>>({\n url: args.url,\n data,\n })\n },\n initialPageParam: {} as Partial<RequestData>,\n getNextPageParam: lastPage => {\n const next: NextMeta = lastPage.meta?.next || {}\n const { offset, idLt } = next\n\n if (idLt) return { where: { id_lt: idLt } }\n if (offset) return { offset: Number(offset) }\n\n return undefined\n },\n enabled: args.enabled,\n ...(opts || {}),\n })\n\n const data: T[] = query.data?.pages?.flatMap(page => page.data) || []\n\n return { ...query, data }\n}\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { FileForUploadClient } from './use_upload_client';
|
|
2
|
+
type AttachmentStatus = 'uploading' | 'success' | 'error';
|
|
3
|
+
interface AttachmentFile extends FileForUploadClient {
|
|
4
|
+
size: number;
|
|
5
|
+
width?: number;
|
|
6
|
+
height?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface FileAttachment {
|
|
9
|
+
id?: string;
|
|
10
|
+
file: AttachmentFile;
|
|
11
|
+
status: AttachmentStatus;
|
|
12
|
+
}
|
|
13
|
+
export declare function useAttachmentUploader({ conversationId }: {
|
|
14
|
+
conversationId: number;
|
|
15
|
+
}): {
|
|
16
|
+
attachments: FileAttachment[];
|
|
17
|
+
attachmentIds: string[];
|
|
18
|
+
handleFilesAttached: (files: AttachmentFile[]) => void;
|
|
19
|
+
removeAttachment: (attachment: FileAttachment) => void;
|
|
20
|
+
reset: () => void;
|
|
21
|
+
pendingUploads: boolean;
|
|
22
|
+
errorMessage: string | null;
|
|
23
|
+
remainingAttachable: number;
|
|
24
|
+
};
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=use_attachment_uploader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use_attachment_uploader.d.ts","sourceRoot":"","sources":["../../src/hooks/use_attachment_uploader.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAmB,MAAM,qBAAqB,CAAA;AAI1E,KAAK,gBAAgB,GAAG,WAAW,GAAG,SAAS,GAAG,OAAO,CAAA;AAEzD,UAAU,cAAe,SAAQ,mBAAmB;IAClD,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,cAAc,CAAA;IACpB,MAAM,EAAE,gBAAgB,CAAA;CACzB;AAkBD,wBAAgB,qBAAqB,CAAC,EAAE,cAAc,EAAE,EAAE;IAAE,cAAc,EAAE,MAAM,CAAA;CAAE;;;iCAUxE,cAAc,EAAE;mCA4FwB,cAAc;;;;;EA4BjE"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { SUPPORTED_EXTENSIONS } from './attachments/supported_extensions';
|
|
3
|
+
import { useUploadClient } from './use_upload_client';
|
|
4
|
+
import { useApiClient } from './use_api_client';
|
|
5
|
+
const MAX_FILE_SIZE_IN_MB = 50;
|
|
6
|
+
const MAX_FILE_SIZE_IN_BYTES = MAX_FILE_SIZE_IN_MB * 1024 * 1024;
|
|
7
|
+
const MAX_NUMBER_OF_ATTACHMENTS = 10;
|
|
8
|
+
export function useAttachmentUploader({ conversationId }) {
|
|
9
|
+
const apiClient = useApiClient();
|
|
10
|
+
const uploadApi = useUploadClient();
|
|
11
|
+
const [attachments, setAttachments] = useState([]);
|
|
12
|
+
const uploadState = useRef({});
|
|
13
|
+
const [lastUploadId, setLastUploadId] = useState();
|
|
14
|
+
const numberOfAttachments = attachments.length;
|
|
15
|
+
const [errorMessage, setErrorMessage] = useState(null);
|
|
16
|
+
const handleFilesAttached = useCallback((files) => {
|
|
17
|
+
const fileErrors = {};
|
|
18
|
+
const validFiles = files.filter(file => {
|
|
19
|
+
const extension = file.name.split('.').pop();
|
|
20
|
+
const isValidExtension = SUPPORTED_EXTENSIONS.includes(`.${extension}`);
|
|
21
|
+
const isValidFileSize = file.size <= MAX_FILE_SIZE_IN_BYTES;
|
|
22
|
+
if (!isValidExtension) {
|
|
23
|
+
fileErrors.file_type ||= [];
|
|
24
|
+
fileErrors.file_type.push(extension);
|
|
25
|
+
}
|
|
26
|
+
if (!isValidFileSize) {
|
|
27
|
+
fileErrors.file_size = true;
|
|
28
|
+
}
|
|
29
|
+
return isValidFileSize && isValidExtension;
|
|
30
|
+
});
|
|
31
|
+
const errorMessages = [];
|
|
32
|
+
if (fileErrors.file_type) {
|
|
33
|
+
errorMessages.push(`The following file types are not supported: ${fileErrors.file_type.join(', ')}`);
|
|
34
|
+
}
|
|
35
|
+
if (fileErrors.file_size) {
|
|
36
|
+
errorMessages.push(`File size exceeds ${MAX_FILE_SIZE_IN_MB} MB`);
|
|
37
|
+
}
|
|
38
|
+
if (numberOfAttachments + validFiles.length > MAX_NUMBER_OF_ATTACHMENTS) {
|
|
39
|
+
errorMessages.push(`You can't attach more than ${MAX_NUMBER_OF_ATTACHMENTS} files at once.`);
|
|
40
|
+
}
|
|
41
|
+
if (errorMessages.length > 0) {
|
|
42
|
+
setErrorMessage(errorMessages.join('\n'));
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const newAttachments = validFiles.map(file => ({
|
|
46
|
+
file,
|
|
47
|
+
status: 'uploading',
|
|
48
|
+
}));
|
|
49
|
+
if (newAttachments && newAttachments.length > 0) {
|
|
50
|
+
setAttachments(prevAttachments => [...prevAttachments, ...newAttachments]);
|
|
51
|
+
newAttachments.forEach(attachment => {
|
|
52
|
+
uploadApi
|
|
53
|
+
.uploadFile(attachment.file)
|
|
54
|
+
.then(({ id: uploadedFileId }) => apiClient.chat.post({
|
|
55
|
+
url: `/me/conversations/${conversationId}/message_attachments`,
|
|
56
|
+
data: {
|
|
57
|
+
data: {
|
|
58
|
+
type: 'MessageAttachment',
|
|
59
|
+
attributes: { uploaded_file_id: uploadedFileId },
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
}))
|
|
63
|
+
.then(({ data: { id: messageAttachmentId } }) => {
|
|
64
|
+
uploadState.current[attachment.file.name] = {
|
|
65
|
+
status: 'success',
|
|
66
|
+
id: messageAttachmentId,
|
|
67
|
+
};
|
|
68
|
+
setLastUploadId(messageAttachmentId);
|
|
69
|
+
})
|
|
70
|
+
.catch(() => {
|
|
71
|
+
uploadState.current[attachment.file.name] = {
|
|
72
|
+
status: 'error',
|
|
73
|
+
};
|
|
74
|
+
setLastUploadId(attachment.file.name);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}, [numberOfAttachments, uploadApi, apiClient.chat, conversationId]);
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
if (!lastUploadId)
|
|
81
|
+
return;
|
|
82
|
+
setLastUploadId(undefined);
|
|
83
|
+
setAttachments(attachments.map(attachment => {
|
|
84
|
+
const state = uploadState.current[attachment.file.name];
|
|
85
|
+
if (state) {
|
|
86
|
+
return { ...attachment, id: state.id, status: state.status };
|
|
87
|
+
}
|
|
88
|
+
return attachment;
|
|
89
|
+
}));
|
|
90
|
+
}, [attachments, lastUploadId]);
|
|
91
|
+
const removeAttachment = useCallback((attachment) => {
|
|
92
|
+
setAttachments(prevAttachments => prevAttachments.filter(a => a.file.uri !== attachment.file.uri));
|
|
93
|
+
}, []);
|
|
94
|
+
const reset = useCallback(() => {
|
|
95
|
+
setAttachments([]);
|
|
96
|
+
setErrorMessage(null);
|
|
97
|
+
}, []);
|
|
98
|
+
const pendingUploads = attachments.filter(a => a.status === 'uploading').length > 0;
|
|
99
|
+
const attachmentIds = useMemo(() => attachments.filter(a => a.status === 'success' && a.id).map(a => a.id), [attachments]);
|
|
100
|
+
return {
|
|
101
|
+
attachments,
|
|
102
|
+
attachmentIds,
|
|
103
|
+
handleFilesAttached,
|
|
104
|
+
removeAttachment,
|
|
105
|
+
reset,
|
|
106
|
+
pendingUploads,
|
|
107
|
+
errorMessage,
|
|
108
|
+
remainingAttachable: MAX_NUMBER_OF_ATTACHMENTS - numberOfAttachments,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=use_attachment_uploader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use_attachment_uploader.js","sourceRoot":"","sources":["../../src/hooks/use_attachment_uploader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAA;AACzE,OAAO,EAAuB,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AA6B/C,MAAM,mBAAmB,GAAG,EAAE,CAAA;AAC9B,MAAM,sBAAsB,GAAG,mBAAmB,GAAG,IAAI,GAAG,IAAI,CAAA;AAChE,MAAM,yBAAyB,GAAG,EAAE,CAAA;AAEpC,MAAM,UAAU,qBAAqB,CAAC,EAAE,cAAc,EAA8B;IAClF,MAAM,SAAS,GAAG,YAAY,EAAE,CAAA;IAChC,MAAM,SAAS,GAAG,eAAe,EAAE,CAAA;IACnC,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAmB,EAAE,CAAC,CAAA;IACpE,MAAM,WAAW,GAAG,MAAM,CAAc,EAAE,CAAC,CAAA;IAC3C,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,EAAU,CAAA;IAC1D,MAAM,mBAAmB,GAAG,WAAW,CAAC,MAAM,CAAA;IAC9C,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC,CAAA;IAErE,MAAM,mBAAmB,GAAG,WAAW,CACrC,CAAC,KAAuB,EAAE,EAAE;QAC1B,MAAM,UAAU,GAAG,EAAe,CAAA;QAElC,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;YACrC,MAAM,SAAS,GAAG,IAAI,CAAC,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,MAAM,KAAK,SAAS,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAY,CAAC,EACtF,CAAC,WAAW,CAAC,CACd,CAAA;IAED,OAAO;QACL,WAAW;QACX,aAAa;QACb,mBAAmB;QACnB,gBAAgB;QAChB,KAAK;QACL,cAAc;QACd,YAAY;QACZ,mBAAmB,EAAE,yBAAyB,GAAG,mBAAmB;KACrE,CAAA;AACH,CAAC","sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { SUPPORTED_EXTENSIONS } from './attachments/supported_extensions'\nimport { FileForUploadClient, useUploadClient } from './use_upload_client'\nimport { useApiClient } from './use_api_client'\nimport { ApiResource } from '../types'\n\ntype AttachmentStatus = 'uploading' | 'success' | 'error'\n\ninterface AttachmentFile extends FileForUploadClient {\n size: number\n width?: number\n height?: number\n}\n\nexport interface FileAttachment {\n id?: string\n file: AttachmentFile\n status: AttachmentStatus\n}\n\ninterface UploadState {\n [fileName: string]: {\n status: AttachmentStatus\n id?: string\n }\n}\n\ninterface FileError {\n file_type?: string[]\n file_size?: boolean\n}\n\nconst MAX_FILE_SIZE_IN_MB = 50\nconst MAX_FILE_SIZE_IN_BYTES = MAX_FILE_SIZE_IN_MB * 1024 * 1024\nconst MAX_NUMBER_OF_ATTACHMENTS = 10\n\nexport function useAttachmentUploader({ conversationId }: { conversationId: number }) {\n const apiClient = useApiClient()\n const uploadApi = useUploadClient()\n const [attachments, setAttachments] = useState<FileAttachment[]>([])\n const uploadState = useRef<UploadState>({})\n const [lastUploadId, setLastUploadId] = useState<string>()\n const numberOfAttachments = attachments.length\n const [errorMessage, setErrorMessage] = useState<string | null>(null)\n\n const handleFilesAttached = useCallback(\n (files: AttachmentFile[]) => {\n const fileErrors = {} as FileError\n\n const validFiles = files.filter(file => {\n const extension = file.name.split('.').pop() as string\n const isValidExtension = SUPPORTED_EXTENSIONS.includes(`.${extension}`)\n const isValidFileSize = file.size <= MAX_FILE_SIZE_IN_BYTES\n\n if (!isValidExtension) {\n fileErrors.file_type ||= []\n fileErrors.file_type.push(extension)\n }\n if (!isValidFileSize) {\n fileErrors.file_size = true\n }\n\n return isValidFileSize && isValidExtension\n })\n\n const errorMessages: string[] = []\n if (fileErrors.file_type) {\n errorMessages.push(\n `The following file types are not supported: ${fileErrors.file_type.join(', ')}`\n )\n }\n if (fileErrors.file_size) {\n errorMessages.push(`File size exceeds ${MAX_FILE_SIZE_IN_MB} MB`)\n }\n if (numberOfAttachments + validFiles.length > MAX_NUMBER_OF_ATTACHMENTS) {\n errorMessages.push(`You can't attach more than ${MAX_NUMBER_OF_ATTACHMENTS} files at once.`)\n }\n if (errorMessages.length > 0) {\n setErrorMessage(errorMessages.join('\\n'))\n return\n }\n\n const newAttachments: FileAttachment[] = validFiles.map(file => ({\n file,\n status: 'uploading',\n }))\n\n if (newAttachments && newAttachments.length > 0) {\n setAttachments(prevAttachments => [...prevAttachments, ...newAttachments])\n\n newAttachments.forEach(attachment => {\n uploadApi\n .uploadFile(attachment.file)\n .then(({ id: uploadedFileId }) =>\n apiClient.chat.post<ApiResource<MessageAttachmentResource>>({\n url: `/me/conversations/${conversationId}/message_attachments`,\n data: {\n data: {\n type: 'MessageAttachment',\n attributes: { uploaded_file_id: uploadedFileId },\n },\n },\n })\n )\n .then(({ data: { id: messageAttachmentId } }) => {\n uploadState.current[attachment.file.name] = {\n status: 'success',\n id: messageAttachmentId,\n }\n setLastUploadId(messageAttachmentId)\n })\n .catch(() => {\n uploadState.current[attachment.file.name] = {\n status: 'error',\n }\n setLastUploadId(attachment.file.name)\n })\n })\n }\n },\n [numberOfAttachments, uploadApi, apiClient.chat, conversationId]\n )\n\n useEffect(() => {\n if (!lastUploadId) return\n\n setLastUploadId(undefined)\n setAttachments(\n attachments.map(attachment => {\n const state = uploadState.current[attachment.file.name]\n if (state) {\n return { ...attachment, id: state.id, status: state.status }\n }\n return attachment\n })\n )\n }, [attachments, lastUploadId])\n\n const removeAttachment = useCallback((attachment: FileAttachment) => {\n setAttachments(prevAttachments =>\n prevAttachments.filter(a => a.file.uri !== attachment.file.uri)\n )\n }, [])\n\n const reset = useCallback(() => {\n setAttachments([])\n setErrorMessage(null)\n }, [])\n\n const pendingUploads = attachments.filter(a => a.status === 'uploading').length > 0\n\n const attachmentIds = useMemo(\n () => attachments.filter(a => a.status === 'success' && a.id).map(a => a.id as string),\n [attachments]\n )\n\n return {\n attachments,\n attachmentIds,\n handleFilesAttached,\n removeAttachment,\n reset,\n pendingUploads,\n errorMessage,\n remainingAttachable: MAX_NUMBER_OF_ATTACHMENTS - numberOfAttachments,\n }\n}\n\ninterface MessageAttachmentResource {\n type: 'MessageAttachment'\n id: string\n uploadedFileId: string\n filename: string\n messageSortKey: string\n metadata: Record<string, unknown>\n checksum: string\n contentType: string\n byteSize: number\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Client } from '../utils';
|
|
2
|
+
export interface FileForUploadClient {
|
|
3
|
+
uri: string;
|
|
4
|
+
name: string;
|
|
5
|
+
type: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const useUploadClient: () => UploadClient;
|
|
8
|
+
declare class UploadClient extends Client {
|
|
9
|
+
uploadFile(file: FileForUploadClient): Promise<UploadedResource>;
|
|
10
|
+
}
|
|
11
|
+
interface UploadedResource {
|
|
12
|
+
id: string;
|
|
13
|
+
type: string;
|
|
14
|
+
attributes: {
|
|
15
|
+
organization_id: string;
|
|
16
|
+
person_id: string;
|
|
17
|
+
md5: string;
|
|
18
|
+
created_at: string;
|
|
19
|
+
expires_at: string;
|
|
20
|
+
source_ip: string;
|
|
21
|
+
name: string;
|
|
22
|
+
content_type: string;
|
|
23
|
+
file_size: number;
|
|
24
|
+
location: string;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=use_upload_client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use_upload_client.d.ts","sourceRoot":"","sources":["../../src/hooks/use_upload_client.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEjC,MAAM,WAAW,mBAAmB;IAClC,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb;AAED,eAAO,MAAM,eAAe,oBAiB3B,CAAA;AAED,cAAM,YAAa,SAAQ,MAAM;IACzB,UAAU,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAkBvE;AAED,UAAU,gBAAgB;IACxB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE;QACV,eAAe,EAAE,MAAM,CAAA;QACvB,SAAS,EAAE,MAAM,CAAA;QACjB,GAAG,EAAE,MAAM,CAAA;QACX,UAAU,EAAE,MAAM,CAAA;QAClB,UAAU,EAAE,MAAM,CAAA;QAClB,SAAS,EAAE,MAAM,CAAA;QACjB,IAAI,EAAE,MAAM,CAAA;QACZ,YAAY,EAAE,MAAM,CAAA;QACpB,SAAS,EAAE,MAAM,CAAA;QACjB,QAAQ,EAAE,MAAM,CAAA;KACjB,CAAA;CACF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useContext, useMemo } from 'react';
|
|
2
|
+
import { ChatContext } from '../contexts/chat_context';
|
|
3
|
+
import { UploadUri } from '../utils/upload_uri';
|
|
4
|
+
import { Client } from '../utils';
|
|
5
|
+
export const useUploadClient = () => {
|
|
6
|
+
const { session, onUnauthorizedResponse } = useContext(ChatContext);
|
|
7
|
+
const uri = useMemo(() => new UploadUri({ session }), [session]);
|
|
8
|
+
const api = useMemo(() => new UploadClient({
|
|
9
|
+
version: '2025-05-16', // not really needed, but required by the Client constructor
|
|
10
|
+
root: uri.baseUrl,
|
|
11
|
+
defaultHeaders: uri.headers,
|
|
12
|
+
onUnauthorizedResponse,
|
|
13
|
+
}), [uri, onUnauthorizedResponse]);
|
|
14
|
+
return api;
|
|
15
|
+
};
|
|
16
|
+
class UploadClient extends Client {
|
|
17
|
+
async uploadFile(file) {
|
|
18
|
+
const formData = new FormData();
|
|
19
|
+
formData.append('file', file);
|
|
20
|
+
const response = await fetch(`${this.root}/v2/files`, {
|
|
21
|
+
method: 'POST',
|
|
22
|
+
headers: this.headers,
|
|
23
|
+
body: formData,
|
|
24
|
+
});
|
|
25
|
+
if (!response.ok) {
|
|
26
|
+
return this.handleNotOk(response);
|
|
27
|
+
}
|
|
28
|
+
const jsonResponse = await response.json();
|
|
29
|
+
return jsonResponse.data[0];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=use_upload_client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use_upload_client.js","sourceRoot":"","sources":["../../src/hooks/use_upload_client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAQjC,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE;IAClC,MAAM,EAAE,OAAO,EAAE,sBAAsB,EAAE,GAAG,UAAU,CAAC,WAAW,CAAC,CAAA;IAEnE,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAA;IAEhE,MAAM,GAAG,GAAG,OAAO,CACjB,GAAG,EAAE,CACH,IAAI,YAAY,CAAC;QACf,OAAO,EAAE,YAAY,EAAE,4DAA4D;QACnF,IAAI,EAAE,GAAG,CAAC,OAAO;QACjB,cAAc,EAAE,GAAG,CAAC,OAAO;QAC3B,sBAAsB;KACvB,CAAC,EACJ,CAAC,GAAG,EAAE,sBAAsB,CAAC,CAC9B,CAAA;IAED,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAED,MAAM,YAAa,SAAQ,MAAM;IAC/B,KAAK,CAAC,UAAU,CAAC,IAAyB;QACxC,MAAM,QAAQ,GAAG,IAAI,QAAQ,EAAE,CAAA;QAC/B,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,IAAuB,CAAC,CAAA;QAEhD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,WAAW,EAAE;YACpD,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,IAAI,EAAE,QAAQ;SACf,CAAC,CAAA;QAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAA;QACnC,CAAC;QAED,MAAM,YAAY,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;QAE1C,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAC7B,CAAC;CACF","sourcesContent":["import { useContext, useMemo } from 'react'\nimport { ChatContext } from '../contexts/chat_context'\nimport { UploadUri } from '../utils/upload_uri'\nimport { Client } from '../utils'\n\nexport interface FileForUploadClient {\n uri: string\n name: string\n type: string // Should be a MIME type\n}\n\nexport const useUploadClient = () => {\n const { session, onUnauthorizedResponse } = useContext(ChatContext)\n\n const uri = useMemo(() => new UploadUri({ session }), [session])\n\n const api = useMemo(\n () =>\n new UploadClient({\n version: '2025-05-16', // not really needed, but required by the Client constructor\n root: uri.baseUrl,\n defaultHeaders: uri.headers,\n onUnauthorizedResponse,\n }),\n [uri, onUnauthorizedResponse]\n )\n\n return api\n}\n\nclass UploadClient extends Client {\n async uploadFile(file: FileForUploadClient): Promise<UploadedResource> {\n const formData = new FormData()\n formData.append('file', file as unknown as Blob)\n\n const response = await fetch(`${this.root}/v2/files`, {\n method: 'POST',\n headers: this.headers,\n body: formData,\n })\n\n if (!response.ok) {\n return this.handleNotOk(response)\n }\n\n const jsonResponse = await response.json()\n\n return jsonResponse.data[0]\n }\n}\n\ninterface UploadedResource {\n id: string\n type: string\n attributes: {\n organization_id: string\n person_id: string\n md5: string\n created_at: string\n expires_at: string\n source_ip: string\n name: string\n content_type: string\n file_size: number\n location: string\n }\n}\n"]}
|
package/build/index.d.ts
CHANGED
|
@@ -4,5 +4,6 @@ export { DesignSystemScreen } from './screens';
|
|
|
4
4
|
export * from './navigation';
|
|
5
5
|
export * from './types';
|
|
6
6
|
export * from './utils/client';
|
|
7
|
+
export { GroupConversations } from './components';
|
|
7
8
|
export { TemporaryDefaultColorsType, ChatAdapters, ClipboardAdapter, Session, Uri, platformFontWeightBold, } from './utils';
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AACvC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAC9C,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AACvC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAC9C,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,gBAAgB,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAEjD,OAAO,EACL,0BAA0B,EAC1B,YAAY,EACZ,gBAAgB,EAChB,OAAO,EACP,GAAG,EACH,sBAAsB,GACvB,MAAM,SAAS,CAAA"}
|
package/build/index.js
CHANGED
|
@@ -4,5 +4,6 @@ export { DesignSystemScreen } from './screens';
|
|
|
4
4
|
export * from './navigation';
|
|
5
5
|
export * from './types';
|
|
6
6
|
export * from './utils/client';
|
|
7
|
+
export { GroupConversations } from './components';
|
|
7
8
|
export { ChatAdapters, ClipboardAdapter, Session, Uri, platformFontWeightBold, } from './utils';
|
|
8
9
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AACvC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAC9C,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AACvC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAC9C,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,gBAAgB,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAEjD,OAAO,EAEL,YAAY,EACZ,gBAAgB,EAChB,OAAO,EACP,GAAG,EACH,sBAAsB,GACvB,MAAM,SAAS,CAAA","sourcesContent":["export * from './contexts/chat_context'\nexport { ApiProvider, chatQueryClient } from './contexts/api_provider'\nexport { DesignSystemScreen } from './screens'\nexport * from './navigation'\nexport * from './types'\nexport * from './utils/client'\nexport { GroupConversations } from './components'\n\nexport {\n TemporaryDefaultColorsType,\n ChatAdapters,\n ClipboardAdapter,\n Session,\n Uri,\n platformFontWeightBold,\n} from './utils'\n"]}
|
|
@@ -66,7 +66,7 @@ export declare const NewConversationStack: import("@react-navigation/native").Ty
|
|
|
66
66
|
};
|
|
67
67
|
};
|
|
68
68
|
}) => React.JSX.Element;
|
|
69
|
-
readonly options: ({ navigation
|
|
69
|
+
readonly options: ({ navigation }: {
|
|
70
70
|
route: import("@react-navigation/native").RouteProp<import("@react-navigation/native").ParamListBase, string>;
|
|
71
71
|
navigation: import("@react-navigation/native-stack").NativeStackNavigationProp<import("@react-navigation/native").ParamListBase, string, undefined>;
|
|
72
72
|
theme: ReactNavigation.Theme;
|
|
@@ -190,7 +190,7 @@ export declare const ChatStack: import("@react-navigation/native").TypedNavigato
|
|
|
190
190
|
};
|
|
191
191
|
};
|
|
192
192
|
}) => React.JSX.Element;
|
|
193
|
-
readonly options: ({ navigation
|
|
193
|
+
readonly options: ({ navigation }: {
|
|
194
194
|
route: import("@react-navigation/native").RouteProp<import("@react-navigation/native").ParamListBase, string>;
|
|
195
195
|
navigation: import("@react-navigation/native-stack").NativeStackNavigationProp<import("@react-navigation/native").ParamListBase, string, undefined>;
|
|
196
196
|
theme: ReactNavigation.Theme;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/navigation/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,EAEL,2BAA2B,EAC5B,MAAM,gCAAgC,CAAA;AACvC,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAA;AAClF,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,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gZ,gBAAiB,KAAK;;;;qCAxG3jZ,2BAA2B;;;;EAQtD,CAAA;AAEF,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;uBA8F4iZ,gBAAiB,KAAK;;;qCApF3jZ,2BAA2B;;;;;;;;;;;;uBAoF0gZ,gBAAiB,KAAK;;;;;;;;;;;uBAAtB,gBAAiB,KAAK;;;;qCA9C3jZ,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;mDA8C2hZ,KAAK;;;iDAvI3jZ,2BAA2B;;;;;;;;;mDAuI2hZ,KAAK;;;iDA3H3jZ,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;mDA2H2hZ,KAAK;;;;iDAxG3jZ,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+FtD,CAAA;AAEF,KAAK,kBAAkB,GAAG,eAAe,CAAC,OAAO,SAAS,CAAC,CAAA;AAE3D,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,eAAe,CAAC;QACxB,UAAU,aAAc,SAAQ,kBAAkB;SAAG;KACtD;CACF"}
|
|
@@ -48,10 +48,10 @@ export const NewConversationStack = createNativeStackNavigator({
|
|
|
48
48
|
},
|
|
49
49
|
ConversationNew: {
|
|
50
50
|
screen: ConversationNewScreen,
|
|
51
|
-
options: ({ navigation
|
|
51
|
+
options: ({ navigation }) => ({
|
|
52
52
|
title: 'New conversation',
|
|
53
53
|
headerLeft: () => null,
|
|
54
|
-
headerRight: (props) => (<HeaderRightButton {...props} onPress={() => navigation.
|
|
54
|
+
headerRight: (props) => (<HeaderRightButton {...props} onPress={() => navigation.getParent()?.goBack()}>
|
|
55
55
|
Cancel
|
|
56
56
|
</HeaderRightButton>),
|
|
57
57
|
}),
|