@planningcenter/chat-react-native 3.11.0-rc.13 → 3.11.0-rc.15

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.
@@ -1 +1 @@
1
- {"version":3,"file":"api_provider.d.ts","sourceRoot":"","sources":["../../src/contexts/api_provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAgB,WAAW,EAAiC,MAAM,uBAAuB,CAAA;AAChG,OAAO,KAAwC,MAAM,OAAO,CAAA;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAkBxC,eAAO,MAAM,eAAe,aAO1B,CAAA;AAEF,wBAAgB,WAAW,CAAC,EAAE,QAAQ,EAAE,EAAE,SAAS,qBAalD;AAED,wBAAgB,eAAe,WAQ9B"}
1
+ {"version":3,"file":"api_provider.d.ts","sourceRoot":"","sources":["../../src/contexts/api_provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EAIZ,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAwC,MAAM,OAAO,CAAA;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAkBxC,eAAO,MAAM,eAAe,aAO1B,CAAA;AAEF,wBAAgB,WAAW,CAAC,EAAE,QAAQ,EAAE,EAAE,SAAS,qBAkBlD;AAcD,wBAAgB,eAAe,WAQ9B"}
@@ -1,6 +1,7 @@
1
- import { focusManager, QueryClient, QueryClientProvider } from '@tanstack/react-query';
1
+ import { focusManager, QueryClient, QueryClientProvider, usePrefetchQuery, } from '@tanstack/react-query';
2
2
  import React, { useContext, useEffect, useRef } from 'react';
3
3
  import { ChatContext } from './chat_context';
4
+ import { appGrantsRequestArgs, getRequestQueryKey } from '../hooks';
4
5
  import { useApiClient } from '../hooks/use_api_client';
5
6
  import { useAppState } from '../hooks/use_app_state';
6
7
  let apiClient;
@@ -28,8 +29,21 @@ export function ApiProvider({ children }) {
28
29
  return;
29
30
  chatQueryClient.clear();
30
31
  }, [sessionChanged]);
31
- return <QueryClientProvider client={chatQueryClient}>{children}</QueryClientProvider>;
32
+ return (<QueryClientProvider client={chatQueryClient}>
33
+ <PrefetchQueries />
34
+ {children}
35
+ </QueryClientProvider>);
32
36
  }
