@planningcenter/chat-react-native 3.13.0-rc.6 → 3.13.0-rc.8
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/screens/reactions_screen.d.ts.map +1 -1
- package/build/screens/reactions_screen.js +11 -6
- package/build/screens/reactions_screen.js.map +1 -1
- package/build/utils/client/transform_request_data.d.ts +1 -1
- package/build/utils/client/transform_request_data.d.ts.map +1 -1
- package/build/utils/client/transform_request_data.js.map +1 -1
- package/build/utils/native_adapters/linking.js +3 -2
- package/build/utils/native_adapters/linking.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/utils/native_adapters/configuration.ts +78 -5
- package/src/screens/reactions_screen.tsx +17 -9
- package/src/utils/client/transform_request_data.ts +3 -4
- package/src/utils/client/types.d.ts +2 -2
- package/src/utils/native_adapters/linking.ts +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactions_screen.d.ts","sourceRoot":"","sources":["../../src/screens/reactions_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,KAAe,MAAM,OAAO,CAAA;AAenC,eAAO,MAAM,sBAAsB,uEAMjC,CAAA;AAEF,MAAM,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;IAClD,UAAU,EAAE,MAAM,CAAA;IAClB,eAAe,EAAE,MAAM,CAAA;IACvB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB,CAAC,CAAA;AAEF,wBAAgB,eAAe,CAAC,EAAE,KAAK,EAAE,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"reactions_screen.d.ts","sourceRoot":"","sources":["../../src/screens/reactions_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,KAAe,MAAM,OAAO,CAAA;AAenC,eAAO,MAAM,sBAAsB,uEAMjC,CAAA;AAEF,MAAM,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;IAClD,UAAU,EAAE,MAAM,CAAA;IAClB,eAAe,EAAE,MAAM,CAAA;IACvB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB,CAAC,CAAA;AAEF,wBAAgB,eAAe,CAAC,EAAE,KAAK,EAAE,EAAE,mBAAmB,qBAkE7D"}
|
|
@@ -21,25 +21,30 @@ export function ReactionsScreen({ route }) {
|
|
|
21
21
|
const { conversation_id, message_id, reaction_value } = route.params;
|
|
22
22
|
const styles = useStyles();
|
|
23
23
|
const { messages } = useConversationMessages({ conversation_id }, { refetchOnMount: false });
|
|
24
|
+
const message = messages.find(m => m.id === message_id);
|
|
25
|
+
const reactionCounts = message?.reactionCounts || [];
|
|
26
|
+
const initialReactionCount = reactionCounts.find(r => r.value === reaction_value) || reactionCounts[0];
|
|
27
|
+
const [reactionCountValue, setReactionCountValue] = React.useState(initialReactionCount?.value);
|
|
28
|
+
const reactionCount = reactionCounts.find(r => r.value === reactionCountValue);
|
|
29
|
+
// Get author IDs for the API call, ensuring we have a valid array
|
|
30
|
+
const authorIds = reactionCount?.authorIds || [];
|
|
24
31
|
const { data: members } = useSuspenseGet({
|
|
25
32
|
url: `/me/conversations/${conversation_id}/members`,
|
|
26
33
|
data: {
|
|
27
34
|
fields: {
|
|
28
35
|
Member: ['id', 'name', 'avatar', 'badges', 'child', 'role'],
|
|
29
36
|
},
|
|
37
|
+
where: {
|
|
38
|
+
id: authorIds,
|
|
39
|
+
},
|
|
40
|
+
limit: authorIds.length,
|
|
30
41
|
},
|
|
31
42
|
});
|
|
32
|
-
const message = messages.find(m => m.id === message_id);
|
|
33
|
-
const reactionCounts = message?.reactionCounts || [];
|
|
34
|
-
const initialReactionCount = reactionCounts.find(r => r.value === reaction_value) || reactionCounts[0];
|
|
35
|
-
const [reactionCountValue, setReactionCountValue] = React.useState(initialReactionCount.value);
|
|
36
|
-
const reactionCount = reactionCounts.find(r => r.value === reactionCountValue);
|
|
37
43
|
if (!reactionCount) {
|
|
38
44
|
return (<View style={styles.errorContainer}>
|
|
39
45
|
<Text>No reactions found for this message.</Text>
|
|
40
46
|
</View>);
|
|
41
47
|
}
|
|
42
|
-
const authorIds = reactionCount.authorIds;
|
|
43
48
|
const authors = members.filter(member => authorIds.includes(member.id));
|
|
44
49
|
return (<FormSheet.Root contentStyle={styles.formSheetContent}>
|
|
45
50
|
<Tabs data={reactionCounts} activeTab={reactionCount} onTabPress={item => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactions_screen.js","sourceRoot":"","sources":["../../src/screens/reactions_screen.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAClE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAA;AAC7E,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAA;AACjD,OAAO,SAAS,EAAE,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAA;AACzF,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAA;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAGtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAA;AAEnD,MAAM,CAAC,MAAM,sBAAsB,GAAG,yBAAyB,CAAC;IAC9D,mBAAmB,EAAE,QAAQ,CAAC,MAAM,CAAC;QACnC,OAAO,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,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AAc,EAAE,QAAQ;YACxB,UAAU,EAAE,QAAQ;YACpB,OAAO,EAAE,EAAE;YACX,SAAS,EAAE,EAAE;SACd;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { StaticScreenProps } from '@react-navigation/native'\nimport React, { memo } from 'react'\nimport { Platform, StyleSheet, View } from 'react-native'\nimport { FlatList } from 'react-native-gesture-handler'\nimport { useSafeAreaInsets } from 'react-native-safe-area-context'\nimport { Avatar, Text } from '../components'\nimport { REACTION_EMOJIS } from '../components/conversation/message_reaction'\nimport { Tabs } from '../components/display/tabs'\nimport FormSheet, { getFormSheetScreenOptions } from '../components/primitive/form_sheet'\nimport { useSuspenseGet, useTheme } from '../hooks'\nimport { useConversationMessages } from '../hooks/use_conversation_messages'\nimport { useFontScale } from '../hooks/use_font_scale'\nimport { MemberResource } from '../types'\nimport { ReactionCountResource } from '../types/resources/reaction'\nimport { platformFontWeightMedium } from '../utils'\n\nexport const ReactionsScreenOptions = getFormSheetScreenOptions({\n sheetAllowedDetents: Platform.select({\n android: [0.5, 0.94], // Going straight to full 0.94 preserves height of screen on Android\n default: [0.5, 1],\n }),\n headerTitle: 'Reactions',\n})\n\nexport type ReactionScreenProps = StaticScreenProps<{\n message_id: string\n conversation_id: number\n reaction_value?: string\n}>\n\nexport function ReactionsScreen({ route }: ReactionScreenProps) {\n const { conversation_id, message_id, reaction_value } = route.params\n const styles = useStyles()\n\n const { messages } = useConversationMessages({ conversation_id }, { refetchOnMount: false })\n const { data: members } = useSuspenseGet<MemberResource[]>({\n url: `/me/conversations/${conversation_id}/members`,\n data: {\n fields: {\n Member: ['id', 'name', 'avatar', 'badges', 'child', 'role'],\n },\n },\n })\n const message = messages.find(m => m.id === message_id)\n const reactionCounts = message?.reactionCounts || []\n const initialReactionCount =\n reactionCounts.find(r => r.value === reaction_value) || reactionCounts[0]\n const [reactionCountValue, setReactionCountValue] = React.useState<\n ReactionCountResource['value']\n >(initialReactionCount.value)\n const reactionCount = reactionCounts.find(r => r.value === reactionCountValue)\n\n if (!reactionCount) {\n return (\n <View style={styles.errorContainer}>\n <Text>No reactions found for this message.</Text>\n </View>\n )\n }\n\n const authorIds = reactionCount.authorIds\n const authors = members.filter(member => authorIds.includes(member.id))\n\n return (\n <FormSheet.Root contentStyle={styles.formSheetContent}>\n <Tabs\n data={reactionCounts}\n activeTab={reactionCount}\n onTabPress={item => {\n setReactionCountValue(item.value)\n }}\n renderItem={({ item }) => (\n <Reaction\n active={reactionCount.id === item.id}\n reaction={item}\n onPress={() => setReactionCountValue(item.value)}\n />\n )}\n style={styles.actions}\n />\n <FlatList\n data={authors}\n contentContainerStyle={styles.contentContainer}\n keyExtractor={item => item.id.toString()}\n renderItem={({ item: author }) => <Author author={author} key={author.id} />}\n />\n </FormSheet.Root>\n )\n}\n\nconst Reaction = ({\n reaction,\n}: {\n active: boolean\n reaction: ReactionCountResource\n onPress: () => void\n}) => {\n const styles = useStyles()\n\n return (\n <View key={reaction.value} style={styles.reaction}>\n <Text style={styles.reactionContent}>{REACTION_EMOJIS[reaction.value]}</Text>\n <Text style={styles.reactionContent}>{reaction.count}</Text>\n </View>\n )\n}\n\ntype AuthorProps = Pick<MemberResource, 'id' | 'name' | 'avatar'>\n\nconst Author = memo(({ author }: { author: AuthorProps }) => {\n const styles = useStyles()\n\n return (\n <View style={styles.authorRow}>\n <Avatar sourceUri={author.avatar} size=\"sm\" />\n <Text variant=\"tertiary\" numberOfLines={2} style={styles.authorName}>\n {author.name}\n </Text>\n </View>\n )\n})\n\nconst TABS_HEIGHT = 67\n\nconst useStyles = () => {\n const { colors } = useTheme()\n const { bottom } = useSafeAreaInsets()\n const fontScale = useFontScale({ maxFontSizeMultiplier: 1.3 })\n\n return StyleSheet.create({\n formSheetContent: {\n paddingTop: 16,\n },\n contentContainer: {\n paddingTop: 8,\n paddingBottom: bottom + Platform.select({ android: 24, default: TABS_HEIGHT + 24 }),\n },\n authorRow: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 8,\n paddingVertical: 8,\n paddingHorizontal: 16,\n flex: 1,\n },\n authorName: {\n flex: 1,\n },\n reaction: {\n paddingHorizontal: 8,\n paddingVertical: 16,\n flexDirection: 'row',\n gap: 4,\n },\n reactionContent: {\n fontSize: 18,\n fontWeight: platformFontWeightMedium,\n },\n actions: {\n minHeight: 68 * fontScale,\n borderBottomColor: colors.borderColorDefaultBase,\n borderBottomWidth: 1,\n },\n errorContainer: {\n flex: 1,\n justifyContent: 'center',\n alignItems: 'center',\n padding: 16,\n marginTop: 30,\n },\n })\n}\n"]}
|
|
1
|
+
{"version":3,"file":"reactions_screen.js","sourceRoot":"","sources":["../../src/screens/reactions_screen.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAClE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAA;AAC7E,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAA;AACjD,OAAO,SAAS,EAAE,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAA;AACzF,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAA;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAGtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAA;AAEnD,MAAM,CAAC,MAAM,sBAAsB,GAAG,yBAAyB,CAAC;IAC9D,mBAAmB,EAAE,QAAQ,CAAC,MAAM,CAAC;QACnC,OAAO,EAA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EAAE,EAAE,GAAG,SAAS;YACzB,iBAAiB,EAAE,MAAM,CAAC,sBAAsB;YAChD,iBAAiB,EAAE,CAAC;SACrB;QACD,cAAc,EAAE;YACd,IAAI,EAAE,CAAC;YACP,cAAc,EAAE,QAAQ;YACxB,UAAU,EAAE,QAAQ;YACpB,OAAO,EAAE,EAAE;YACX,SAAS,EAAE,EAAE;SACd;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { StaticScreenProps } from '@react-navigation/native'\nimport React, { memo } from 'react'\nimport { Platform, StyleSheet, View } from 'react-native'\nimport { FlatList } from 'react-native-gesture-handler'\nimport { useSafeAreaInsets } from 'react-native-safe-area-context'\nimport { Avatar, Text } from '../components'\nimport { REACTION_EMOJIS } from '../components/conversation/message_reaction'\nimport { Tabs } from '../components/display/tabs'\nimport FormSheet, { getFormSheetScreenOptions } from '../components/primitive/form_sheet'\nimport { useSuspenseGet, useTheme } from '../hooks'\nimport { useConversationMessages } from '../hooks/use_conversation_messages'\nimport { useFontScale } from '../hooks/use_font_scale'\nimport { MemberResource } from '../types'\nimport { ReactionCountResource } from '../types/resources/reaction'\nimport { platformFontWeightMedium } from '../utils'\n\nexport const ReactionsScreenOptions = getFormSheetScreenOptions({\n sheetAllowedDetents: Platform.select({\n android: [0.5, 0.94], // Going straight to full 0.94 preserves height of screen on Android\n default: [0.5, 1],\n }),\n headerTitle: 'Reactions',\n})\n\nexport type ReactionScreenProps = StaticScreenProps<{\n message_id: string\n conversation_id: number\n reaction_value?: string\n}>\n\nexport function ReactionsScreen({ route }: ReactionScreenProps) {\n const { conversation_id, message_id, reaction_value } = route.params\n const styles = useStyles()\n\n const { messages } = useConversationMessages({ conversation_id }, { refetchOnMount: false })\n\n const message = messages.find(m => m.id === message_id)\n const reactionCounts = message?.reactionCounts || []\n const initialReactionCount =\n reactionCounts.find(r => r.value === reaction_value) || reactionCounts[0]\n const [reactionCountValue, setReactionCountValue] = React.useState<\n ReactionCountResource['value']\n >(initialReactionCount?.value)\n const reactionCount = reactionCounts.find(r => r.value === reactionCountValue)\n\n // Get author IDs for the API call, ensuring we have a valid array\n const authorIds = reactionCount?.authorIds || []\n\n const { data: members } = useSuspenseGet<MemberResource[]>({\n url: `/me/conversations/${conversation_id}/members`,\n data: {\n fields: {\n Member: ['id', 'name', 'avatar', 'badges', 'child', 'role'],\n },\n where: {\n id: authorIds,\n },\n limit: authorIds.length,\n },\n })\n\n if (!reactionCount) {\n return (\n <View style={styles.errorContainer}>\n <Text>No reactions found for this message.</Text>\n </View>\n )\n }\n\n const authors = members.filter(member => authorIds.includes(member.id))\n\n return (\n <FormSheet.Root contentStyle={styles.formSheetContent}>\n <Tabs\n data={reactionCounts}\n activeTab={reactionCount}\n onTabPress={item => {\n setReactionCountValue(item.value)\n }}\n renderItem={({ item }) => (\n <Reaction\n active={reactionCount.id === item.id}\n reaction={item}\n onPress={() => setReactionCountValue(item.value)}\n />\n )}\n style={styles.actions}\n />\n <FlatList\n data={authors}\n contentContainerStyle={styles.contentContainer}\n keyExtractor={item => item.id.toString()}\n renderItem={({ item: author }) => <Author author={author} key={author.id} />}\n />\n </FormSheet.Root>\n )\n}\n\nconst Reaction = ({\n reaction,\n}: {\n active: boolean\n reaction: ReactionCountResource\n onPress: () => void\n}) => {\n const styles = useStyles()\n\n return (\n <View key={reaction.value} style={styles.reaction}>\n <Text style={styles.reactionContent}>{REACTION_EMOJIS[reaction.value]}</Text>\n <Text style={styles.reactionContent}>{reaction.count}</Text>\n </View>\n )\n}\n\ntype AuthorProps = Pick<MemberResource, 'id' | 'name' | 'avatar'>\n\nconst Author = memo(({ author }: { author: AuthorProps }) => {\n const styles = useStyles()\n\n return (\n <View style={styles.authorRow}>\n <Avatar sourceUri={author.avatar} size=\"sm\" />\n <Text variant=\"tertiary\" numberOfLines={2} style={styles.authorName}>\n {author.name}\n </Text>\n </View>\n )\n})\n\nconst TABS_HEIGHT = 67\n\nconst useStyles = () => {\n const { colors } = useTheme()\n const { bottom } = useSafeAreaInsets()\n const fontScale = useFontScale({ maxFontSizeMultiplier: 1.3 })\n\n return StyleSheet.create({\n formSheetContent: {\n paddingTop: 16,\n },\n contentContainer: {\n paddingTop: 8,\n paddingBottom: bottom + Platform.select({ android: 24, default: TABS_HEIGHT + 24 }),\n },\n authorRow: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 8,\n paddingVertical: 8,\n paddingHorizontal: 16,\n flex: 1,\n },\n authorName: {\n flex: 1,\n },\n reaction: {\n paddingHorizontal: 8,\n paddingVertical: 16,\n flexDirection: 'row',\n gap: 4,\n },\n reactionContent: {\n fontSize: 18,\n fontWeight: platformFontWeightMedium,\n },\n actions: {\n minHeight: 68 * fontScale,\n borderBottomColor: colors.borderColorDefaultBase,\n borderBottomWidth: 1,\n },\n errorContainer: {\n flex: 1,\n justifyContent: 'center',\n alignItems: 'center',\n padding: 16,\n marginTop: 30,\n },\n })\n}\n"]}
|
|
@@ -2,7 +2,7 @@ import { RequestData } from './types';
|
|
|
2
2
|
export declare const transformRequestData: ({ fields, where, include, perPage, ...restData }: Partial<RequestData>) => {
|
|
3
3
|
include: string | undefined;
|
|
4
4
|
};
|
|
5
|
-
export declare function flattenAttribute<T extends Record<string, string | string[]>>(obj: T | undefined, key: keyof T): {};
|
|
5
|
+
export declare function flattenAttribute<T extends Record<string, string | number | (string | number)[] | string[]>>(obj: T | undefined, key: keyof T): {};
|
|
6
6
|
type QueryArgs = {
|
|
7
7
|
key: string;
|
|
8
8
|
value: string | number | boolean | object | any[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform_request_data.d.ts","sourceRoot":"","sources":["../../../src/utils/client/transform_request_data.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAErC,eAAO,MAAM,oBAAoB,qDAM9B,OAAO,CAAC,WAAW,CAAC;;CAOtB,CAAA;AAED,wBAAgB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"transform_request_data.d.ts","sourceRoot":"","sources":["../../../src/utils/client/transform_request_data.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAErC,eAAO,MAAM,oBAAoB,qDAM9B,OAAO,CAAC,WAAW,CAAC;;CAOtB,CAAA;AAED,wBAAgB,gBAAgB,CAC9B,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC,EAC1E,GAAG,EAAE,CAAC,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,CAAC,MAajC;AAED,KAAK,SAAS,GAAG;IACf,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,GAAG,EAAE,CAAA;CAClD,CAAA;AACD,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAA;AAE5D,wBAAgB,UAAU,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,SAAS,GAAG,WAAW,CAajE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform_request_data.js","sourceRoot":"","sources":["../../../src/utils/client/transform_request_data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAGzC,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,EACnC,MAAM,EACN,KAAK,EACL,OAAO,EACP,OAAO,GAAG,GAAG,EACb,GAAG,QAAQ,EACU,EAAE,EAAE;IACzB,OAAO;QACL,GAAG,gBAAgB,CAAC,MAAM,EAAE,QAAQ,CAAC;QACrC,GAAG,gBAAgB,CAAC,KAAK,EAAE,OAAO,CAAC;QACnC,GAAG,eAAe,CAAC,EAAE,OAAO,EAAE,GAAG,QAAQ,EAAE,CAAC;QAC5C,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO;KAC9D,CAAA;AACH,CAAC,CAAA;AAED,MAAM,UAAU,gBAAgB,
|
|
1
|
+
{"version":3,"file":"transform_request_data.js","sourceRoot":"","sources":["../../../src/utils/client/transform_request_data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAGzC,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,EACnC,MAAM,EACN,KAAK,EACL,OAAO,EACP,OAAO,GAAG,GAAG,EACb,GAAG,QAAQ,EACU,EAAE,EAAE;IACzB,OAAO;QACL,GAAG,gBAAgB,CAAC,MAAM,EAAE,QAAQ,CAAC;QACrC,GAAG,gBAAgB,CAAC,KAAK,EAAE,OAAO,CAAC;QACnC,GAAG,eAAe,CAAC,EAAE,OAAO,EAAE,GAAG,QAAQ,EAAE,CAAC;QAC5C,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO;KAC9D,CAAA;AACH,CAAC,CAAA;AAED,MAAM,UAAU,gBAAgB,CAE9B,GAAkB,EAAE,GAAY;IAChC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAA;IAEzC,OAAO,MAAM,CACX,GAAG,EACH,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QACnB,OAAO;YACL,GAAG,GAAG;YACN,GAAG,UAAU,CAAC,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,IAAI,GAAG,EAAE,KAAK,EAAE,CAAC;SACzD,CAAA;IACH,CAAC,EACD,EAAE,CACH,CAAA;AACH,CAAC;AAQD,MAAM,UAAU,UAAU,CAAC,EAAE,GAAG,EAAE,KAAK,EAAa;IAClD,IAAI,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAA;IACrD,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACpB,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAA8B,CAAA;QAC5D,OAAO,IAAI,CAAC,MAAM,CAChB,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;YAChB,GAAG,GAAG;YACN,GAAG,UAAU,CAAC,EAAE,GAAG,EAAE,GAAG,GAAG,IAAI,MAAM,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;SAClE,CAAC,EACF,EAAE,CACH,CAAA;IACH,CAAC;IACD,OAAO,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAA;AACzB,CAAC","sourcesContent":["import { isObject, reduce, isArray } from 'lodash'\nimport { keysToSnakeCase } from './utils'\nimport { RequestData } from './types'\n\nexport const transformRequestData = ({\n fields,\n where,\n include,\n perPage = 100,\n ...restData\n}: Partial<RequestData>) => {\n return {\n ...flattenAttribute(fields, 'fields'),\n ...flattenAttribute(where, 'where'),\n ...keysToSnakeCase({ perPage, ...restData }),\n include: Array.isArray(include) ? include.join(',') : include,\n }\n}\n\nexport function flattenAttribute<\n T extends Record<string, string | number | (string | number)[] | string[]>,\n>(obj: T | undefined, key: keyof T) {\n if (!isObject(obj)) return { [key]: obj }\n\n return reduce(\n obj,\n (acc, value, attr) => {\n return {\n ...acc,\n ...buildQuery({ key: `${String(key)}[${attr}]`, value }),\n }\n },\n {}\n )\n}\n\ntype QueryArgs = {\n key: string\n value: string | number | boolean | object | any[]\n}\ntype QueryReturn = Record<string, string | number | boolean>\n\nexport function buildQuery({ key, value }: QueryArgs): QueryReturn {\n if (isArray(value)) return { [key]: value.join(',') }\n if (isObject(value)) {\n const keys = Object.keys(value) as Array<keyof typeof value>\n return keys.reduce(\n (acc, subKey) => ({\n ...acc,\n ...buildQuery({ key: `${key}[${subKey}]`, value: value[subKey] }),\n }),\n {}\n )\n }\n return { [key]: value }\n}\n"]}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { Linking } from 'react-native';
|
|
1
2
|
export class LinkingAdapter {
|
|
2
3
|
openURL;
|
|
3
4
|
canOpenURL;
|
|
4
5
|
constructor(methods) {
|
|
5
|
-
this.openURL = methods.openURL;
|
|
6
|
-
this.canOpenURL = methods.canOpenURL;
|
|
6
|
+
this.openURL = methods.openURL.bind(Linking);
|
|
7
|
+
this.canOpenURL = methods.canOpenURL.bind(Linking);
|
|
7
8
|
}
|
|
8
9
|
}
|
|
9
10
|
//# sourceMappingURL=linking.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linking.js","sourceRoot":"","sources":["../../../src/utils/native_adapters/linking.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"linking.js","sourceRoot":"","sources":["../../../src/utils/native_adapters/linking.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,MAAM,OAAO,cAAc;IACzB,OAAO,CAAoB;IAC3B,UAAU,CAAuB;IAEjC,YAAY,OAAgD;QAC1D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC5C,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACpD,CAAC;CACF","sourcesContent":["import { Linking } from 'react-native'\n\nexport class LinkingAdapter {\n openURL: Linking['openURL']\n canOpenURL: Linking['canOpenURL']\n\n constructor(methods: Pick<Linking, 'openURL' | 'canOpenURL'>) {\n this.openURL = methods.openURL.bind(Linking)\n this.canOpenURL = methods.canOpenURL.bind(Linking)\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@planningcenter/chat-react-native",
|
|
3
|
-
"version": "3.13.0-rc.
|
|
3
|
+
"version": "3.13.0-rc.8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"react-native-url-polyfill": "^2.0.0",
|
|
56
56
|
"typescript": "<5.6.0"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "bba056de785a41883df6fffcaacadc2bbe17f708"
|
|
59
59
|
}
|
|
@@ -1,21 +1,94 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { Linking as RNLinking } from 'react-native'
|
|
3
|
+
import { ChatAdapters, Linking } from '../../../utils/native_adapters/configuration'
|
|
4
|
+
import {
|
|
5
|
+
AudioAdapter,
|
|
6
|
+
Clipboard,
|
|
7
|
+
ClipboardAdapter,
|
|
8
|
+
ImagePickerAdapter,
|
|
9
|
+
LinkingAdapter,
|
|
10
|
+
VideoAdapter,
|
|
11
|
+
} from '../../../utils/native_adapters'
|
|
12
|
+
import { VideoPlayerHandle, VideoPlayerProps } from '../../../utils/native_adapters/video'
|
|
3
13
|
|
|
4
14
|
describe('ChatAdapters', () => {
|
|
5
|
-
const getStringAsync = jest.fn()
|
|
6
|
-
const setStringAsync = jest.fn()
|
|
15
|
+
const getStringAsync = jest.fn(async () => '')
|
|
16
|
+
const setStringAsync = jest.fn(async (_: string) => {})
|
|
7
17
|
const clipboard = new ClipboardAdapter({
|
|
8
18
|
getStringAsync,
|
|
9
19
|
setStringAsync,
|
|
10
20
|
})
|
|
21
|
+
const audio = new AudioAdapter({
|
|
22
|
+
useAudio: (_: string) => ({
|
|
23
|
+
play: jest.fn(),
|
|
24
|
+
pause: jest.fn(),
|
|
25
|
+
isPlaying: false,
|
|
26
|
+
duration: 0,
|
|
27
|
+
position: 0,
|
|
28
|
+
AudioPlayer: null,
|
|
29
|
+
}),
|
|
30
|
+
})
|
|
31
|
+
const Player = React.forwardRef<VideoPlayerHandle, VideoPlayerProps>((_props, _ref) => null)
|
|
32
|
+
const video = new VideoAdapter({
|
|
33
|
+
Player,
|
|
34
|
+
})
|
|
35
|
+
const imagePicker = new ImagePickerAdapter({
|
|
36
|
+
openCameraAsync: async () => ({ canceled: true, assets: null }),
|
|
37
|
+
openImageLibraryAsync: async () => ({ canceled: true, assets: null }),
|
|
38
|
+
})
|
|
11
39
|
|
|
12
40
|
it('should be defined', () => {
|
|
13
41
|
expect(ChatAdapters).toBeDefined()
|
|
14
42
|
})
|
|
15
43
|
|
|
16
44
|
it('should configure the clipboard', () => {
|
|
17
|
-
ChatAdapters.configure({
|
|
45
|
+
ChatAdapters.configure({
|
|
46
|
+
clipboard,
|
|
47
|
+
audio,
|
|
48
|
+
video,
|
|
49
|
+
imagePicker,
|
|
50
|
+
})
|
|
18
51
|
|
|
19
52
|
expect(Clipboard).toEqual(clipboard)
|
|
20
53
|
})
|
|
54
|
+
|
|
55
|
+
describe('linking adapter', () => {
|
|
56
|
+
describe('defaults', () => {
|
|
57
|
+
it('should be configured', () => {
|
|
58
|
+
ChatAdapters.configure({
|
|
59
|
+
clipboard,
|
|
60
|
+
audio,
|
|
61
|
+
video,
|
|
62
|
+
imagePicker,
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
expect(Linking).toBeDefined()
|
|
66
|
+
expect(Linking.openURL).toBeDefined()
|
|
67
|
+
expect(Linking.canOpenURL).toBeDefined()
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
describe('openUrl', () => {
|
|
71
|
+
Linking.openURL('https://www.google.com')
|
|
72
|
+
expect(RNLinking.openURL).toHaveBeenCalledWith('https://www.google.com')
|
|
73
|
+
})
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
describe('Adapter is bound to Linking context', () => {
|
|
77
|
+
const linking = new LinkingAdapter({
|
|
78
|
+
openURL: async function (url: string) {
|
|
79
|
+
expect(url).toBe('https://www.google.com')
|
|
80
|
+
expect(this).toBe(RNLinking)
|
|
81
|
+
},
|
|
82
|
+
canOpenURL: async function (url: string) {
|
|
83
|
+
expect(url).toBe('https://www.google.com')
|
|
84
|
+
expect(this).toBe(RNLinking)
|
|
85
|
+
|
|
86
|
+
return true
|
|
87
|
+
},
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
linking.openURL('https://www.google.com')
|
|
91
|
+
linking.canOpenURL('https://www.google.com')
|
|
92
|
+
})
|
|
93
|
+
})
|
|
21
94
|
})
|
|
@@ -33,22 +33,31 @@ export function ReactionsScreen({ route }: ReactionScreenProps) {
|
|
|
33
33
|
const styles = useStyles()
|
|
34
34
|
|
|
35
35
|
const { messages } = useConversationMessages({ conversation_id }, { refetchOnMount: false })
|
|
36
|
+
|
|
37
|
+
const message = messages.find(m => m.id === message_id)
|
|
38
|
+
const reactionCounts = message?.reactionCounts || []
|
|
39
|
+
const initialReactionCount =
|
|
40
|
+
reactionCounts.find(r => r.value === reaction_value) || reactionCounts[0]
|
|
41
|
+
const [reactionCountValue, setReactionCountValue] = React.useState<
|
|
42
|
+
ReactionCountResource['value']
|
|
43
|
+
>(initialReactionCount?.value)
|
|
44
|
+
const reactionCount = reactionCounts.find(r => r.value === reactionCountValue)
|
|
45
|
+
|
|
46
|
+
// Get author IDs for the API call, ensuring we have a valid array
|
|
47
|
+
const authorIds = reactionCount?.authorIds || []
|
|
48
|
+
|
|
36
49
|
const { data: members } = useSuspenseGet<MemberResource[]>({
|
|
37
50
|
url: `/me/conversations/${conversation_id}/members`,
|
|
38
51
|
data: {
|
|
39
52
|
fields: {
|
|
40
53
|
Member: ['id', 'name', 'avatar', 'badges', 'child', 'role'],
|
|
41
54
|
},
|
|
55
|
+
where: {
|
|
56
|
+
id: authorIds,
|
|
57
|
+
},
|
|
58
|
+
limit: authorIds.length,
|
|
42
59
|
},
|
|
43
60
|
})
|
|
44
|
-
const message = messages.find(m => m.id === message_id)
|
|
45
|
-
const reactionCounts = message?.reactionCounts || []
|
|
46
|
-
const initialReactionCount =
|
|
47
|
-
reactionCounts.find(r => r.value === reaction_value) || reactionCounts[0]
|
|
48
|
-
const [reactionCountValue, setReactionCountValue] = React.useState<
|
|
49
|
-
ReactionCountResource['value']
|
|
50
|
-
>(initialReactionCount.value)
|
|
51
|
-
const reactionCount = reactionCounts.find(r => r.value === reactionCountValue)
|
|
52
61
|
|
|
53
62
|
if (!reactionCount) {
|
|
54
63
|
return (
|
|
@@ -58,7 +67,6 @@ export function ReactionsScreen({ route }: ReactionScreenProps) {
|
|
|
58
67
|
)
|
|
59
68
|
}
|
|
60
69
|
|
|
61
|
-
const authorIds = reactionCount.authorIds
|
|
62
70
|
const authors = members.filter(member => authorIds.includes(member.id))
|
|
63
71
|
|
|
64
72
|
return (
|
|
@@ -17,10 +17,9 @@ export const transformRequestData = ({
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
export function flattenAttribute<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
) {
|
|
20
|
+
export function flattenAttribute<
|
|
21
|
+
T extends Record<string, string | number | (string | number)[] | string[]>,
|
|
22
|
+
>(obj: T | undefined, key: keyof T) {
|
|
24
23
|
if (!isObject(obj)) return { [key]: obj }
|
|
25
24
|
|
|
26
25
|
return reduce(
|
|
@@ -18,7 +18,7 @@ export interface GetRequest extends GenericRequest {
|
|
|
18
18
|
data: {
|
|
19
19
|
filter?: string
|
|
20
20
|
fields: Record<string, string[]>
|
|
21
|
-
where?: Record<string, string>
|
|
21
|
+
where?: Record<string, string | number | (string | number)[]>
|
|
22
22
|
include?: string[]
|
|
23
23
|
order?: string
|
|
24
24
|
perPage?: number
|
|
@@ -60,7 +60,7 @@ export interface ApiClient<T = unknown> {
|
|
|
60
60
|
|
|
61
61
|
export type RequestData = {
|
|
62
62
|
fields: Record<string, string[] | string>
|
|
63
|
-
where: Record<string, string>
|
|
63
|
+
where: Record<string, string | number | (string | number)[]>
|
|
64
64
|
include: string[]
|
|
65
65
|
data: Record<string, unknown>
|
|
66
66
|
perPage: number
|
|
@@ -5,7 +5,7 @@ export class LinkingAdapter {
|
|
|
5
5
|
canOpenURL: Linking['canOpenURL']
|
|
6
6
|
|
|
7
7
|
constructor(methods: Pick<Linking, 'openURL' | 'canOpenURL'>) {
|
|
8
|
-
this.openURL = methods.openURL
|
|
9
|
-
this.canOpenURL = methods.canOpenURL
|
|
8
|
+
this.openURL = methods.openURL.bind(Linking)
|
|
9
|
+
this.canOpenURL = methods.canOpenURL.bind(Linking)
|
|
10
10
|
}
|
|
11
11
|
}
|