@planningcenter/chat-react-native 2.0.1-rc.0 → 2.1.0-rc.0

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.
Files changed (115) hide show
  1. package/build/components/conversation/message.d.ts.map +1 -1
  2. package/build/components/conversation/message.js +7 -2
  3. package/build/components/conversation/message.js.map +1 -1
  4. package/build/components/conversation/message_reaction.d.ts +1 -1
  5. package/build/components/conversation/message_reaction.d.ts.map +1 -1
  6. package/build/components/conversation/message_reaction.js +1 -1
  7. package/build/components/conversation/message_reaction.js.map +1 -1
  8. package/build/components/conversations.d.ts.map +1 -1
  9. package/build/components/conversations.js +76 -30
  10. package/build/components/conversations.js.map +1 -1
  11. package/build/components/display/badge.d.ts +2 -6
  12. package/build/components/display/badge.d.ts.map +1 -1
  13. package/build/components/display/badge.js +1 -5
  14. package/build/components/display/badge.js.map +1 -1
  15. package/build/components/display/tabs.d.ts +17 -0
  16. package/build/components/display/tabs.d.ts.map +1 -0
  17. package/build/components/display/tabs.js +97 -0
  18. package/build/components/display/tabs.js.map +1 -0
  19. package/build/contexts/api_provider.js +2 -2
  20. package/build/contexts/api_provider.js.map +1 -1
  21. package/build/hooks/use_conversation_jolt_events.d.ts +2 -0
  22. package/build/hooks/use_conversation_jolt_events.d.ts.map +1 -0
  23. package/build/hooks/use_conversation_jolt_events.js +47 -0
  24. package/build/hooks/use_conversation_jolt_events.js.map +1 -0
  25. package/build/hooks/use_conversation_messages.d.ts +2 -18
  26. package/build/hooks/use_conversation_messages.d.ts.map +1 -1
  27. package/build/hooks/use_conversation_messages.js +2 -2
  28. package/build/hooks/use_conversation_messages.js.map +1 -1
  29. package/build/hooks/use_conversations.d.ts +37 -0
  30. package/build/hooks/use_conversations.d.ts.map +1 -0
  31. package/build/hooks/use_conversations.js +48 -0
  32. package/build/hooks/use_conversations.js.map +1 -0
  33. package/build/hooks/use_jolt.d.ts +9 -0
  34. package/build/hooks/use_jolt.d.ts.map +1 -0
  35. package/build/hooks/use_jolt.js +71 -0
  36. package/build/hooks/use_jolt.js.map +1 -0
  37. package/build/hooks/use_suspense_api.d.ts +7 -2
  38. package/build/hooks/use_suspense_api.d.ts.map +1 -1
  39. package/build/hooks/use_suspense_api.js +7 -2
  40. package/build/hooks/use_suspense_api.js.map +1 -1
  41. package/build/navigation/index.d.ts +5 -0
  42. package/build/navigation/index.d.ts.map +1 -1
  43. package/build/navigation/index.js +7 -2
  44. package/build/navigation/index.js.map +1 -1
  45. package/build/screens/message_actions_screen.d.ts +1 -1
  46. package/build/screens/message_actions_screen.d.ts.map +1 -1
  47. package/build/screens/message_actions_screen.js +1 -1
  48. package/build/screens/message_actions_screen.js.map +1 -1
  49. package/build/screens/reactions_screen.d.ts +11 -0
  50. package/build/screens/reactions_screen.d.ts.map +1 -0
  51. package/build/screens/reactions_screen.js +83 -0
  52. package/build/screens/reactions_screen.js.map +1 -0
  53. package/build/types/resources/app_name.d.ts +2 -0
  54. package/build/types/resources/app_name.d.ts.map +1 -0
  55. package/build/types/resources/app_name.js +2 -0
  56. package/build/types/resources/app_name.js.map +1 -0
  57. package/build/types/resources/conversation.d.ts +18 -10
  58. package/build/types/resources/conversation.d.ts.map +1 -1
  59. package/build/types/resources/conversation.js.map +1 -1
  60. package/build/types/resources/conversation_badge.d.ts +12 -0
  61. package/build/types/resources/conversation_badge.d.ts.map +1 -0
  62. package/build/types/resources/conversation_badge.js +2 -0
  63. package/build/types/resources/conversation_badge.js.map +1 -0
  64. package/build/types/resources/group_resource.d.ts +12 -0
  65. package/build/types/resources/group_resource.d.ts.map +1 -0
  66. package/build/types/resources/group_resource.js +2 -0
  67. package/build/types/resources/group_resource.js.map +1 -0
  68. package/build/types/resources/index.d.ts +2 -1
  69. package/build/types/resources/index.d.ts.map +1 -1
  70. package/build/types/resources/index.js +2 -1
  71. package/build/types/resources/index.js.map +1 -1
  72. package/build/types/resources/member.d.ts +23 -0
  73. package/build/types/resources/member.d.ts.map +1 -0
  74. package/build/types/resources/member.js +2 -0
  75. package/build/types/resources/member.js.map +1 -0
  76. package/build/types/resources/member_ability.d.ts +6 -0
  77. package/build/types/resources/member_ability.d.ts.map +1 -0
  78. package/build/types/resources/member_ability.js +2 -0
  79. package/build/types/resources/member_ability.js.map +1 -0
  80. package/build/types/resources/reaction.d.ts +1 -1
  81. package/build/types/resources/reaction.js.map +1 -1
  82. package/build/utils/cache/page_mutations.d.ts +19 -2
  83. package/build/utils/cache/page_mutations.d.ts.map +1 -1
  84. package/build/utils/cache/page_mutations.js +21 -7
  85. package/build/utils/cache/page_mutations.js.map +1 -1
  86. package/build/utils/date.d.ts +4 -0
  87. package/build/utils/date.d.ts.map +1 -0
  88. package/build/utils/date.js +23 -0
  89. package/build/utils/date.js.map +1 -0
  90. package/package.json +7 -3
  91. package/src/__tests__/utils/cache/page_mutations.ts +7 -46
  92. package/src/components/conversation/message.tsx +8 -3
  93. package/src/components/conversation/message_reaction.tsx +6 -2
  94. package/src/components/conversations.tsx +95 -32
  95. package/src/components/display/badge.tsx +3 -8
  96. package/src/components/display/tabs.tsx +142 -0
  97. package/src/contexts/api_provider.tsx +3 -3
  98. package/src/hooks/use_conversation_jolt_events.ts +67 -0
  99. package/src/hooks/use_conversation_messages.ts +6 -2
  100. package/src/hooks/use_conversations.ts +53 -0
  101. package/src/hooks/use_jolt.ts +101 -0
  102. package/src/hooks/use_suspense_api.ts +10 -3
  103. package/src/navigation/index.tsx +10 -2
  104. package/src/screens/message_actions_screen.tsx +1 -1
  105. package/src/screens/reactions_screen.tsx +131 -0
  106. package/src/types/resources/app_name.ts +1 -0
  107. package/src/types/resources/conversation.ts +18 -10
  108. package/src/types/resources/conversation_badge.ts +10 -0
  109. package/src/types/resources/group_resource.ts +10 -0
  110. package/src/types/resources/index.ts +2 -1
  111. package/src/types/resources/member.ts +24 -0
  112. package/src/types/resources/member_ability.ts +5 -0
  113. package/src/types/resources/reaction.ts +1 -1
  114. package/src/utils/cache/page_mutations.ts +32 -9
  115. package/src/utils/date.ts +25 -0