37
+ // Component to prefetch queries when the app is focused
38
+ // This needs to live in the provider so that it can access the api client
39
+ // and the chat query client
40
+ const PrefetchQueries = () => {
41
+ usePrefetchQuery({
42
+ queryKey: getRequestQueryKey(appGrantsRequestArgs),
43
+ queryFn: defaultQueryFn,
44
+ });
45
+ return null;
46
+ };
33
47
  export function useFocusManager() {
34
48
  const appState = useAppState();
35
49
  useEffect(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"api_provider.js","sourceRoot":"","sources":["../../src/contexts/api_provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,mBAAmB,EAAY,MAAM,uBAAuB,CAAA;AAChG,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAE5D,OAAO,EAAE,WAAW,EAAoB,MAAM,gBAAgB,CAAA;AAE9D,OAAO,EAAa,YAAY,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEpD,IAAI,SAAgC,CAAA;AAEpC,MAAM,cAAc,GAAG,CAAC,EAAE,QAAQ,EAA0B,EAAE,EAAE;IAC9D,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAA;IACrC,CAAC;IAED,MAAM,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,GAAG,MAAM,CAAC,GAAG,QAA2B,CAAA;IAEtE,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAA;AACnD,CAAC,CAAA;AAED,MAAM,CAAC,M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AM,KAAK,OAAO,CAAC,CAAA;AAC/F,CAAC;AAED,SAAS,WAAW,CAAI,KAAQ;IAC9B,MAAM,GAAG,GAAG,MAAM,CAAI,KAAK,CAAC,CAAA;IAE5B,SAAS,CAAC,GAAG,EAAE;QACb,GAAG,CAAC,OAAO,GAAG,KAAK,CAAA;IACrB,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAA;IAEX,OAAO,GAAG,CAAC,OAAO,CAAA;AACpB,CAAC","sourcesContent":["import { focusManager, QueryClient, QueryClientProvider, QueryKey } from '@tanstack/react-query'\nimport React, { useContext, useEffect, useRef } from 'react'\nimport { ViewProps } from 'react-native'\nimport { ChatContext, ChatContextValue } from './chat_context'\nimport { RequestQueryKey } from '../hooks'\nimport { ApiClient, useApiClient } from '../hooks/use_api_client'\nimport { useAppState } from '../hooks/use_app_state'\n\nlet apiClient: ApiClient | undefined\n\nconst defaultQueryFn = ({ queryKey }: { queryKey: QueryKey }) => {\n if (!apiClient) {\n throw new Error('No token present')\n }\n\n const [url, data, headers, app = 'chat'] = queryKey as RequestQueryKey\n\n return apiClient[app].get({ url, data, headers })\n}\n\nexport const chatQueryClient = new QueryClient({\n defaultOptions: {\n queries: {\n queryFn: defaultQueryFn,\n retry: 3,\n },\n },\n})\n\nexport function ApiProvider({ children }: ViewProps) {\n const { token, env } = useContext(ChatContext)\n const sessionChanged = useSessionChanged({ token, env })\n\n apiClient = useApiClient()\n\n useEffect(() => {\n if (!sessionChanged) return\n\n chatQueryClient.clear()\n }, [sessionChanged])\n\n return <QueryClientProvider client={chatQueryClient}>{children}</QueryClientProvider>\n}\n\nexport function useFocusManager() {\n const appState = useAppState()\n\n useEffect(() => {\n focusManager.setFocused(appState === 'active')\n }, [appState])\n\n return appState\n}\n\nfunction useSessionChanged(value: Pick<ChatContextValue, 'token' | 'env'>): boolean {\n const { token: newToken, env: newEnv } = value\n const { token: prevToken, env: prevEnv } = usePrevious<typeof value>(value)\n\n return Boolean(prevToken && newToken !== prevToken) || Boolean(prevEnv && newEnv !== prevEnv)\n}\n\nfunction usePrevious<T>(value: T): T {\n const ref = useRef<T>(value)\n\n useEffect(() => {\n ref.current = value\n }, [value])\n\n return ref.current\n}\n"]}
1
+ {"version":3,"file":"api_provider.js","sourceRoot":"","sources":["../../src/contexts/api_provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,WAAW,EACX,mBAAmB,EAEnB,gBAAgB,GACjB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAE5D,OAAO,EAAE,WAAW,EAAoB,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAmB,MAAM,UAAU,CAAA;AACpF,OAAO,EAAa,YAAY,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEpD,IAAI,SAAgC,CAAA;AAEpC,MAAM,cAAc,GAAG,CAAC,EAAE,QAAQ,EAA0B,EAAE,EAAE;IAC9D,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAA;IACrC,CAAC;IAED,MAAM,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,GAAG,MAAM,CAAC,GAAG,QAA2B,CAAA;IAEtE,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAA;AACnD,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,WAAW,CAAC;IAC7C,cAAc,EAAE;QACd,OAAO,EAAE;YACP,OAAO,EAAE,cAAc;YACvB,KAAK,EAAE,CAAC;SACT;KACF;CACF,CAAC,CAAA;AAEF,MAAM,UAAU,WAAW,CAAC,EAAE,QAAQ,EAAa;IACj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E3E,OAAO,OAAO,CAAC,SAAS,IAAI,QAAQ,KAAK,SAAS,CAAC,IAAI,OAAO,CAAC,OAAO,IAAI,MAAM,KAAK,OAAO,CAAC,CAAA;AAC/F,CAAC;AAED,SAAS,WAAW,CAAI,KAAQ;IAC9B,MAAM,GAAG,GAAG,MAAM,CAAI,KAAK,CAAC,CAAA;IAE5B,SAAS,CAAC,GAAG,EAAE;QACb,GAAG,CAAC,OAAO,GAAG,KAAK,CAAA;IACrB,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAA;IAEX,OAAO,GAAG,CAAC,OAAO,CAAA;AACpB,CAAC","sourcesContent":["import {\n focusManager,\n QueryClient,\n QueryClientProvider,\n QueryKey,\n usePrefetchQuery,\n} from '@tanstack/react-query'\nimport React, { useContext, useEffect, useRef } from 'react'\nimport { ViewProps } from 'react-native'\nimport { ChatContext, ChatContextValue } from './chat_context'\nimport { appGrantsRequestArgs, getRequestQueryKey, RequestQueryKey } from '../hooks'\nimport { ApiClient, useApiClient } from '../hooks/use_api_client'\nimport { useAppState } from '../hooks/use_app_state'\n\nlet apiClient: ApiClient | undefined\n\nconst defaultQueryFn = ({ queryKey }: { queryKey: QueryKey }) => {\n if (!apiClient) {\n throw new Error('No token present')\n }\n\n const [url, data, headers, app = 'chat'] = queryKey as RequestQueryKey\n\n return apiClient[app].get({ url, data, headers })\n}\n\nexport const chatQueryClient = new QueryClient({\n defaultOptions: {\n queries: {\n queryFn: defaultQueryFn,\n retry: 3,\n },\n },\n})\n\nexport function ApiProvider({ children }: ViewProps) {\n const { token, env } = useContext(ChatContext)\n const sessionChanged = useSessionChanged({ token, env })\n\n apiClient = useApiClient()\n\n useEffect(() => {\n if (!sessionChanged) return\n\n chatQueryClient.clear()\n }, [sessionChanged])\n\n return (\n <QueryClientProvider client={chatQueryClient}>\n <PrefetchQueries />\n {children}\n </QueryClientProvider>\n )\n}\n\n// Component to prefetch queries when the app is focused\n// This needs to live in the provider so that it can access the api client\n// and the chat query client\nconst PrefetchQueries = () => {\n usePrefetchQuery({\n queryKey: getRequestQueryKey(appGrantsRequestArgs),\n queryFn: defaultQueryFn,\n })\n\n return null\n}\n\nexport function useFocusManager() {\n const appState = useAppState()\n\n useEffect(() => {\n focusManager.setFocused(appState === 'active')\n }, [appState])\n\n return appState\n}\n\nfunction useSessionChanged(value: Pick<ChatContextValue, 'token' | 'env'>): boolean {\n const { token: newToken, env: newEnv } = value\n const { token: prevToken, env: prevEnv } = usePrevious<typeof value>(value)\n\n return Boolean(prevToken && newToken !== prevToken) || Boolean(prevEnv && newEnv !== prevEnv)\n}\n\nfunction usePrevious<T>(value: T): T {\n const ref = useRef<T>(value)\n\n useEffect(() => {\n ref.current = value\n }, [value])\n\n return ref.current\n}\n"]}
@@ -1,4 +1,14 @@
1
1
  import { AppGrantsResource } from '../types';
2
+ import { App } from './use_api_client';
3
+ export declare const appGrantsRequestArgs: {
4
+ url: string;
5
+ data: {
6
+ fields: {
7
+ AppGrant: string[];
8
+ };
9
+ };
10
+ app: App;
11
+ };
2
12
  export declare function useAppGrants(): {
3
13
  error: import("../types").ApiError;
4
14
  isError: true;
@@ -1 +1 @@
1
- {"version":3,"file":"use_chat_permissions.d.ts","sourceRoot":"","sources":["../../src/hooks/use_chat_permissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAG5C,wBAAgB,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAU3B;AAED,wBAAgB,yBAAyB,IAAI,OAAO,CAInD"}
1
+ {"version":3,"file":"use_chat_permissions.d.ts","sourceRoot":"","sources":["../../src/hooks/use_chat_permissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAE5C,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAEtC,eAAO,MAAM,oBAAoB;;;;;;;SAOhB,GAAG;CACnB,CAAA;AAED,wBAAgB,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAE3B;AAED,wBAAgB,yBAAyB,IAAI,OAAO,CAInD"}
@@ -1,14 +1,15 @@
1
1
  import { useApiGet } from './use_api';
2
- export function useAppGrants() {
3
- return useApiGet({
4
- url: '/me/app_grants',
5
- data: {
6
- fields: {
7
- AppGrant: ['create_conversations', 'app_name'],
8
- },
2
+ export const appGrantsRequestArgs = {
3
+ url: '/me/app_grants',
4
+ data: {
5
+ fields: {
6
+ AppGrant: ['create_conversations', 'app_name'],
9
7
  },
10
- app: 'chat',
11
- });
8
+ },
9
+ app: 'chat',
10
+ };
11
+ export function useAppGrants() {
12
+ return useApiGet(appGrantsRequestArgs);
12
13
  }
13
14
  export function useCanCreateConversations() {
14
15
  const { data: appGrants = [] } = useAppGrants();
@@ -1 +1 @@
1
- {"version":3,"file":"use_chat_permissions.js","sourceRoot":"","sources":["../../src/hooks/use_chat_permissions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC,MAAM,UAAU,YAAY;IAC1B,OAAO,SAAS,CAAsB;QACpC,GAAG,EAAE,gBAAgB;QACrB,IAAI,EAAE;YACJ,MAAM,EAAE;gBACN,QAAQ,EAAE,CAAC,sBAAsB,EAAE,UAAU,CAAC;aAC/C;SACF;QACD,GAAG,EAAE,MAAM;KACZ,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,UAAU,yBAAyB;IACvC,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,EAAE,EAAE,GAAG,YAAY,EAAE,CAAA;IAE/C,OAAO,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAA;AACjE,CAAC","sourcesContent":["import { AppGrantsResource } from '../types'\nimport { useApiGet } from './use_api'\n\nexport function useAppGrants() {\n return useApiGet<AppGrantsResource[]>({\n url: '/me/app_grants',\n data: {\n fields: {\n AppGrant: ['create_conversations', 'app_name'],\n },\n },\n app: 'chat',\n })\n}\n\nexport function useCanCreateConversations(): boolean {\n const { data: appGrants = [] } = useAppGrants()\n\n return appGrants.some(appGrant => appGrant.createConversations)\n}\n"]}
1
+ {"version":3,"file":"use_chat_permissions.js","sourceRoot":"","sources":["../../src/hooks/use_chat_permissions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAGrC,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,GAAG,EAAE,gBAAgB;IACrB,IAAI,EAAE;QACJ,MAAM,EAAE;YACN,QAAQ,EAAE,CAAC,sBAAsB,EAAE,UAAU,CAAC;SAC/C;KACF;IACD,GAAG,EAAE,MAAa;CACnB,CAAA;AAED,MAAM,UAAU,YAAY;IAC1B,OAAO,SAAS,CAAsB,oBAAoB,CAAC,CAAA;AAC7D,CAAC;AAED,MAAM,UAAU,yBAAyB;IACvC,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,EAAE,EAAE,GAAG,YAAY,EAAE,CAAA;IAE/C,OAAO,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAA;AACjE,CAAC","sourcesContent":["import { AppGrantsResource } from '../types'\nimport { useApiGet } from './use_api'\nimport { App } from './use_api_client'\n\nexport const appGrantsRequestArgs = {\n url: '/me/app_grants',\n data: {\n fields: {\n AppGrant: ['create_conversations', 'app_name'],\n },\n },\n app: 'chat' as App,\n}\n\nexport function useAppGrants() {\n return useApiGet<AppGrantsResource[]>(appGrantsRequestArgs)\n}\n\nexport function useCanCreateConversations(): boolean {\n const { data: appGrants = [] } = useAppGrants()\n\n return appGrants.some(appGrant => appGrant.createConversations)\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"conversation_select_recipients_screen.d.ts","sourceRoot":"","sources":["../../../src/screens/conversation_select_recipients/conversation_select_recipients_screen.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAMzB,OAAO,EAAE,uCAAuC,EAAE,MAAM,sBAAsB,CAAA;AAW9E,eAAO,MAAM,kCAAkC,eAE5C,uCAAuC,sBA+IzC,CAAA"}
1
+ {"version":3,"file":"conversation_select_recipients_screen.d.ts","sourceRoot":"","sources":["../../../src/screens/conversation_select_recipients/conversation_select_recipients_screen.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAMzB,OAAO,EAAE,uCAAuC,EAAE,MAAM,sBAAsB,CAAA;AAY9E,eAAO,MAAM,kCAAkC,eAE5C,uCAAuC,sBAyJzC,CAAA"}
@@ -10,10 +10,14 @@ import { useServiceTypesWithTeams } from '../conversation_filter_recipients/hook
10
10
  import { TeamRecipientRow } from './components/team_recipient_row';
11
11
  import { GroupsRecipientRow } from './components/groups_recipient_row';
12
12
  import { DefaultLoading } from '../../components/page/loading';
13
+ import { useAppGrants } from '../../hooks';
13
14
  const MAX_VISIBLE_RECIPIENTS = 5;
14
15
  export const ConversationSelectRecipientsScreen = ({ route, }) => {
15
16
  const styles = useStyles();
16
17
  const navigation = useNavigation();
18
+ const appGrants = useAppGrants();
19
+ const canCreateGroupsConversations = appGrants.data?.some(g => g.createConversations && g.appName === 'Groups');
20
+ const canCreateServicesConversations = appGrants.data?.some(g => g.createConversations && g.appName === 'Services');
17
21
  const { data: groups = [], isFetching: isGroupsFetching } = useGroupsGroups();
18
22
  const groupsWithCreatePermission = groups.filter(g => g.canCreateConversation);
19
23
  const visibleGroups = groupsWithCreatePermission.slice(0, MAX_VISIBLE_RECIPIENTS);
@@ -62,39 +66,39 @@ export const ConversationSelectRecipientsScreen = ({ route, }) => {
62
66
  });
63
67
  };
64
68
  return (<ScrollView contentContainerStyle={styles.contentContainer}>
65
- <View style={styles.section}>
66
- <View style={styles.sectionHeader}>
67
- <Heading variant="h3">My groups</Heading>
68
- </View>
69
- <View>
70
- {isGroupsFetching ? (<DefaultLoading />) : groupsWithCreatePermission.length === 0 ? (<BlankState subtitle="Join a group with chat enabled and permissions to start a new conversation." style={styles.blankState}/>) : (<>
71
- {visibleGroups.map(group => {
72
- return (<GroupsRecipientRow key={group.id} group={group} onPress={handleGroupsNavigateToConversationNew}/>);
73
- })}
74
- {hasMoreGroups && (<ViewMoreLinkRow onPress={handleGroupsViewMore} accessibilityHint="Navigate to a full list of your groups."/>)}
75
- {showGroupsDisclaimer && <GroupsWithoutChatDisclaimerRow />}
76
- </>)}
77
- </View>
78
- </View>
79
- <View style={styles.section}>
80
- <View style={styles.sectionHeader}>
81
- <Heading variant="h3">Teams I lead</Heading>
82
- {hasServiceTypes && (<Button style={styles.selectTeamsButton} onPress={() => navigation.navigate('New', {
83
- screen: 'ConversationFilterRecipients',
84
- params: {
85
- source_app_name: 'Services',
86
- },
87
- })} title="Select teams" variant="outline" iconNameLeft="general.search" size="sm"/>)}
88
- </View>
89
- <View>
90
- {isServiceTypesFetching ? (<DefaultLoading />) : hasServiceTypes ? (<>
91
- {visibleServiceTypes.map(serviceType => {
92
- return (<TeamRecipientRow key={serviceType.id} serviceType={serviceType} onPress={handleTeamsNavigateToConversationNew}/>);
93
- })}
94
- {hasMoreServiceTypes && (<ViewMoreLinkRow onPress={handleServiceTypesViewMore} accessibilityHint="Navigate to a full list of teams you lead."/>)}
95
- </>) : (<BlankState subtitle="You don't lead any teams." style={styles.blankState}/>)}
96
- </View>
97
- </View>
69
+ {canCreateGroupsConversations && (<View style={styles.section}>
70
+ <View style={styles.sectionHeader}>
71
+ <Heading variant="h3">My groups</Heading>
72
+ </View>
73
+ <View>
74
+ {isGroupsFetching ? (<DefaultLoading />) : groupsWithCreatePermission.length === 0 ? (<BlankState subtitle="Join a group with chat enabled and permissions to start a new conversation." style={styles.blankState}/>) : (<>
75
+ {visibleGroups.map(group => {
76
+ return (<GroupsRecipientRow key={group.id} group={group} onPress={handleGroupsNavigateToConversationNew}/>);
77
+ })}
78
+ {hasMoreGroups && (<ViewMoreLinkRow onPress={handleGroupsViewMore} accessibilityHint="Navigate to a full list of your groups."/>)}
79
+ {showGroupsDisclaimer && <GroupsWithoutChatDisclaimerRow />}
80
+ </>)}
81
+ </View>
82
+ </View>)}
83
+ {canCreateServicesConversations && (<View style={styles.section}>
84
+ <View style={styles.sectionHeader}>
85
+ <Heading variant="h3">Teams I lead</Heading>
86
+ {hasServiceTypes && (<Button style={styles.selectTeamsButton} onPress={() => navigation.navigate('New', {
87
+ screen: 'ConversationFilterRecipients',
88
+ params: {
89
+ source_app_name: 'Services',
90
+ },
91
+ })} title="Select teams" variant="outline" iconNameLeft="general.search" size="sm"/>)}
92
+ </View>
93
+ <View>
94
+ {isServiceTypesFetching ? (<DefaultLoading />) : hasServiceTypes ? (<>
95
+ {visibleServiceTypes.map(serviceType => {
96
+ return (<TeamRecipientRow key={serviceType.id} serviceType={serviceType} onPress={handleTeamsNavigateToConversationNew}/>);
97
+ })}
98
+ {hasMoreServiceTypes && (<ViewMoreLinkRow onPress={handleServiceTypesViewMore} accessibilityHint="Navigate to a full list of teams you lead."/>)}
99
+ </>) : (<BlankState subtitle="You don't lead any teams." style={styles.blankState}/>)}
100
+ </View>
101
+ </View>)}
98
102
  </ScrollView>);
99
103
  };
100
104
  const useStyles = () => {
@@ -1 +1 @@
1
- {"version":3,"file":"conversation_select_recipients_screen.js","sourceRoot":"","sources":["../../../src/screens/conversation_select_recipients/conversation_select_recipients_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA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H;YAAA,GAAG,CACJ,CAAC,CAAC,CAAC,CACF,CAAC,UAAU,CAAC,QAAQ,CAAC,2BAA2B,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,EAAG,CAC9E,CACH;QAAA,EAAE,IAAI,CACR;MAAA,EAAE,IAAI,CACR;IAAA,EAAE,UAAU,CAAC,CACd,CAAA;AACH,CAAC,CAAA;AAED,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,EAAE,MAAM,EAAE,GAAG,iBAAiB,EAAE,CAAA;IAEtC,OAAO,UAAU,CAAC,MAAM,CAAC;QACvB,gBAAgB,EAAE;YAChB,GAAG,EAAE,EAAE;YACP,UAAU,EAAE,EAAE;YACd,aAAa,EAAE,EAAE,GAAG,MAAM;SAC3B;QACD,OAAO,EAAE;YACP,IAAI,EAAE,CAAC;SACR;QACD,aAAa,EAAE;YACb,aAAa,EAAE,KAAK;YACpB,cAAc,EAAE,eAAe;YAC/B,iBAAiB,EAAE,EAAE;YACrB,aAAa,EAAE,CAAC;SACjB;QACD,iBAAiB,EAAE,EAAE;QACrB,UAAU,EAAE;YACV,SAAS,EAAE,EAAE;YACb,YAAY,EAAE,EAAE;SACjB;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { useNavigation } from '@react-navigation/native'\nimport React from 'react'\nimport { ScrollView, StyleSheet, View } from 'react-native'\nimport { BlankState, Button, Heading } from '../../components'\nimport { GroupsGroupResource } from '../../types'\nimport { useGroupsGroups } from '../../hooks/use_groups_groups'\nimport { useSafeAreaInsets } from 'react-native-safe-area-context'\nimport { ConversationSelectRecipientsScreenProps } from './types/screen_props'\nimport { ViewMoreLinkRow } from './components/view_more_link_row'\nimport { GroupsWithoutChatDisclaimerRow } from './components/groups_without_chat_disclaimer_row'\nimport { useServiceTypesWithTeams } from '../conversation_filter_recipients/hooks/use_service_types_with_teams'\nimport { ServiceTypeWithTeams } from '../conversation_filter_recipients/types'\nimport { TeamRecipientRow } from './components/team_recipient_row'\nimport { GroupsRecipientRow } from './components/groups_recipient_row'\nimport { DefaultLoading } from '../../components/page/loading'\n\nconst MAX_VISIBLE_RECIPIENTS = 5\n\nexport const ConversationSelectRecipientsScreen = ({\n route,\n}: ConversationSelectRecipientsScreenProps) => {\n const styles = useStyles()\n const navigation = useNavigation()\n\n const { data: groups = [], isFetching: isGroupsFetching } = useGroupsGroups()\n const groupsWithCreatePermission = groups.filter(g => g.canCreateConversation)\n const visibleGroups = groupsWithCreatePermission.slice(0, MAX_VISIBLE_RECIPIENTS)\n const hasMoreGroups = groupsWithCreatePermission.length > MAX_VISIBLE_RECIPIENTS\n const hasGroupsWithoutChatPermission = groups.length > groupsWithCreatePermission.length\n const showGroupsDisclaimer = hasGroupsWithoutChatPermission && !hasMoreGroups\n\n const handleGroupsNavigateToConversationNew = (group: GroupsGroupResource) => {\n navigation.navigate('New', {\n screen: 'ConversationNew',\n params: {\n group_id: group.id,\n source_app_name: 'Groups',\n ...route.params,\n },\n })\n }\n\n const handleGroupsViewMore = () => {\n navigation.navigate('New', {\n screen: 'ConversationSelectGroupRecipients',\n params: {\n ...route.params,\n },\n })\n }\n\n const { serviceTypes, isFetching: isServiceTypesFetching } = useServiceTypesWithTeams()\n const visibleServiceTypes = serviceTypes.slice(0, MAX_VISIBLE_RECIPIENTS)\n const hasMoreServiceTypes = serviceTypes.length > MAX_VISIBLE_RECIPIENTS\n const hasServiceTypes = serviceTypes.length > 0\n\n const handleTeamsNavigateToConversationNew = (teams: ServiceTypeWithTeams['teams']) => {\n const teamIds = teams.map(team => team.id)\n\n navigation.navigate('New', {\n screen: 'ConversationNew',\n params: {\n team_ids: teamIds,\n source_app_name: 'Services',\n ...route.params,\n },\n })\n }\n\n const handleServiceTypesViewMore = () => {\n navigation.navigate('New', {\n screen: 'ConversationSelectTeamsILeadRecipients',\n params: {\n ...route.params,\n },\n })\n }\n\n return (\n <ScrollView contentContainerStyle={styles.contentContainer}>\n <View style={styles.section}>\n <View style={styles.sectionHeader}>\n <Heading variant=\"h3\">My groups</Heading>\n </View>\n <View>\n {isGroupsFetching ? (\n <DefaultLoading />\n ) : groupsWithCreatePermission.length === 0 ? (\n <BlankState\n subtitle=\"Join a group with chat enabled and permissions to start a new conversation.\"\n style={styles.blankState}\n />\n ) : (\n <>\n {visibleGroups.map(group => {\n return (\n <GroupsRecipientRow\n key={group.id}\n group={group}\n onPress={handleGroupsNavigateToConversationNew}\n />\n )\n })}\n {hasMoreGroups && (\n <ViewMoreLinkRow\n onPress={handleGroupsViewMore}\n accessibilityHint=\"Navigate to a full list of your groups.\"\n />\n )}\n {showGroupsDisclaimer && <GroupsWithoutChatDisclaimerRow />}\n </>\n )}\n </View>\n </View>\n <View style={styles.section}>\n <View style={styles.sectionHeader}>\n <Heading variant=\"h3\">Teams I lead</Heading>\n {hasServiceTypes && (\n <Button\n style={styles.selectTeamsButton}\n onPress={() =>\n navigation.navigate('New', {\n screen: 'ConversationFilterRecipients',\n params: {\n source_app_name: 'Services',\n },\n })\n }\n title=\"Select teams\"\n variant=\"outline\"\n iconNameLeft=\"general.search\"\n size=\"sm\"\n />\n )}\n </View>\n <View>\n {isServiceTypesFetching ? (\n <DefaultLoading />\n ) : hasServiceTypes ? (\n <>\n {visibleServiceTypes.map(serviceType => {\n return (\n <TeamRecipientRow\n key={serviceType.id}\n serviceType={serviceType}\n onPress={handleTeamsNavigateToConversationNew}\n />\n )\n })}\n {hasMoreServiceTypes && (\n <ViewMoreLinkRow\n onPress={handleServiceTypesViewMore}\n accessibilityHint=\"Navigate to a full list of teams you lead.\"\n />\n )}\n </>\n ) : (\n <BlankState subtitle=\"You don't lead any teams.\" style={styles.blankState} />\n )}\n </View>\n </View>\n </ScrollView>\n )\n}\n\nconst useStyles = () => {\n const { bottom } = useSafeAreaInsets()\n\n return StyleSheet.create({\n contentContainer: {\n gap: 24,\n paddingTop: 16,\n paddingBottom: 16 + bottom,\n },\n section: {\n flex: 1,\n },\n sectionHeader: {\n flexDirection: 'row',\n justifyContent: 'space-between',\n paddingHorizontal: 16,\n paddingBottom: 4,\n },\n selectTeamsButton: {},\n blankState: {\n marginTop: 24,\n marginBottom: 48,\n },\n })\n}\n"]}
1
+ {"version":3,"file":"conversation_select_recipients_screen.js","sourceRoot":"","sources":["../../../src/screens/conversation_select_recipients/conversation_select_recipients_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACxD,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAE9D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAElE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AACjE,OAAO,EAAE,8BAA8B,EAAE,MAAM,iDAAiD,CAAA;AAChG,OAAO,EAAE,wBAAwB,EAAE,MAAM,sEAAsE,CAAA;AAE/G,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAA;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,MAAM,sBAAsB,GAAG,CAAC,CAAA;AAEhC,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,EACjD,KAAK,GACmC,EAAE,EAAE;IAC5C,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAC1B,MAAM,UAAU,GAAG,aAAa,EAAE,CAAA;IAClC,MAAM,SAAS,GAAG,YAAY,EAAE,CAAA;IAChC,MAAM,4BAA4B,GAAG,SAAS,CAAC,IAAI,EAAE,IAAI,CACvD,CA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SAC3B;QACD,OAAO,EAAE;YACP,IAAI,EAAE,CAAC;SACR;QACD,aAAa,EAAE;YACb,aAAa,EAAE,KAAK;YACpB,cAAc,EAAE,eAAe;YAC/B,iBAAiB,EAAE,EAAE;YACrB,aAAa,EAAE,CAAC;SACjB;QACD,iBAAiB,EAAE,EAAE;QACrB,UAAU,EAAE;YACV,SAAS,EAAE,EAAE;YACb,YAAY,EAAE,EAAE;SACjB;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { useNavigation } from '@react-navigation/native'\nimport React from 'react'\nimport { ScrollView, StyleSheet, View } from 'react-native'\nimport { BlankState, Button, Heading } from '../../components'\nimport { GroupsGroupResource } from '../../types'\nimport { useGroupsGroups } from '../../hooks/use_groups_groups'\nimport { useSafeAreaInsets } from 'react-native-safe-area-context'\nimport { ConversationSelectRecipientsScreenProps } from './types/screen_props'\nimport { ViewMoreLinkRow } from './components/view_more_link_row'\nimport { GroupsWithoutChatDisclaimerRow } from './components/groups_without_chat_disclaimer_row'\nimport { useServiceTypesWithTeams } from '../conversation_filter_recipients/hooks/use_service_types_with_teams'\nimport { ServiceTypeWithTeams } from '../conversation_filter_recipients/types'\nimport { TeamRecipientRow } from './components/team_recipient_row'\nimport { GroupsRecipientRow } from './components/groups_recipient_row'\nimport { DefaultLoading } from '../../components/page/loading'\nimport { useAppGrants } from '../../hooks'\n\nconst MAX_VISIBLE_RECIPIENTS = 5\n\nexport const ConversationSelectRecipientsScreen = ({\n route,\n}: ConversationSelectRecipientsScreenProps) => {\n const styles = useStyles()\n const navigation = useNavigation()\n const appGrants = useAppGrants()\n const canCreateGroupsConversations = appGrants.data?.some(\n g => g.createConversations && g.appName === 'Groups'\n )\n const canCreateServicesConversations = appGrants.data?.some(\n g => g.createConversations && g.appName === 'Services'\n )\n const { data: groups = [], isFetching: isGroupsFetching } = useGroupsGroups()\n const groupsWithCreatePermission = groups.filter(g => g.canCreateConversation)\n const visibleGroups = groupsWithCreatePermission.slice(0, MAX_VISIBLE_RECIPIENTS)\n const hasMoreGroups = groupsWithCreatePermission.length > MAX_VISIBLE_RECIPIENTS\n const hasGroupsWithoutChatPermission = groups.length > groupsWithCreatePermission.length\n const showGroupsDisclaimer = hasGroupsWithoutChatPermission && !hasMoreGroups\n\n const handleGroupsNavigateToConversationNew = (group: GroupsGroupResource) => {\n navigation.navigate('New', {\n screen: 'ConversationNew',\n params: {\n group_id: group.id,\n source_app_name: 'Groups',\n ...route.params,\n },\n })\n }\n\n const handleGroupsViewMore = () => {\n navigation.navigate('New', {\n screen: 'ConversationSelectGroupRecipients',\n params: {\n ...route.params,\n },\n })\n }\n\n const { serviceTypes, isFetching: isServiceTypesFetching } = useServiceTypesWithTeams()\n const visibleServiceTypes = serviceTypes.slice(0, MAX_VISIBLE_RECIPIENTS)\n const hasMoreServiceTypes = serviceTypes.length > MAX_VISIBLE_RECIPIENTS\n const hasServiceTypes = serviceTypes.length > 0\n\n const handleTeamsNavigateToConversationNew = (teams: ServiceTypeWithTeams['teams']) => {\n const teamIds = teams.map(team => team.id)\n\n navigation.navigate('New', {\n screen: 'ConversationNew',\n params: {\n team_ids: teamIds,\n source_app_name: 'Services',\n ...route.params,\n },\n })\n }\n\n const handleServiceTypesViewMore = () => {\n navigation.navigate('New', {\n screen: 'ConversationSelectTeamsILeadRecipients',\n params: {\n ...route.params,\n },\n })\n }\n\n return (\n <ScrollView contentContainerStyle={styles.contentContainer}>\n {canCreateGroupsConversations && (\n <View style={styles.section}>\n <View style={styles.sectionHeader}>\n <Heading variant=\"h3\">My groups</Heading>\n </View>\n <View>\n {isGroupsFetching ? (\n <DefaultLoading />\n ) : groupsWithCreatePermission.length === 0 ? (\n <BlankState\n subtitle=\"Join a group with chat enabled and permissions to start a new conversation.\"\n style={styles.blankState}\n />\n ) : (\n <>\n {visibleGroups.map(group => {\n return (\n <GroupsRecipientRow\n key={group.id}\n group={group}\n onPress={handleGroupsNavigateToConversationNew}\n />\n )\n })}\n {hasMoreGroups && (\n <ViewMoreLinkRow\n onPress={handleGroupsViewMore}\n accessibilityHint=\"Navigate to a full list of your groups.\"\n />\n )}\n {showGroupsDisclaimer && <GroupsWithoutChatDisclaimerRow />}\n </>\n )}\n </View>\n </View>\n )}\n {canCreateServicesConversations && (\n <View style={styles.section}>\n <View style={styles.sectionHeader}>\n <Heading variant=\"h3\">Teams I lead</Heading>\n {hasServiceTypes && (\n <Button\n style={styles.selectTeamsButton}\n onPress={() =>\n navigation.navigate('New', {\n screen: 'ConversationFilterRecipients',\n params: {\n source_app_name: 'Services',\n },\n })\n }\n title=\"Select teams\"\n variant=\"outline\"\n iconNameLeft=\"general.search\"\n size=\"sm\"\n />\n )}\n </View>\n <View>\n {isServiceTypesFetching ? (\n <DefaultLoading />\n ) : hasServiceTypes ? (\n <>\n {visibleServiceTypes.map(serviceType => {\n return (\n <TeamRecipientRow\n key={serviceType.id}\n serviceType={serviceType}\n onPress={handleTeamsNavigateToConversationNew}\n />\n )\n })}\n {hasMoreServiceTypes && (\n <ViewMoreLinkRow\n onPress={handleServiceTypesViewMore}\n accessibilityHint=\"Navigate to a full list of teams you lead.\"\n />\n )}\n </>\n ) : (\n <BlankState subtitle=\"You don't lead any teams.\" style={styles.blankState} />\n )}\n </View>\n </View>\n )}\n </ScrollView>\n )\n}\n\nconst useStyles = () => {\n const { bottom } = useSafeAreaInsets()\n\n return StyleSheet.create({\n contentContainer: {\n gap: 24,\n paddingTop: 16,\n paddingBottom: 16 + bottom,\n },\n section: {\n flex: 1,\n },\n sectionHeader: {\n flexDirection: 'row',\n justifyContent: 'space-between',\n paddingHorizontal: 16,\n paddingBottom: 4,\n },\n selectTeamsButton: {},\n blankState: {\n marginTop: 24,\n marginBottom: 48,\n },\n })\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planningcenter/chat-react-native",
3
- "version": "3.11.0-rc.13",
3
+ "version": "3.11.0-rc.15",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -55,5 +55,5 @@
55
55
  "prettier": "^3.4.2",
56
56
  "typescript": "<5.6.0"
57
57
  },
58
- "gitHead": "905fd163f4090ed8d212ce8d841ddf9f88162a1f"
58
+ "gitHead": "860cc60acb3af7597f5f2f193a691415ba9bd663"
59
59
  }
@@ -1,8 +1,14 @@
1
- import { focusManager, QueryClient, QueryClientProvider, QueryKey } from '@tanstack/react-query'
1
+ import {
2
+ focusManager,
3
+ QueryClient,
4
+ QueryClientProvider,
5
+ QueryKey,
6
+ usePrefetchQuery,
7
+ } from '@tanstack/react-query'
2
8
  import React, { useContext, useEffect, useRef } from 'react'
3
9
  import { ViewProps } from 'react-native'
4
10
  import { ChatContext, ChatContextValue } from './chat_context'
5
- import { RequestQueryKey } from '../hooks'
11
+ import { appGrantsRequestArgs, getRequestQueryKey, RequestQueryKey } from '../hooks'
6
12
  import { ApiClient, useApiClient } from '../hooks/use_api_client'
7
13
  import { useAppState } from '../hooks/use_app_state'
8
14
 
@@ -39,7 +45,24 @@ export function ApiProvider({ children }: ViewProps) {
39
45
  chatQueryClient.clear()
40
46
  }, [sessionChanged])
41
47
 
42
- return <QueryClientProvider client={chatQueryClient}>{children}</QueryClientProvider>
48
+ return (
49
+ <QueryClientProvider client={chatQueryClient}>
50
+ <PrefetchQueries />
51
+ {children}
52
+ </QueryClientProvider>
53
+ )
54
+ }
55
+
56
+ // Component to prefetch queries when the app is focused
57
+ // This needs to live in the provider so that it can access the api client
58
+ // and the chat query client
59
+ const PrefetchQueries = () => {
60
+ usePrefetchQuery({
61
+ queryKey: getRequestQueryKey(appGrantsRequestArgs),
62
+ queryFn: defaultQueryFn,
63
+ })
64
+
65
+ return null
43
66
  }
44
67
 
45
68
  export function useFocusManager() {
@@ -1,16 +1,19 @@
1
1
  import { AppGrantsResource } from '../types'
2
2
  import { useApiGet } from './use_api'
3
+ import { App } from './use_api_client'
3
4
 
4
- export function useAppGrants() {
5
- return useApiGet<AppGrantsResource[]>({
6
- url: '/me/app_grants',
7
- data: {
8
- fields: {
9
- AppGrant: ['create_conversations', 'app_name'],
10
- },
5
+ export const appGrantsRequestArgs = {
6
+ url: '/me/app_grants',
7
+ data: {
8
+ fields: {
9
+ AppGrant: ['create_conversations', 'app_name'],
11
10
  },
12
- app: 'chat',
13
- })
11
+ },
12
+ app: 'chat' as App,
13
+ }
14
+
15
+ export function useAppGrants() {
16
+ return useApiGet<AppGrantsResource[]>(appGrantsRequestArgs)
14
17
  }
15
18
 
16
19
  export function useCanCreateConversations(): boolean {
@@ -13,6 +13,7 @@ import { ServiceTypeWithTeams } from '../conversation_filter_recipients/types'
13
13
  import { TeamRecipientRow } from './components/team_recipient_row'
14
14
  import { GroupsRecipientRow } from './components/groups_recipient_row'
15
15
  import { DefaultLoading } from '../../components/page/loading'
16
+ import { useAppGrants } from '../../hooks'
16
17
 
17
18
  const MAX_VISIBLE_RECIPIENTS = 5
18
19
 
@@ -21,7 +22,13 @@ export const ConversationSelectRecipientsScreen = ({
21
22
  }: ConversationSelectRecipientsScreenProps) => {
22
23
  const styles = useStyles()
23
24
  const navigation = useNavigation()
24
-
25
+ const appGrants = useAppGrants()
26
+ const canCreateGroupsConversations = appGrants.data?.some(
27
+ g => g.createConversations && g.appName === 'Groups'
28
+ )
29
+ const canCreateServicesConversations = appGrants.data?.some(
30
+ g => g.createConversations && g.appName === 'Services'
31
+ )
25
32
  const { data: groups = [], isFetching: isGroupsFetching } = useGroupsGroups()
26
33
  const groupsWithCreatePermission = groups.filter(g => g.canCreateConversation)
27
34
  const visibleGroups = groupsWithCreatePermission.slice(0, MAX_VISIBLE_RECIPIENTS)
@@ -78,87 +85,91 @@ export const ConversationSelectRecipientsScreen = ({
78
85
 
79
86
  return (
80
87
  <ScrollView contentContainerStyle={styles.contentContainer}>
81
- <View style={styles.section}>
82
- <View style={styles.sectionHeader}>
83
- <Heading variant="h3">My groups</Heading>
84
- </View>
85
- <View>
86
- {isGroupsFetching ? (
87
- <DefaultLoading />
88
- ) : groupsWithCreatePermission.length === 0 ? (
89
- <BlankState
90
- subtitle="Join a group with chat enabled and permissions to start a new conversation."
91
- style={styles.blankState}
92
- />
93
- ) : (
94
- <>
95
- {visibleGroups.map(group => {
96
- return (
97
- <GroupsRecipientRow
98
- key={group.id}
99
- group={group}
100
- onPress={handleGroupsNavigateToConversationNew}
88
+ {canCreateGroupsConversations && (
89
+ <View style={styles.section}>
90
+ <View style={styles.sectionHeader}>
91
+ <Heading variant="h3">My groups</Heading>
92
+ </View>
93
+ <View>
94
+ {isGroupsFetching ? (
95
+ <DefaultLoading />
96
+ ) : groupsWithCreatePermission.length === 0 ? (
97
+ <BlankState
98
+ subtitle="Join a group with chat enabled and permissions to start a new conversation."
99
+ style={styles.blankState}
100
+ />
101
+ ) : (
102
+ <>
103
+ {visibleGroups.map(group => {
104
+ return (
105
+ <GroupsRecipientRow
106
+ key={group.id}
107
+ group={group}
108
+ onPress={handleGroupsNavigateToConversationNew}
109
+ />
110
+ )
111
+ })}
112
+ {hasMoreGroups && (
113
+ <ViewMoreLinkRow
114
+ onPress={handleGroupsViewMore}
115
+ accessibilityHint="Navigate to a full list of your groups."
101
116
  />
102
- )
103
- })}
104
- {hasMoreGroups && (
105
- <ViewMoreLinkRow
106
- onPress={handleGroupsViewMore}
107
- accessibilityHint="Navigate to a full list of your groups."
108
- />
109
- )}
110
- {showGroupsDisclaimer && <GroupsWithoutChatDisclaimerRow />}
111
- </>
112
- )}
113
- </View>
114
- </View>
115
- <View style={styles.section}>
116
- <View style={styles.sectionHeader}>
117
- <Heading variant="h3">Teams I lead</Heading>
118
- {hasServiceTypes && (
119
- <Button
120
- style={styles.selectTeamsButton}
121
- onPress={() =>
122
- navigation.navigate('New', {
123
- screen: 'ConversationFilterRecipients',
124
- params: {
125
- source_app_name: 'Services',
126
- },
127
- })
128
- }
129
- title="Select teams"
130
- variant="outline"
131
- iconNameLeft="general.search"
132
- size="sm"
133
- />
134
- )}
117
+ )}
118
+ {showGroupsDisclaimer && <GroupsWithoutChatDisclaimerRow />}
119
+ </>
120
+ )}
121
+ </View>
135
122
  </View>
136
- <View>
137
- {isServiceTypesFetching ? (
138
- <DefaultLoading />
139
- ) : hasServiceTypes ? (
140
- <>
141
- {visibleServiceTypes.map(serviceType => {
142
- return (
143
- <TeamRecipientRow
144
- key={serviceType.id}
145
- serviceType={serviceType}
146
- onPress={handleTeamsNavigateToConversationNew}
123
+ )}
124
+ {canCreateServicesConversations && (
125
+ <View style={styles.section}>
126
+ <View style={styles.sectionHeader}>
127
+ <Heading variant="h3">Teams I lead</Heading>
128
+ {hasServiceTypes && (
129
+ <Button
130
+ style={styles.selectTeamsButton}
131
+ onPress={() =>
132
+ navigation.navigate('New', {
133
+ screen: 'ConversationFilterRecipients',
134
+ params: {
135
+ source_app_name: 'Services',
136
+ },
137
+ })
138
+ }
139
+ title="Select teams"
140
+ variant="outline"
141
+ iconNameLeft="general.search"
142
+ size="sm"
143
+ />
144
+ )}
145
+ </View>
146
+ <View>
147
+ {isServiceTypesFetching ? (
148
+ <DefaultLoading />
149
+ ) : hasServiceTypes ? (
150
+ <>
151
+ {visibleServiceTypes.map(serviceType => {
152
+ return (
153
+ <TeamRecipientRow
154
+ key={serviceType.id}
155
+ serviceType={serviceType}
156
+ onPress={handleTeamsNavigateToConversationNew}
157
+ />
158
+ )
159
+ })}
160
+ {hasMoreServiceTypes && (
161
+ <ViewMoreLinkRow
162
+ onPress={handleServiceTypesViewMore}
163
+ accessibilityHint="Navigate to a full list of teams you lead."
147
164
  />
148
- )
149
- })}
150
- {hasMoreServiceTypes && (
151
- <ViewMoreLinkRow
152
- onPress={handleServiceTypesViewMore}
153
- accessibilityHint="Navigate to a full list of teams you lead."
154
- />
155
- )}
156
- </>
157
- ) : (
158
- <BlankState subtitle="You don't lead any teams." style={styles.blankState} />
159
- )}
165
+ )}
166
+ </>
167
+ ) : (
168
+ <BlankState subtitle="You don't lead any teams." style={styles.blankState} />
169
+ )}
170
+ </View>
160
171
  </View>
161
- </View>
172
+ )}
162
173
  </ScrollView>
163
174
  )
164
175
  }