@planningcenter/chat-react-native 3.7.0-rc.2 → 3.7.0-rc.3

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":"reactions_screen.d.ts","sourceRoot":"","sources":["../../src/screens/reactions_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAA;AAC7E,OAAO,KAAK,MAAM,OAAO,CAAA;AAWzB,eAAO,MAAM,sBAAsB,EAAE,4BAMpC,CAAA;AAED,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,qBAkD7D"}
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,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAA;AAC7E,OAAO,KAAK,MAAM,OAAO,CAAA;AAYzB,eAAO,MAAM,sBAAsB,EAAE,4BAMpC,CAAA;AAED,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,qBA8D7D"}
@@ -1,11 +1,12 @@
1
1
  import React from 'react';
2
- import { FlatList, StyleSheet, useWindowDimensions, View } from 'react-native';
2
+ import { StyleSheet, useWindowDimensions, View } from 'react-native';
3
3
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
4
4
  import { Avatar, Text } from '../components';
5
5
  import { REACTION_EMOJIS, useReactionStyles } from '../components/conversation/message_reaction';
6
6
  import { Tabs } from '../components/display/tabs';
7
7
  import { useSuspenseGet, useTheme } from '../hooks';
8
8
  import { useConversationMessages } from '../hooks/use_conversation_messages';