@@ -0,0 +1,83 @@
1
+ import React from 'react';
2
+ import { FlatList, StyleSheet, useWindowDimensions, View } from 'react-native';
3
+ import { useSafeAreaInsets } from 'react-native-safe-area-context';
4
+ import { Avatar, Text } from '../components';
5
+ import { REACTION_EMOJIS, useReactionStyles } from '../components/conversation/message_reaction';
6
+ import { Tabs } from '../components/display/tabs';
7
+ import { useSuspenseGet, useTheme } from '../hooks';
8
+ import { useConversationMessages } from '../hooks/use_conversation_messages';
9
+ export const ReactionsScreenOptions = {
10
+ presentation: 'formSheet',
11
+ headerShown: false,
12
+ sheetAllowedDetents: [0.5],
13
+ sheetGrabberVisible: true,
14
+ };
15
+ export function ReactionsScreen({ route }) {
16
+ const { conversation_id, message_id, reaction_value } = route.params;
17
+ const styles = useStyles();
18
+ const { messages } = useConversationMessages({ conversation_id }, { refetchOnMount: false });
19
+ const { data: members } = useSuspenseGet({
20
+ url: `/me/conversations/${conversation_id}/members`,
21
+ data: {
22
+ fields: {
23
+ Member: ['id', 'name', 'avatar', 'badges', 'child', 'role'],
24
+ },
25
+ },
26
+ });
27
+ const message = messages.find(m => m.id === message_id);
28
+ const reactionCounts = message?.reactionCounts || [];
29
+ const initialReactionCount = reactionCounts.find(r => r.value === reaction_value) || reactionCounts[0];
30
+ const [reactionCount, setReactionCount] = React.useState(initialReactionCount);
31
+ const authorIds = reactionCount.authorIds;
32
+ const authors = members.filter(member => authorIds.includes(member.id));
33
+ return (<View style={styles.container}>
34
+ <Tabs data={reactionCounts} activeTab={reactionCount} onTabPress={setReactionCount} renderItem={({ item }) => (<Reaction active={reactionCount.id === item.id} reaction={item} onPress={() => setReactionCount(item)}/>)} style={styles.actions}/>
35
+ <FlatList data={authors} keyExtractor={item => item.id} renderItem={({ item: author }) => (<View style={styles.authorList}>
36
+ <Avatar size={'md'} sourceUri={author.avatar}/>
37
+ <Text key={author.id}>{author.name}</Text>
38
+ </View>)}/>
39
+ </View>);
40
+ }
41
+ const Reaction = ({ reaction, }) => {
42
+ const styles = useStyles();
43
+ const reactionStyles = useReactionStyles({ mine: reaction.mine ? 1 : 0 });
44
+ return (<View key={reaction.value} style={styles.reaction}>
45
+ <Text style={reactionStyles.reactionEmoji}>{REACTION_EMOJIS[reaction.value]}</Text>
46
+ <Text style={reactionStyles.reactionEmoji}>{reaction.count}</Text>
47
+ </View>);
48
+ };
49
+ const useStyles = () => {
50
+ const theme = useTheme();
51
+ const { height } = useWindowDimensions();
52
+ const { bottom } = useSafeAreaInsets();
53
+ return StyleSheet.create({
54
+ container: {
55
+ justifyContent: 'flex-start',
56
+ paddingTop: 12,
57
+ paddingBottom: bottom,
58
+ width: '100%',
59
+ backgroundColor: theme.colors.fillColorNeutral100Inverted,
60
+ height,
61
+ gap: 8,
62
+ },
63
+ authorList: {
64
+ flexDirection: 'row',
65
+ alignItems: 'center',
66
+ gap: 8,
67
+ paddingHorizontal: 12,
68
+ paddingVertical: 12,
69
+ },
70
+ reaction: {
71
+ paddingVertical: 12,
72
+ paddingHorizontal: 12,
73
+ flexDirection: 'row',
74
+ gap: 4,
75
+ },
76
+ actions: {
77
+ minHeight: 48,
78
+ borderBottomColor: theme.colors.fillColorNeutral040,
79
+ borderBottomWidth: 1,
80
+ },
81
+ });
82
+ };
83
+ //# sourceMappingURL=reactions_screen.js.map
@@ -0,0 +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,M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YACzD,MAAM;YACN,GAAG,EAAE,CAAC;SACP;QACD,UAAU,EAAE;YACV,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,QAAQ;YACpB,GAAG,EAAE,CAAC;YACN,iBAAiB,EAAE,EAAE;YACrB,eAAe,EAAE,EAAE;SACpB;QACD,QAAQ,EAAE;YACR,eAAe,EAAE,EAAE;YACnB,iBAAiB,EAAE,EAAE;YACrB,aAAa,EAAE,KAAK;YACpB,GAAG,EAAE,CAAC;SACP;QACD,OAAO,EAAE;YACP,SAAS,EAAE,EAAE;YACb,iBAAiB,EAAE,KAAK,CAAC,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}\n\nexport type ReactionScreenProps = StaticScreenProps<{\n message_id: string\n conversation_id: string\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))\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}\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"]}
@@ -0,0 +1,2 @@
1
+ export type AppName = 'Services' | 'Groups';
2
+ //# sourceMappingURL=app_name.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app_name.d.ts","sourceRoot":"","sources":["../../../src/types/resources/app_name.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG,UAAU,GAAG,QAAQ,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=app_name.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app_name.js","sourceRoot":"","sources":["../../../src/types/resources/app_name.ts"],"names":[],"mappings":"","sourcesContent":["export type AppName = 'Services' | 'Groups'\n"]}
@@ -1,15 +1,23 @@
1
- import type { ResourceObject } from '../api_primitives';
2
- export interface ConversationResource extends ResourceObject {
3
- title: string;
4
- subtitle: string;
1
+ import { ConversationBadgeResource } from './conversation_badge';
2
+ import { GroupResource } from './group_resource';
3
+ import { MemberAbilityResource } from './member_ability';
4
+ export interface ConversationResource {
5
+ type: 'Conversation';
6
+ id: string;
7
+ badges?: ConversationBadgeResource[];
5
8
  createdAt: string;
6
- updatedAt: string;
9
+ deleted?: boolean;
10
+ groups?: GroupResource[];
11
+ previewAvatarUrls?: string[];
12
+ lastMessageAuthorId?: string;
13
+ lastMessageAuthorName?: string;
14
+ lastMessageCreatedAt?: string;
15
+ lastMessageTextPreview?: string;
16
+ memberAbility?: MemberAbilityResource;
17
+ muted: boolean;
7
18
  repliesDisabled: boolean;
8
- lastMessageAuthorId: string;
9
- lastMessageAuthorName: string;
10
- lastMessageCreatedAt: string;
11
- lastMessageTextPreview: string;
19
+ title: string;
12
20
  unreadCount: number;
13
- muted: boolean;
21
+ updatedAt: string;
14
22
  }
15
23
  //# sourceMappingURL=conversation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../src/types/resources/conversation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAEvD,MAAM,WAAW,oBAAqB,SAAQ,cAAc;IAC1D,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,eAAe,EAAE,OAAO,CAAA;IACxB,mBAAmB,EAAE,MAAM,CAAA;IAC3B,qBAAqB,EAAE,MAAM,CAAA;IAC7B,oBAAoB,EAAE,MAAM,CAAA;IAC5B,sBAAsB,EAAE,MAAM,CAAA;IAC9B,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,OAAO,CAAA;CACf"}
1
+ {"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../src/types/resources/conversation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AAExD,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,cAAc,CAAA;IACpB,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,CAAC,EAAE,yBAAyB,EAAE,CAAA;IACpC,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,MAAM,CAAC,EAAE,aAAa,EAAE,CAAA;IACxB,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC5B,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,sBAAsB,CAAC,EAAE,MAAM,CAAA;IAC/B,aAAa,CAAC,EAAE,qBAAqB,CAAA;IACrC,KAAK,EAAE,OAAO,CAAA;IACd,eAAe,EAAE,OAAO,CAAA;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;CAClB"}
@@ -1 +1 @@
1
- {"version":3,"file":"conversation.js","sourceRoot":"","sources":["../../../src/types/resources/conversation.ts"],"names":[],"mappings":"","sourcesContent":["import type { ResourceObject } from '../api_primitives'\n\nexport interface ConversationResource extends ResourceObject {\n title: string\n subtitle: string\n createdAt: string\n updatedAt: string\n repliesDisabled: boolean\n lastMessageAuthorId: string\n lastMessageAuthorName: string\n lastMessageCreatedAt: string\n lastMessageTextPreview: string\n unreadCount: number\n muted: boolean\n}\n"]}
1
+ {"version":3,"file":"conversation.js","sourceRoot":"","sources":["../../../src/types/resources/conversation.ts"],"names":[],"mappings":"","sourcesContent":["import { ConversationBadgeResource } from './conversation_badge'\nimport { GroupResource } from './group_resource'\nimport { MemberAbilityResource } from './member_ability'\n\nexport interface ConversationResource {\n type: 'Conversation'\n id: string\n badges?: ConversationBadgeResource[]\n createdAt: string\n deleted?: boolean\n groups?: GroupResource[]\n previewAvatarUrls?: string[]\n lastMessageAuthorId?: string\n lastMessageAuthorName?: string\n lastMessageCreatedAt?: string\n lastMessageTextPreview?: string\n memberAbility?: MemberAbilityResource\n muted: boolean\n repliesDisabled: boolean\n title: string\n unreadCount: number\n updatedAt: string\n}\n"]}
@@ -0,0 +1,12 @@
1
+ import { AppName } from './app_name';
2
+ export interface ConversationBadgeResource {
3
+ type: 'ConversationBadge';
4
+ id: string;
5
+ links: {
6
+ self: string;
7
+ };
8
+ text: string | null;
9
+ appName: AppName;
10
+ pcoResourceType: string;
11
+ }
12
+ //# sourceMappingURL=conversation_badge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversation_badge.d.ts","sourceRoot":"","sources":["../../../src/types/resources/conversation_badge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEpC,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,mBAAmB,CAAA;IACzB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;IACvB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,OAAO,EAAE,OAAO,CAAA;IAChB,eAAe,EAAE,MAAM,CAAA;CACxB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=conversation_badge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversation_badge.js","sourceRoot":"","sources":["../../../src/types/resources/conversation_badge.ts"],"names":[],"mappings":"","sourcesContent":["import { AppName } from './app_name'\n\nexport interface ConversationBadgeResource {\n type: 'ConversationBadge'\n id: string\n links: { self: string }\n text: string | null\n appName: AppName\n pcoResourceType: string\n}\n"]}
@@ -0,0 +1,12 @@
1
+ import { AppName } from './app_name';
2
+ export interface GroupResource {
3
+ type: 'Group';
4
+ id: string;
5
+ links: {
6
+ self: string;
7
+ };
8
+ name: string | null;
9
+ sourceAppName: AppName;
10
+ sourceType: string;
11
+ }
12
+ //# sourceMappingURL=group_resource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"group_resource.d.ts","sourceRoot":"","sources":["../../../src/types/resources/group_resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEpC,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,OAAO,CAAA;IACb,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;IACvB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,aAAa,EAAE,OAAO,CAAA;IACtB,UAAU,EAAE,MAAM,CAAA;CACnB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=group_resource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"group_resource.js","sourceRoot":"","sources":["../../../src/types/resources/group_resource.ts"],"names":[],"mappings":"","sourcesContent":["import { AppName } from './app_name'\n\nexport interface GroupResource {\n type: 'Group'\n id: string\n links: { self: string }\n name: string | null\n sourceAppName: AppName\n sourceType: string\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  export * from './conversation';
2
+ export * from './member';
2
3
  export * from './message';
3
- export * from './person';
4
4
  export * from './oauth_token';
5
+ export * from './person';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/resources/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,eAAe,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/resources/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,UAAU,CAAA"}
@@ -1,5 +1,6 @@
1
1
  export * from './conversation';
2
+ export * from './member';
2
3
  export * from './message';
3
- export * from './person';
4
4
  export * from './oauth_token';
5
+ export * from './person';
5
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/resources/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,eAAe,CAAA","sourcesContent":["export * from './conversation'\nexport * from './message'\nexport * from './person'\nexport * from './oauth_token'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/resources/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,UAAU,CAAA","sourcesContent":["export * from './conversation'\nexport * from './member'\nexport * from './message'\nexport * from './oauth_token'\nexport * from './person'\n"]}
@@ -0,0 +1,23 @@
1
+ export interface MemberResource {
2
+ type: 'Member';
3
+ id: string;
4
+ name: string;
5
+ avatar: string;
6
+ badges: MemberBadge[];
7
+ child: boolean;
8
+ role?: string;
9
+ }
10
+ export interface MemberResourceWithPerson extends MemberResource {
11
+ person: {
12
+ firstName: string;
13
+ lastName: string;
14
+ avatarUrl: string;
15
+ child: boolean;
16
+ id: string;
17
+ type: 'Person';
18
+ };
19
+ }
20
+ export interface MemberBadge {
21
+ title: string;
22
+ }
23
+ //# sourceMappingURL=member.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"member.d.ts","sourceRoot":"","sources":["../../../src/types/resources/member.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,QAAQ,CAAA;IACd,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,WAAW,EAAE,CAAA;IACrB,KAAK,EAAE,OAAO,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,wBAAyB,SAAQ,cAAc;IAC9D,MAAM,EAAE;QACN,SAAS,EAAE,MAAM,CAAA;QACjB,QAAQ,EAAE,MAAM,CAAA;QAChB,SAAS,EAAE,MAAM,CAAA;QACjB,KAAK,EAAE,OAAO,CAAA;QACd,EAAE,EAAE,MAAM,CAAA;QACV,IAAI,EAAE,QAAQ,CAAA;KACf,CAAA;CACF;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAA;CACd"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=member.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"member.js","sourceRoot":"","sources":["../../../src/types/resources/member.ts"],"names":[],"mappings":"","sourcesContent":["export interface MemberResource {\n type: 'Member'\n id: string\n name: string\n avatar: string\n badges: MemberBadge[]\n child: boolean\n role?: string\n}\n\nexport interface MemberResourceWithPerson extends MemberResource {\n person: {\n firstName: string\n lastName: string\n avatarUrl: string\n child: boolean\n id: string\n type: 'Person'\n }\n}\n\nexport interface MemberBadge {\n title: string\n}\n"]}
@@ -0,0 +1,6 @@
1
+ export interface MemberAbilityResource {
2
+ type: 'MemberAbility';
3
+ canUpdate: boolean;
4
+ canDelete: boolean;
5
+ }
6
+ //# sourceMappingURL=member_ability.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"member_ability.d.ts","sourceRoot":"","sources":["../../../src/types/resources/member_ability.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,eAAe,CAAA;IACrB,SAAS,EAAE,OAAO,CAAA;IAClB,SAAS,EAAE,OAAO,CAAA;CACnB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=member_ability.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"member_ability.js","sourceRoot":"","sources":["../../../src/types/resources/member_ability.ts"],"names":[],"mappings":"","sourcesContent":["export interface MemberAbilityResource {\n type: 'MemberAbility'\n canUpdate: boolean\n canDelete: boolean\n}\n"]}
@@ -5,6 +5,6 @@ export interface ReactionCountResource {
5
5
  count: number;
6
6
  mine: number;
7
7
  messageId: string;
8
- authorIds: number[];
8
+ authorIds: string[];
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: number[]\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: string[]\n}\n"]}
@@ -14,7 +14,7 @@ export declare function updateRecordInPagesData<T extends ResourceObject>({ data
14
14
  pageParams: any;
15
15
  };
16
16
  record: T;
17
- processRecord?: (_record: T) => T;
17
+ processRecord?: (_next: T, _prev?: T) => T;
18
18
  }): {
19
19
  pages: {
20
20
  data: T[];
@@ -29,9 +29,26 @@ export declare function addRecordInPagesData<T extends ResourceObject>({ data, r
29
29
  pageParams: any;
30
30
  };
31
31
  record: T;
32
- processRecord?: (_record: T) => T;
32
+ processRecord?: (_next: T, _prev?: T) => T;
33
33
  }): {
34
34
  pages: ApiCollection<T>[];
35
35
  pageParams: any;
36
36
  } | undefined;
37
+ /**
38
+ * deleteRecordInPagesData
39
+ */
40
+ export declare function deleteRecordInPagesData<T extends ResourceObject>({ data, record, }: {
41
+ data?: {
42
+ pages: ApiCollection<T>[];
43
+ pageParams: any;
44
+ };
45
+ record: T;
46
+ }): {
47
+ pages: {
48
+ data: T[];
49
+ links: Record<string, string>;
50
+ meta: import("../../types").CollectionMeta;
51
+ }[];
52
+ pageParams: any;
53
+ } | undefined;
37
54
  //# sourceMappingURL=page_mutations.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"page_mutations.d.ts","sourceRoot":"","sources":["../../../src/utils/cache/page_mutations.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE3D;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,cAAc,EAAE,EAChE,IAAI,EACJ,MAAM,EACN,aAAsB,GACvB,EAAE;IACD,IAAI,CAAC,EAAE;QAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC;QAAC,UAAU,EAA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AC;QAAC,UAAU,EAAE,GAAG,CAAA;KAAE,CAAA;IACrD,MAAM,EAAE,CAAC,CAAA;IACT,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAA;CAC3C;;gBAHiD,GAAG;cAapD;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,cAAc,EAAE,EAChE,IAAI,EACJ,MAAM,GACP,EAAE;IACD,IAAI,CAAC,EAAE;QAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC;QAAC,UAAU,EAAE,GAAG,CAAA;KAAE,CAAA;IACrD,MAAM,EAAE,CAAC,CAAA;CACV;;;;;;gBAFiD,GAAG;cAcpD"}
@@ -15,7 +15,7 @@ export function updateRecordInPagesData({ data, record, processRecord = r => r,
15
15
  const newData = page.data.map(message => {
16
16
  if (message.id === record.id) {
17
17
  foundRecord = true;
18
- return processRecord(record);
18
+ return processRecord(record, message);
19
19
  }
20
20
  return message;
21
21
  });
@@ -24,9 +24,9 @@ export function updateRecordInPagesData({ data, record, processRecord = r => r,
24
24
  if (!foundRecord) {
25
25
  // Can be used to add as well but it's not at all efficient. It's better to use addRecordInPagesData.
26
26
  // This is a fallback for when the record is not found in the cache.
27
- const lastPage = { ...newPages[newPages.length - 1] };
28
- lastPage.data = [...lastPage.data, processRecord(record)];
29
- newPages[newPages.length - 1] = lastPage;
27
+ const firstPage = { ...newPages[0] };
28
+ firstPage.data = [processRecord(record), ...firstPage.data];
29
+ newPages[0] = firstPage;
30
30
  }
31
31
  return { ...data, pages: newPages };
32
32
  }
@@ -34,9 +34,23 @@ export function addRecordInPagesData({ data, record, processRecord = r => r, })
34
34
  if (!data)
35
35
  return data;
36
36
  const newPages = [...data.pages];
37
- const lastPage = { ...newPages[newPages.length - 1] };
38
- lastPage.data = [...lastPage.data, processRecord(record)];
39
- newPages[newPages.length - 1] = lastPage;
37
+ const firstPage = { ...newPages[0] };
38
+ firstPage.data = [processRecord(record), ...firstPage.data];
39
+ newPages[0] = firstPage;
40
+ return { ...data, pages: newPages };
41
+ }
42
+ /**
43
+ * deleteRecordInPagesData
44
+ */
45
+ export function deleteRecordInPagesData({ data, record, }) {
46
+ if (!data)
47
+ return data;
48
+ const newPages = data.pages.map(page => {
49
+ const newData = page.data.filter(message => {
50
+ return message.id !== record.id;
51
+ });
52
+ return { ...page, data: newData };
53
+ });
40
54
  return { ...data, pages: newPages };
41
55
  }
42
56
  //# sourceMappingURL=page_mutations.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"page_mutations.js","sourceRoot":"","sources":["../../../src/utils/cache/page_mutations.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAA2B,EAChE,IAAI,EACJ,MAAM,EACN,aAAa,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,GAKvB;IACC,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAA;IAEtB,IAAI,WAAW,GAAG,KAAK,CAAA;IACvB,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QACrC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;YACtC,IAAI,OAAO,CAAC,EAAE,KAAK,MAAM,CAAC,EAAE,EAAE,CAAC;gBAC7B,WAAW,GAAG,IAAI,CAAA;gBAClB,OAAO,aAAa,CAAC,MAAM,CAAC,CAAA;YAC9B,CAAC;YACD,OAAO,OAAO,CAAA;QAChB,CAAC,CAAC,CAAA;QAEF,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAA;IACnC,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,qGAAqG;QACrG,oEAAoE;QACpE,MAAM,QAAQ,GAAG,EAAE,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAA;QACrD,QAAQ,CAAC,IAAI,GAAG,CAAC,GAAG,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC,CAAA;QACzD,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAA;IAC1C,CAAC;IAED,OAAO,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAA;AACrC,CAAC;AAED,MAAM,UAAU,oBAAoB,CAA2B,EAC7D,IAAI,EACJ,MAAM,EACN,aAAa,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,GAKvB;IACC,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAA;IAEtB,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAA;IAChC,MAAM,QAAQ,GAAG,EAAE,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAA;IACrD,QAAQ,CAAC,IAAI,GAAG,CAAC,GAAG,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC,CAAA;IAEzD,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAA;IAExC,OAAO,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAA;AACrC,CAAC","sourcesContent":["/**\n * Helpers to handle updating messages in the cache\n * Messages are ordered by ULID on the client so we may\n * have diverging logic from other kinds of api data\n */\n\nimport { ApiCollection, ResourceObject } from '../../types'\n\n/**\n * updateRecordInPagesData\n * Can be used to add as well but it's not at all efficient. It's better to use addRecordInPagesData.\n */\nexport function updateRecordInPagesData<T extends ResourceObject>({\n data,\n record,\n processRecord = r => r,\n}: {\n data?: { pages: ApiCollection<T>[]; pageParams: any }\n record: T\n processRecord?: (_record: T) => T\n}) {\n if (!data) return data\n\n let foundRecord = false\n const newPages = data.pages.map(page => {\n const newData = page.data.map(message => {\n if (message.id === record.id) {\n foundRecord = true\n return processRecord(record)\n }\n return message\n })\n\n return { ...page, data: newData }\n })\n\n if (!foundRecord) {\n // Can be used to add as well but it's not at all efficient. It's better to use addRecordInPagesData.\n // This is a fallback for when the record is not found in the cache.\n const lastPage = { ...newPages[newPages.length - 1] }\n lastPage.data = [...lastPage.data, processRecord(record)]\n newPages[newPages.length - 1] = lastPage\n }\n\n return { ...data, pages: newPages }\n}\n\nexport function addRecordInPagesData<T extends ResourceObject>({\n data,\n record,\n processRecord = r => r,\n}: {\n data?: { pages: ApiCollection<T>[]; pageParams: any }\n record: T\n processRecord?: (_record: T) => T\n}) {\n if (!data) return data\n\n const newPages = [...data.pages]\n const lastPage = { ...newPages[newPages.length - 1] }\n lastPage.data = [...lastPage.data, processRecord(record)]\n\n newPages[newPages.length - 1] = lastPage\n\n return { ...data, pages: newPages }\n}\n"]}
1
+ {"version":3,"file":"page_mutations.js","sourceRoot":"","sources":["../../../src/utils/cache/page_mutations.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAA2B,EAChE,IAAI,EACJ,MAAM,EACN,aAAa,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,GAKvB;IACC,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAA;IAEtB,IAAI,WAAW,GAAG,KAAK,CAAA;IACvB,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QACrC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;YACtC,IAAI,OAAO,CAAC,EAAE,KAAK,MAAM,CAAC,EAAE,EAAE,CAAC;gBAC7B,WAAW,GAAG,IAAI,CAAA;gBAClB,OAAO,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;YACvC,CAAC;YACD,OAAO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,CAAC,EAAE;QACrC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE;YACzC,OAAO,OAAO,CAAC,EAAE,KAAK,MAAM,CAAC,EAAE,CAAA;QACjC,CAAC,CAAC,CAAA;QAEF,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAA;IACnC,CAAC,CAAC,CAAA;IAEF,OAAO,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAA;AACrC,CAAC","sourcesContent":["/**\n * Helpers to handle updating messages in the cache\n * Messages are ordered by ULID on the client so we may\n * have diverging logic from other kinds of api data\n */\n\nimport { ApiCollection, ResourceObject } from '../../types'\n\n/**\n * updateRecordInPagesData\n * Can be used to add as well but it's not at all efficient. It's better to use addRecordInPagesData.\n */\nexport function updateRecordInPagesData<T extends ResourceObject>({\n data,\n record,\n processRecord = r => r,\n}: {\n data?: { pages: ApiCollection<T>[]; pageParams: any }\n record: T\n processRecord?: (_next: T, _prev?: T) => T\n}) {\n if (!data) return data\n\n let foundRecord = false\n const newPages = data.pages.map(page => {\n const newData = page.data.map(message => {\n if (message.id === record.id) {\n foundRecord = true\n return processRecord(record, message)\n }\n return message\n })\n\n return { ...page, data: newData }\n })\n\n if (!foundRecord) {\n // Can be used to add as well but it's not at all efficient. It's better to use addRecordInPagesData.\n // This is a fallback for when the record is not found in the cache.\n const firstPage = { ...newPages[0] }\n firstPage.data = [processRecord(record), ...firstPage.data]\n newPages[0] = firstPage\n }\n\n return { ...data, pages: newPages }\n}\n\nexport function addRecordInPagesData<T extends ResourceObject>({\n data,\n record,\n processRecord = r => r,\n}: {\n data?: { pages: ApiCollection<T>[]; pageParams: any }\n record: T\n processRecord?: (_next: T, _prev?: T) => T\n}) {\n if (!data) return data\n\n const newPages = [...data.pages]\n const firstPage = { ...newPages[0] }\n firstPage.data = [processRecord(record), ...firstPage.data]\n\n newPages[0] = firstPage\n\n return { ...data, pages: newPages }\n}\n\n/**\n * deleteRecordInPagesData\n */\nexport function deleteRecordInPagesData<T extends ResourceObject>({\n data,\n record,\n}: {\n data?: { pages: ApiCollection<T>[]; pageParams: any }\n record: T\n}) {\n if (!data) return data\n\n const newPages = data.pages.map(page => {\n const newData = page.data.filter(message => {\n return message.id !== record.id\n })\n\n return { ...page, data: newData }\n })\n\n return { ...data, pages: newPages }\n}\n"]}
@@ -0,0 +1,4 @@
1
+ type DateProps = string | number | Date;
2
+ export declare function formatDatePreview(date?: DateProps): any;
3
+ export {};
4
+ //# sourceMappingURL=date.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../src/utils/date.ts"],"names":[],"mappings":"AAGA,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;AAEvC,wBAAgB,iBAAiB,CAAC,IAAI,CAAC,EAAE,SAAS,OAcjD"}
@@ -0,0 +1,23 @@
1
+ import { date as formatDate } from '@planningcenter/datetime-fmt';
2
+ import moment from 'moment-timezone';
3
+ export function formatDatePreview(date) {
4
+ if (!date)
5
+ return '';
6
+ const now = moment();
7
+ const isToday = now.isSame(date, 'day');
8
+ const isThisWeek = now.isSame(date, 'week');
9
+ const isThisYear = now.isSame(date, 'year');
10
+ if (isToday)
11
+ return moment(date).format('h:mm a');
12
+ if (isThisWeek)
13
+ return formatDate(date, { style: 'relative-short' });
14
+ if (isThisYear)
15
+ return formatDate(date, { style: 'abbreviated' });
16
+ // TODO: Org date format
17
+ return formatShorterDate(date);
18
+ }
19
+ const formatShorterDate = (date) => {
20
+ // Drop the century from the year
21
+ return formatDate(date, { style: 'short', year: true }).replace(/20(\d{2})/, '$1');
22
+ };
23
+ //# sourceMappingURL=date.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date.js","sourceRoot":"","sources":["../../src/utils/date.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,8BAA8B,CAAA;AACjE,OAAO,MAAM,MAAM,iBAAiB,CAAA;AAIpC,MAAM,UAAU,iBAAiB,CAAC,IAAgB;IAChD,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAA;IAEpB,MAAM,GAAG,GAAG,MAAM,EAAE,CAAA;IACpB,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;IACvC,MAAM,UAAU,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IAC3C,MAAM,UAAU,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IAE3C,IAAI,OAAO;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IACjD,IAAI,UAAU;QAAE,OAAO,UAAU,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,gBAAgB,EAAE,CAAC,CAAA;IACpE,IAAI,UAAU;QAAE,OAAO,UAAU,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC,CAAA;IAEjE,wBAAwB;IACxB,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAA;AAChC,CAAC;AAED,MAAM,iBAAiB,GAAG,CAAC,IAAe,EAAE,EAAE;IAC5C,iCAAiC;IACjC,OAAO,UAAU,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,CAAA;AACpF,CAAC,CAAA","sourcesContent":["import { date as formatDate } from '@planningcenter/datetime-fmt'\nimport moment from 'moment-timezone'\n\ntype DateProps = string | number | Date\n\nexport function formatDatePreview(date?: DateProps) {\n if (!date) return ''\n\n const now = moment()\n const isToday = now.isSame(date, 'day')\n const isThisWeek = now.isSame(date, 'week')\n const isThisYear = now.isSame(date, 'year')\n\n if (isToday) return moment(date).format('h:mm a')\n if (isThisWeek) return formatDate(date, { style: 'relative-short' })\n if (isThisYear) return formatDate(date, { style: 'abbreviated' })\n\n // TODO: Org date format\n return formatShorterDate(date)\n}\n\nconst formatShorterDate = (date: DateProps) => {\n // Drop the century from the year\n return formatDate(date, { style: 'short', year: true }).replace(/20(\\d{2})/, '$1')\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planningcenter/chat-react-native",
3
- "version": "2.0.1-rc.0",
3
+ "version": "2.1.0-rc.0",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -24,13 +24,17 @@
24
24
  "react-native-url-polyfill": "^2.0.0"
25
25
  },
26
26
  "peerDependencies": {
27
- "@planningcenter/icons": "^15.17.0",
27
+ "@planningcenter/datetime-fmt": ">=1.0.0",
28
+ "@planningcenter/icons": ">=15.0.0",
29
+ "@planningcenter/jolt-client": ">=2.0.0",
28
30
  "@react-navigation/elements": "*",
29
31
  "@react-navigation/native": ">=7.0.0",
30
32
  "@react-navigation/native-stack": ">=7.0.0",
31
33
  "@tanstack/react-query": "^5.0.0",
32
34
  "color": "^3.1.2",
33
35
  "lodash": "*",
36
+ "moment": ">=2.0.0",
37
+ "moment-timezone": ">=2.0.0",
34
38
  "react": "*",
35
39
  "react-native": "*",
36
40
  "react-native-device-info": "*",
@@ -47,5 +51,5 @@
47
51
  "prettier": "^3.4.2",
48
52
  "typescript": "<5.6.0"
49
53
  },
50
- "gitHead": "06d7daa82162274562468d89e060fa707cbbd7a3"
54
+ "gitHead": "9ada391b04ffc168aa7ffb4baaa746429ee7e093"
51
55
  }
@@ -1,4 +1,4 @@
1
- import { addRecordInPagesData, updateRecordInPagesData } from '../../../utils/'
1
+ import { deleteRecordInPagesData, updateRecordInPagesData } from '../../../utils/'
2
2
 
3
3
  const data = {
4
4
  pageParams: {},
@@ -105,6 +105,7 @@ describe('updateRecordInPagesData', () => {
105
105
  pages: [
106
106
  {
107
107
  data: [
108
+ { id, type: 'Message', text: `updated example ${id}` },
108
109
  { id: '1', type: 'Message', text: 'message 1' },
109
110
  { id: '2', type: 'Message', text: 'message 2' },
110
111
  ],
@@ -116,7 +117,6 @@ describe('updateRecordInPagesData', () => {
116
117
  data: [
117
118
  { id: '3', type: 'Message', text: 'message 3' },
118
119
  { id: '4', type: 'Message', text: 'message 4' },
119
- { id, type: 'Message', text: `updated example ${id}` },
120
120
  ],
121
121
  included: [],
122
122
  links: {},
@@ -127,49 +127,14 @@ describe('updateRecordInPagesData', () => {
127
127
  })
128
128
  })
129
129
 
130
- describe('addRecordInPagesData', () => {
131
- it('should add records that do not yet exist', () => {
132
- const id = '7'
130
+ describe('deleteRecordInPagesData', () => {
131
+ it('should delete records from page', () => {
132
+ const id = '4'
133
133
  const record = createRecord({ id })
134
134
 
135
- const result = addRecordInPagesData<typeof record>({
136
- data,
137
- record,
138
- })
139
-
140
- expect(result).toEqual({
141
- pageParams: {},
142
- pages: [
143
- {
144
- data: [
145
- { id: '1', type: 'Message', text: 'message 1' },
146
- { id: '2', type: 'Message', text: 'message 2' },
147
- ],
148
- included: [],
149
- links: {},
150
- meta: { count: 2, totalCount: 2 },
151
- },
152
- {
153
- data: [
154
- { id: '3', type: 'Message', text: 'message 3' },
155
- { id: '4', type: 'Message', text: 'message 4' },
156
- record,
157
- ],
158
- included: [],
159
- links: {},
160
- meta: { count: 2, totalCount: 2 },
161
- },
162
- ],
163
- })
164
- })
165
-
166
- it('should add the record in the pages data and update with a custom processRecord function', () => {
167
- const id = '8'
168
- const record = createRecord({ id })
169
- const result = addRecordInPagesData<typeof record>({
135
+ const result = deleteRecordInPagesData<typeof record>({
170
136
  data,
171
137
  record,
172
- processRecord: r => ({ ...r, text: 'updated ' + r.text }),
173
138
  })
174
139
 
175
140
  expect(result).toEqual({
@@ -185,11 +150,7 @@ describe('addRecordInPagesData', () => {
185
150
  meta: { count: 2, totalCount: 2 },
186
151
  },
187
152
  {
188
- data: [
189
- { id: '3', type: 'Message', text: 'message 3' },
190
- { id: '4', type: 'Message', text: 'message 4' },
191
- { ...record, text: `updated example ${id}` },
192
- ],
153
+ data: [{ id: '3', type: 'Message', text: 'message 3' }],
193
154
  included: [],
194
155
  links: {},
195
156
  meta: { count: 2, totalCount: 2 },