9
+ import { FlashList } from '@shopify/flash-list';
9
10
  export const ReactionsScreenOptions = {
10
11
  presentation: 'formSheet',
11
12
  headerShown: false,
@@ -28,12 +29,20 @@ export function ReactionsScreen({ route }) {
28
29
  const message = messages.find(m => m.id === message_id);
29
30
  const reactionCounts = message?.reactionCounts || [];
30
31
  const initialReactionCount = reactionCounts.find(r => r.value === reaction_value) || reactionCounts[0];
31
- const [reactionCount, setReactionCount] = React.useState(initialReactionCount);
32
+ const [reactionCountValue, setReactionCountValue] = React.useState(initialReactionCount.value);
33
+ const reactionCount = reactionCounts.find(r => r.value === reactionCountValue);
34
+ if (!reactionCount) {
35
+ return (<View style={styles.errorContainer}>
36
+ <Text>No reactions found for this message.</Text>
37
+ </View>);
38
+ }
32
39
  const authorIds = reactionCount.authorIds;
33
- const authors = members.filter(member => authorIds.includes(member.id.toString()));
40
+ const authors = members.filter(member => authorIds.includes(member.id));
34
41
  return (<View style={styles.container}>
35
- <Tabs data={reactionCounts} activeTab={reactionCount} onTabPress={setReactionCount} renderItem={({ item }) => (<Reaction active={reactionCount.id === item.id} reaction={item} onPress={() => setReactionCount(item)}/>)} style={styles.actions}/>
36
- <FlatList data={authors} keyExtractor={item => item.id.toString()} renderItem={({ item: author }) => (<View style={styles.authorList}>
42
+ <Tabs data={reactionCounts} activeTab={reactionCount} onTabPress={item => {
43
+ setReactionCountValue(item.value);
44
+ }} renderItem={({ item }) => (<Reaction active={reactionCount.id === item.id} reaction={item} onPress={() => setReactionCountValue(item.value)}/>)} style={styles.actions}/>
45
+ <FlashList data={authors} keyExtractor={item => item.id.toString()} renderItem={({ item: author }) => (<View style={styles.authorList}>
37
46
  <Avatar size={'md'} sourceUri={author.avatar}/>
38
47
  <Text key={author.id}>{author.name}</Text>
39
48
  </View>)}/>
@@ -79,6 +88,13 @@ const useStyles = () => {
79
88
  borderBottomColor: theme.colors.fillColorNeutral040,
80
89
  borderBottomWidth: 1,
81
90
  },
91
+ errorContainer: {
92
+ flex: 1,
93
+ justifyContent: 'center',
94
+ alignItems: 'center',
95
+ padding: 16,
96
+ marginTop: 30,
97
+ },
82
98
  });
83
99
  };
84
100
  //# sourceMappingURL=reactions_screen.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"reactions_screen.js","sourceRoot":"","sources":["../../src/screens/reactions_screen.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,mBAAmB,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAClE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAA;AAChG,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAA;AACjD,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAA;AAI5E,MAAM,CAAC,MAAM,sBAAsB,GAAiC;IAClE,YAAY,EAAE,WAAW;IACzB,WAAW,EAAE,KAAK;IAClB,mBAAmB,EAAE,CAAC,GAAG,CAAC;IAC1B,mBAAmB,EAAE,IAAI;IACzB,iBAAiB,EAAE,EAAE;CACtB,CAAA;AAQD,MAAM,UAAU,eAAe,CAAC,EAAE,KAAK,EAAuB;IAC5D,MAAM,EAAE,eAAe,EAAE,UAAU,EAAE,cAAc,EAAE,G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AC,MAAM,CAAC,mBAAmB;YACnD,iBAAiB,EAAE,CAAC;SACrB;KACF,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { StaticScreenProps } from '@react-navigation/native'\nimport { NativeStackNavigationOptions } from '@react-navigation/native-stack'\nimport React from 'react'\nimport { FlatList, StyleSheet, useWindowDimensions, View } from 'react-native'\nimport { useSafeAreaInsets } from 'react-native-safe-area-context'\nimport { Avatar, Text } from '../components'\nimport { REACTION_EMOJIS, useReactionStyles } from '../components/conversation/message_reaction'\nimport { Tabs } from '../components/display/tabs'\nimport { useSuspenseGet, useTheme } from '../hooks'\nimport { useConversationMessages } from '../hooks/use_conversation_messages'\nimport { MemberResource } from '../types'\nimport { ReactionCountResource } from '../types/resources/reaction'\n\nexport const ReactionsScreenOptions: NativeStackNavigationOptions = {\n presentation: 'formSheet',\n headerShown: false,\n sheetAllowedDetents: [0.5],\n sheetGrabberVisible: true,\n sheetCornerRadius: 16,\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 [reactionCount, setReactionCount] =\n React.useState<ReactionCountResource>(initialReactionCount)\n\n const authorIds = reactionCount.authorIds\n const authors = members.filter(member => authorIds.includes(member.id.toString()))\n\n return (\n <View style={styles.container}>\n <Tabs\n data={reactionCounts}\n activeTab={reactionCount}\n onTabPress={setReactionCount}\n renderItem={({ item }) => (\n <Reaction\n active={reactionCount.id === item.id}\n reaction={item}\n onPress={() => setReactionCount(item)}\n />\n )}\n style={styles.actions}\n />\n <FlatList\n data={authors}\n keyExtractor={item => item.id.toString()}\n renderItem={({ item: author }) => (\n <View style={styles.authorList}>\n <Avatar size={'md'} sourceUri={author.avatar} />\n <Text key={author.id}>{author.name}</Text>\n </View>\n )}\n />\n </View>\n )\n}\n\nconst Reaction = ({\n reaction,\n}: {\n active: boolean\n reaction: ReactionCountResource\n onPress: () => void\n}) => {\n const styles = useStyles()\n const reactionStyles = useReactionStyles({ mine: reaction.mine ? 1 : 0 })\n\n return (\n <View key={reaction.value} style={styles.reaction}>\n <Text style={reactionStyles.reactionEmoji}>{REACTION_EMOJIS[reaction.value]}</Text>\n <Text style={reactionStyles.reactionEmoji}>{reaction.count}</Text>\n </View>\n )\n}\n\nconst useStyles = () => {\n const theme = useTheme()\n const { height } = useWindowDimensions()\n const { bottom } = useSafeAreaInsets()\n\n return StyleSheet.create({\n container: {\n justifyContent: 'flex-start',\n paddingTop: 12,\n paddingBottom: bottom,\n width: '100%',\n backgroundColor: theme.colors.fillColorNeutral100Inverted,\n height,\n gap: 8,\n },\n authorList: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 8,\n paddingHorizontal: 12,\n paddingVertical: 12,\n },\n reaction: {\n paddingVertical: 12,\n paddingHorizontal: 12,\n flexDirection: 'row',\n gap: 4,\n },\n actions: {\n minHeight: 48,\n borderBottomColor: theme.colors.fillColorNeutral040,\n borderBottomWidth: 1,\n },\n })\n}\n"]}
1
+ {"version":3,"file":"reactions_screen.js","sourceRoot":"","sources":["../../src/screens/reactions_screen.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAClE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MA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,CAAA","sourcesContent":["import { StaticScreenProps } from '@react-navigation/native'\nimport { NativeStackNavigationOptions } from '@react-navigation/native-stack'\nimport React from 'react'\nimport { StyleSheet, useWindowDimensions, View } from 'react-native'\nimport { useSafeAreaInsets } from 'react-native-safe-area-context'\nimport { Avatar, Text } from '../components'\nimport { REACTION_EMOJIS, useReactionStyles } from '../components/conversation/message_reaction'\nimport { Tabs } from '../components/display/tabs'\nimport { useSuspenseGet, useTheme } from '../hooks'\nimport { useConversationMessages } from '../hooks/use_conversation_messages'\nimport { MemberResource } from '../types'\nimport { ReactionCountResource } from '../types/resources/reaction'\nimport { FlashList } from '@shopify/flash-list'\n\nexport const ReactionsScreenOptions: NativeStackNavigationOptions = {\n presentation: 'formSheet',\n headerShown: false,\n sheetAllowedDetents: [0.5],\n sheetGrabberVisible: true,\n sheetCornerRadius: 16,\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 <View style={styles.container}>\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 <FlashList\n data={authors}\n keyExtractor={item => item.id.toString()}\n renderItem={({ item: author }) => (\n <View style={styles.authorList}>\n <Avatar size={'md'} sourceUri={author.avatar} />\n <Text key={author.id}>{author.name}</Text>\n </View>\n )}\n />\n </View>\n )\n}\n\nconst Reaction = ({\n reaction,\n}: {\n active: boolean\n reaction: ReactionCountResource\n onPress: () => void\n}) => {\n const styles = useStyles()\n const reactionStyles = useReactionStyles({ mine: reaction.mine ? 1 : 0 })\n\n return (\n <View key={reaction.value} style={styles.reaction}>\n <Text style={reactionStyles.reactionEmoji}>{REACTION_EMOJIS[reaction.value]}</Text>\n <Text style={reactionStyles.reactionEmoji}>{reaction.count}</Text>\n </View>\n )\n}\n\nconst useStyles = () => {\n const theme = useTheme()\n const { height } = useWindowDimensions()\n const { bottom } = useSafeAreaInsets()\n\n return StyleSheet.create({\n container: {\n justifyContent: 'flex-start',\n paddingTop: 12,\n paddingBottom: bottom,\n width: '100%',\n backgroundColor: theme.colors.fillColorNeutral100Inverted,\n height,\n gap: 8,\n },\n authorList: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 8,\n paddingHorizontal: 12,\n paddingVertical: 12,\n },\n reaction: {\n paddingVertical: 12,\n paddingHorizontal: 12,\n flexDirection: 'row',\n gap: 4,\n },\n actions: {\n minHeight: 48,\n borderBottomColor: theme.colors.fillColorNeutral040,\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"]}
@@ -5,6 +5,6 @@ export interface ReactionCountResource {
5
5
  count: number;
6
6
  mine: number;
7
7
  messageId: string;
8
- authorIds: string[];
8
+ authorIds: number[];
9
9
  }
10
10
  //# sourceMappingURL=reaction.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reaction.js","sourceRoot":"","sources":["../../../src/types/resources/reaction.ts"],"names":[],"mappings":"","sourcesContent":["export interface ReactionCountResource {\n type: 'ReactionCount'\n id: string\n value: 'thumbs_up' | 'thumbs_down' | 'pray' | 'laugh' | 'heart'\n count: number\n mine: number\n messageId: string\n authorIds: string[] // These is in fact a string array\n}\n"]}
1
+ {"version":3,"file":"reaction.js","sourceRoot":"","sources":["../../../src/types/resources/reaction.ts"],"names":[],"mappings":"","sourcesContent":["export interface ReactionCountResource {\n type: 'ReactionCount'\n id: string\n value: 'thumbs_up' | 'thumbs_down' | 'pray' | 'laugh' | 'heart'\n count: number\n mine: number\n messageId: string\n authorIds: number[]\n}\n"]}
@@ -1,12 +1,12 @@
1
1
  export function transformReactionEventDataToReactionCountResource({ data, oldData, event, currentPersonId, }) {
2
2
  let authorIds = new Set(oldData?.authorIds || []);
3
3
  if (event === 'reaction.created') {
4
- authorIds.add(data.author_id.toString());
4
+ authorIds.add(data.author_id);
5
5
  }
6
6
  else if (event === 'reaction.destroyed') {
7
- authorIds.delete(data.author_id.toString());
7
+ authorIds.delete(data.author_id);
8
8
  }
9
- const mine = authorIds.has(currentPersonId.toString());
9
+ const mine = authorIds.has(currentPersonId);
10
10
  return {
11
11
  type: 'ReactionCount',
12
12
  id: `${data.message_sort_key}/${data.value}`,
@@ -1 +1 @@
1
- {"version":3,"file":"transform_reaction_event_data_to_reaction_count_resource.js","sourceRoot":"","sources":["../../../src/utils/jolt/transform_reaction_event_data_to_reaction_count_resource.ts"],"names":[],"mappings":"AAWA,MAAM,UAAU,iDAAiD,CAAC,EAChE,IAAI,EACJ,OAAO,EACP,KAAK,EACL,eAAe,GACT;IACN,IAAI,SAAS,GAAG,IAAI,GAAG,CAAC,OAAO,EAAE,SAAS,IAAI,EAAE,CAAC,CAAA;IACjD,IAAI,KAAK,KAAK,kBAAkB,EAAE,CAAC;QACjC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAA;IAC1C,CAAC;SAAM,IAAI,KAAK,KAAK,oBAAoB,EAAE,CAAC;QAC1C,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAA;IAC7C,CAAC;IAED,MAAM,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC,CAAA;IAEtD,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,EAAE,EAAE,GAAG,IAAI,CAAC,gBAAgB,IAAI,IAAI,CAAC,KAAK,EAAE;QAC5C,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAClB,SAAS,EAAE,IAAI,CAAC,gBAAgB;QAChC,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC;KACjC,CAAA;AACH,CAAC","sourcesContent":["import { JoltReactionEvent } from '../../types/jolt_events'\nimport { ReactionCreatedEvent } from '../../types/jolt_events/reaction_events'\nimport { ReactionCountResource } from '../../types/resources/reaction'\n\ninterface Props {\n data: ReactionCreatedEvent['data']['data']\n oldData?: ReactionCountResource\n event: JoltReactionEvent['event']\n currentPersonId: number\n}\n\nexport function transformReactionEventDataToReactionCountResource({\n data,\n oldData,\n event,\n currentPersonId,\n}: Props): ReactionCountResource {\n let authorIds = new Set(oldData?.authorIds || [])\n if (event === 'reaction.created') {\n authorIds.add(data.author_id.toString())\n } else if (event === 'reaction.destroyed') {\n authorIds.delete(data.author_id.toString())\n }\n\n const mine = authorIds.has(currentPersonId.toString())\n\n return {\n type: 'ReactionCount',\n id: `${data.message_sort_key}/${data.value}`,\n value: data.value,\n count: data.count,\n mine: mine ? 1 : 0,\n messageId: data.message_sort_key,\n authorIds: Array.from(authorIds),\n }\n}\n"]}
1
+ {"version":3,"file":"transform_reaction_event_data_to_reaction_count_resource.js","sourceRoot":"","sources":["../../../src/utils/jolt/transform_reaction_event_data_to_reaction_count_resource.ts"],"names":[],"mappings":"AAWA,MAAM,UAAU,iDAAiD,CAAC,EAChE,IAAI,EACJ,OAAO,EACP,KAAK,EACL,eAAe,GACT;IACN,IAAI,SAAS,GAAG,IAAI,GAAG,CAAC,OAAO,EAAE,SAAS,IAAI,EAAE,CAAC,CAAA;IACjD,IAAI,KAAK,KAAK,kBAAkB,EAAE,CAAC;QACjC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IAC/B,CAAC;SAAM,IAAI,KAAK,KAAK,oBAAoB,EAAE,CAAC;QAC1C,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IAClC,CAAC;IAED,MAAM,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;IAE3C,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,EAAE,EAAE,GAAG,IAAI,CAAC,gBAAgB,IAAI,IAAI,CAAC,KAAK,EAAE;QAC5C,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAClB,SAAS,EAAE,IAAI,CAAC,gBAAgB;QAChC,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC;KACjC,CAAA;AACH,CAAC","sourcesContent":["import { JoltReactionEvent } from '../../types/jolt_events'\nimport { ReactionCreatedEvent } from '../../types/jolt_events/reaction_events'\nimport { ReactionCountResource } from '../../types/resources/reaction'\n\ninterface Props {\n data: ReactionCreatedEvent['data']['data']\n oldData?: ReactionCountResource\n event: JoltReactionEvent['event']\n currentPersonId: number\n}\n\nexport function transformReactionEventDataToReactionCountResource({\n data,\n oldData,\n event,\n currentPersonId,\n}: Props): ReactionCountResource {\n let authorIds = new Set(oldData?.authorIds || [])\n if (event === 'reaction.created') {\n authorIds.add(data.author_id)\n } else if (event === 'reaction.destroyed') {\n authorIds.delete(data.author_id)\n }\n\n const mine = authorIds.has(currentPersonId)\n\n return {\n type: 'ReactionCount',\n id: `${data.message_sort_key}/${data.value}`,\n value: data.value,\n count: data.count,\n mine: mine ? 1 : 0,\n messageId: data.message_sort_key,\n authorIds: Array.from(authorIds),\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planningcenter/chat-react-native",
3
- "version": "3.7.0-rc.2",
3
+ "version": "3.7.0-rc.3",
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": "3b71fbd4d157d71bc2f29676b6f2c3b3d274afff"
58
+ "gitHead": "259b99ec6d74ec0eacac7448f9d5f56de42a4921"
59
59
  }
@@ -1,7 +1,7 @@
1
1
  import { StaticScreenProps } from '@react-navigation/native'
2
2
  import { NativeStackNavigationOptions } from '@react-navigation/native-stack'
3
3
  import React from 'react'
4
- import { FlatList, StyleSheet, useWindowDimensions, View } from 'react-native'
4
+ import { StyleSheet, useWindowDimensions, View } from 'react-native'
5
5
  import { useSafeAreaInsets } from 'react-native-safe-area-context'
6
6
  import { Avatar, Text } from '../components'
7
7
  import { REACTION_EMOJIS, useReactionStyles } from '../components/conversation/message_reaction'
@@ -10,6 +10,7 @@ import { useSuspenseGet, useTheme } from '../hooks'
10
10
  import { useConversationMessages } from '../hooks/use_conversation_messages'
11
11
  import { MemberResource } from '../types'
12
12
  import { ReactionCountResource } from '../types/resources/reaction'
13
+ import { FlashList } from '@shopify/flash-list'
13
14
 
14
15
  export const ReactionsScreenOptions: NativeStackNavigationOptions = {
15
16
  presentation: 'formSheet',
@@ -42,28 +43,40 @@ export function ReactionsScreen({ route }: ReactionScreenProps) {
42
43
  const reactionCounts = message?.reactionCounts || []
43
44
  const initialReactionCount =
44
45
  reactionCounts.find(r => r.value === reaction_value) || reactionCounts[0]
45
- const [reactionCount, setReactionCount] =
46
- React.useState<ReactionCountResource>(initialReactionCount)
46
+ const [reactionCountValue, setReactionCountValue] = React.useState<
47
+ ReactionCountResource['value']
48
+ >(initialReactionCount.value)
49
+ const reactionCount = reactionCounts.find(r => r.value === reactionCountValue)
50
+
51
+ if (!reactionCount) {
52
+ return (
53
+ <View style={styles.errorContainer}>
54
+ <Text>No reactions found for this message.</Text>
55
+ </View>
56
+ )
57
+ }
47
58
 
48
59
  const authorIds = reactionCount.authorIds
49
- const authors = members.filter(member => authorIds.includes(member.id.toString()))
60
+ const authors = members.filter(member => authorIds.includes(member.id))
50
61
 
51
62
  return (
52
63
  <View style={styles.container}>
53
64
  <Tabs
54
65
  data={reactionCounts}
55
66
  activeTab={reactionCount}
56
- onTabPress={setReactionCount}
67
+ onTabPress={item => {
68
+ setReactionCountValue(item.value)
69
+ }}
57
70
  renderItem={({ item }) => (
58
71
  <Reaction
59
72
  active={reactionCount.id === item.id}
60
73
  reaction={item}
61
- onPress={() => setReactionCount(item)}
74
+ onPress={() => setReactionCountValue(item.value)}
62
75
  />
63
76
  )}
64
77
  style={styles.actions}
65
78
  />
66
- <FlatList
79
+ <FlashList
67
80
  data={authors}
68
81
  keyExtractor={item => item.id.toString()}
69
82
  renderItem={({ item: author }) => (
@@ -128,5 +141,12 @@ const useStyles = () => {
128
141
  borderBottomColor: theme.colors.fillColorNeutral040,
129
142
  borderBottomWidth: 1,
130
143
  },
144
+ errorContainer: {
145
+ flex: 1,
146
+ justifyContent: 'center',
147
+ alignItems: 'center',
148
+ padding: 16,
149
+ marginTop: 30,
150
+ },
131
151
  })
132
152
  }
@@ -5,5 +5,5 @@ export interface ReactionCountResource {
5
5
  count: number
6
6
  mine: number
7
7
  messageId: string
8
- authorIds: string[] // These is in fact a string array
8
+ authorIds: number[]
9
9
  }
@@ -17,12 +17,12 @@ export function transformReactionEventDataToReactionCountResource({
17
17
  }: Props): ReactionCountResource {
18
18
  let authorIds = new Set(oldData?.authorIds || [])
19
19
  if (event === 'reaction.created') {
20
- authorIds.add(data.author_id.toString())
20
+ authorIds.add(data.author_id)
21
21
  } else if (event === 'reaction.destroyed') {
22
- authorIds.delete(data.author_id.toString())
22
+ authorIds.delete(data.author_id)
23
23
  }
24
24
 
25
- const mine = authorIds.has(currentPersonId.toString())
25
+ const mine = authorIds.has(currentPersonId)
26
26
 
27
27
  return {
28
28
  type: 'ReactionCount',