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

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 (138) 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/components/index.d.ts +1 -1
  20. package/build/components/index.d.ts.map +1 -1
  21. package/build/components/index.js +1 -1
  22. package/build/components/index.js.map +1 -1
  23. package/build/components/{error_boundary.d.ts → page/error_boundary.d.ts} +6 -4
  24. package/build/components/page/error_boundary.d.ts.map +1 -0
  25. package/build/components/page/error_boundary.js +115 -0
  26. package/build/components/page/error_boundary.js.map +1 -0
  27. package/build/components/page/loading.d.ts +3 -0
  28. package/build/components/page/loading.d.ts.map +1 -0
  29. package/build/components/page/loading.js +24 -0
  30. package/build/components/page/loading.js.map +1 -0
  31. package/build/contexts/api_provider.js +2 -2
  32. package/build/contexts/api_provider.js.map +1 -1
  33. package/build/hooks/use_conversation_jolt_events.d.ts +2 -0
  34. package/build/hooks/use_conversation_jolt_events.d.ts.map +1 -0
  35. package/build/hooks/use_conversation_jolt_events.js +47 -0
  36. package/build/hooks/use_conversation_jolt_events.js.map +1 -0
  37. package/build/hooks/use_conversation_messages.d.ts +2 -18
  38. package/build/hooks/use_conversation_messages.d.ts.map +1 -1
  39. package/build/hooks/use_conversation_messages.js +2 -2
  40. package/build/hooks/use_conversation_messages.js.map +1 -1
  41. package/build/hooks/use_conversations.d.ts +37 -0
  42. package/build/hooks/use_conversations.d.ts.map +1 -0
  43. package/build/hooks/use_conversations.js +48 -0
  44. package/build/hooks/use_conversations.js.map +1 -0
  45. package/build/hooks/use_jolt.d.ts +9 -0
  46. package/build/hooks/use_jolt.d.ts.map +1 -0
  47. package/build/hooks/use_jolt.js +71 -0
  48. package/build/hooks/use_jolt.js.map +1 -0
  49. package/build/hooks/use_suspense_api.d.ts +7 -2
  50. package/build/hooks/use_suspense_api.d.ts.map +1 -1
  51. package/build/hooks/use_suspense_api.js +7 -2
  52. package/build/hooks/use_suspense_api.js.map +1 -1
  53. package/build/navigation/index.d.ts +11 -2
  54. package/build/navigation/index.d.ts.map +1 -1
  55. package/build/navigation/index.js +14 -6
  56. package/build/navigation/index.js.map +1 -1
  57. package/build/navigation/screenLayout.d.ts.map +1 -1
  58. package/build/navigation/screenLayout.js +5 -8
  59. package/build/navigation/screenLayout.js.map +1 -1
  60. package/build/screens/message_actions_screen.d.ts +1 -1
  61. package/build/screens/message_actions_screen.d.ts.map +1 -1
  62. package/build/screens/message_actions_screen.js +1 -1
  63. package/build/screens/message_actions_screen.js.map +1 -1
  64. package/build/screens/reactions_screen.d.ts +11 -0
  65. package/build/screens/reactions_screen.d.ts.map +1 -0
  66. package/build/screens/reactions_screen.js +83 -0
  67. package/build/screens/reactions_screen.js.map +1 -0
  68. package/build/types/resources/app_name.d.ts +2 -0
  69. package/build/types/resources/app_name.d.ts.map +1 -0
  70. package/build/types/resources/app_name.js +2 -0
  71. package/build/types/resources/app_name.js.map +1 -0
  72. package/build/types/resources/conversation.d.ts +18 -10
  73. package/build/types/resources/conversation.d.ts.map +1 -1
  74. package/build/types/resources/conversation.js.map +1 -1
  75. package/build/types/resources/conversation_badge.d.ts +12 -0
  76. package/build/types/resources/conversation_badge.d.ts.map +1 -0
  77. package/build/types/resources/conversation_badge.js +2 -0
  78. package/build/types/resources/conversation_badge.js.map +1 -0
  79. package/build/types/resources/group_resource.d.ts +12 -0
  80. package/build/types/resources/group_resource.d.ts.map +1 -0
  81. package/build/types/resources/group_resource.js +2 -0
  82. package/build/types/resources/group_resource.js.map +1 -0
  83. package/build/types/resources/index.d.ts +2 -1
  84. package/build/types/resources/index.d.ts.map +1 -1
  85. package/build/types/resources/index.js +2 -1
  86. package/build/types/resources/index.js.map +1 -1
  87. package/build/types/resources/member.d.ts +23 -0
  88. package/build/types/resources/member.d.ts.map +1 -0
  89. package/build/types/resources/member.js +2 -0
  90. package/build/types/resources/member.js.map +1 -0
  91. package/build/types/resources/member_ability.d.ts +6 -0
  92. package/build/types/resources/member_ability.d.ts.map +1 -0
  93. package/build/types/resources/member_ability.js +2 -0
  94. package/build/types/resources/member_ability.js.map +1 -0
  95. package/build/types/resources/reaction.d.ts +1 -1
  96. package/build/types/resources/reaction.js.map +1 -1
  97. package/build/utils/cache/page_mutations.d.ts +19 -2
  98. package/build/utils/cache/page_mutations.d.ts.map +1 -1
  99. package/build/utils/cache/page_mutations.js +21 -7
  100. package/build/utils/cache/page_mutations.js.map +1 -1
  101. package/build/utils/date.d.ts +4 -0
  102. package/build/utils/date.d.ts.map +1 -0
  103. package/build/utils/date.js +23 -0
  104. package/build/utils/date.js.map +1 -0
  105. package/package.json +7 -3
  106. package/src/__tests__/utils/cache/page_mutations.ts +7 -46
  107. package/src/components/conversation/message.tsx +8 -3
  108. package/src/components/conversation/message_reaction.tsx +6 -2
  109. package/src/components/conversations.tsx +95 -32
  110. package/src/components/display/badge.tsx +3 -8
  111. package/src/components/display/tabs.tsx +142 -0
  112. package/src/components/index.tsx +1 -1
  113. package/src/components/page/error_boundary.tsx +135 -0
  114. package/src/components/page/loading.tsx +28 -0
  115. package/src/contexts/api_provider.tsx +3 -3
  116. package/src/hooks/use_conversation_jolt_events.ts +67 -0
  117. package/src/hooks/use_conversation_messages.ts +6 -2
  118. package/src/hooks/use_conversations.ts +53 -0
  119. package/src/hooks/use_jolt.ts +101 -0
  120. package/src/hooks/use_suspense_api.ts +10 -3
  121. package/src/navigation/index.tsx +23 -7
  122. package/src/navigation/screenLayout.tsx +5 -10
  123. package/src/screens/message_actions_screen.tsx +1 -1
  124. package/src/screens/reactions_screen.tsx +131 -0
  125. package/src/types/resources/app_name.ts +1 -0
  126. package/src/types/resources/conversation.ts +18 -10
  127. package/src/types/resources/conversation_badge.ts +10 -0
  128. package/src/types/resources/group_resource.ts +10 -0
  129. package/src/types/resources/index.ts +2 -1
  130. package/src/types/resources/member.ts +24 -0
  131. package/src/types/resources/member_ability.ts +5 -0
  132. package/src/types/resources/reaction.ts +1 -1
  133. package/src/utils/cache/page_mutations.ts +32 -9
  134. package/src/utils/date.ts +25 -0
  135. package/build/components/error_boundary.d.ts.map +0 -1
  136. package/build/components/error_boundary.js +0 -24
  137. package/build/components/error_boundary.js.map +0 -1
  138. package/src/components/error_boundary.tsx +0 -27
@@ -1,20 +1,15 @@
1
1
  import React from 'react'
2
- import { QueryErrorResetBoundary } from '@tanstack/react-query'
3
- import ErrorBoundary from '../components/error_boundary'
2
+ import ErrorBoundary from '../components/page/error_boundary'
4
3
  import { Suspense } from 'react'
5
- import { Text } from '../components/display'
6
4
  import { ApiProvider } from '../contexts'
5
+ import { DefaultLoading } from '../components/page/loading'
7
6
 
8
7
  export function ScreenLayout({ children }: { children: React.ReactElement }) {
9
8
  return (
10
9
  <ApiProvider>
11
- <QueryErrorResetBoundary>
12
- {({ reset }) => (
13
- <ErrorBoundary onReset={reset}>
14
- <Suspense fallback={<Text>loading...</Text>}>{children}</Suspense>
15
- </ErrorBoundary>
16
- )}
17
- </QueryErrorResetBoundary>
10
+ <ErrorBoundary>
11
+ <Suspense fallback={<DefaultLoading />}>{children}</Suspense>
12
+ </ErrorBoundary>
18
13
  </ApiProvider>
19
14
  )
20
15
  }
@@ -15,7 +15,7 @@ import { ReactionCountResource } from '../types/resources/reaction'
15
15
  import { updateRecordInPagesData } from '../utils'
16
16
  import { Clipboard } from '../utils/native_adapters'
17
17
 
18
- export const ReactScreenOptions: NativeStackNavigationOptions = {
18
+ export const MessageActionsScreenOptions: NativeStackNavigationOptions = {
19
19
  presentation: 'formSheet',
20
20
  headerShown: false,
21
21
  sheetAllowedDetents: [0.25],
@@ -0,0 +1,131 @@
1
+ import { StaticScreenProps } from '@react-navigation/native'
2
+ import { NativeStackNavigationOptions } from '@react-navigation/native-stack'
3
+ import React from 'react'
4
+ import { FlatList, StyleSheet, useWindowDimensions, View } from 'react-native'
5
+ import { useSafeAreaInsets } from 'react-native-safe-area-context'
6
+ import { Avatar, Text } from '../components'
7
+ import { REACTION_EMOJIS, useReactionStyles } from '../components/conversation/message_reaction'
8
+ import { Tabs } from '../components/display/tabs'
9
+ import { useSuspenseGet, useTheme } from '../hooks'
10
+ import { useConversationMessages } from '../hooks/use_conversation_messages'
11
+ import { MemberResource } from '../types'
12
+ import { ReactionCountResource } from '../types/resources/reaction'
13
+
14
+ export const ReactionsScreenOptions: NativeStackNavigationOptions = {
15
+ presentation: 'formSheet',
16
+ headerShown: false,
17
+ sheetAllowedDetents: [0.5],
18
+ sheetGrabberVisible: true,
19
+ }
20
+
21
+ export type ReactionScreenProps = StaticScreenProps<{
22
+ message_id: string
23
+ conversation_id: string
24
+ reaction_value?: string
25
+ }>
26
+
27
+ export function ReactionsScreen({ route }: ReactionScreenProps) {
28
+ const { conversation_id, message_id, reaction_value } = route.params
29
+ const styles = useStyles()
30
+
31
+ const { messages } = useConversationMessages({ conversation_id }, { refetchOnMount: false })
32
+ const { data: members } = useSuspenseGet<MemberResource[]>({
33
+ url: `/me/conversations/${conversation_id}/members`,
34
+ data: {
35
+ fields: {
36
+ Member: ['id', 'name', 'avatar', 'badges', 'child', 'role'],
37
+ },
38
+ },
39
+ })
40
+ const message = messages.find(m => m.id === message_id)
41
+ const reactionCounts = message?.reactionCounts || []
42
+ const initialReactionCount =
43
+ reactionCounts.find(r => r.value === reaction_value) || reactionCounts[0]
44
+ const [reactionCount, setReactionCount] =
45
+ React.useState<ReactionCountResource>(initialReactionCount)
46
+
47
+ const authorIds = reactionCount.authorIds
48
+ const authors = members.filter(member => authorIds.includes(member.id))
49
+
50
+ return (
51
+ <View style={styles.container}>
52
+ <Tabs
53
+ data={reactionCounts}
54
+ activeTab={reactionCount}
55
+ onTabPress={setReactionCount}
56
+ renderItem={({ item }) => (
57
+ <Reaction
58
+ active={reactionCount.id === item.id}
59
+ reaction={item}
60
+ onPress={() => setReactionCount(item)}
61
+ />
62
+ )}
63
+ style={styles.actions}
64
+ />
65
+ <FlatList
66
+ data={authors}
67
+ keyExtractor={item => item.id}
68
+ renderItem={({ item: author }) => (
69
+ <View style={styles.authorList}>
70
+ <Avatar size={'md'} sourceUri={author.avatar} />
71
+ <Text key={author.id}>{author.name}</Text>
72
+ </View>
73
+ )}
74
+ />
75
+ </View>
76
+ )
77
+ }
78
+
79
+ const Reaction = ({
80
+ reaction,
81
+ }: {
82
+ active: boolean
83
+ reaction: ReactionCountResource
84
+ onPress: () => void
85
+ }) => {
86
+ const styles = useStyles()
87
+ const reactionStyles = useReactionStyles({ mine: reaction.mine ? 1 : 0 })
88
+
89
+ return (
90
+ <View key={reaction.value} style={styles.reaction}>
91
+ <Text style={reactionStyles.reactionEmoji}>{REACTION_EMOJIS[reaction.value]}</Text>
92
+ <Text style={reactionStyles.reactionEmoji}>{reaction.count}</Text>
93
+ </View>
94
+ )
95
+ }
96
+
97
+ const useStyles = () => {
98
+ const theme = useTheme()
99
+ const { height } = useWindowDimensions()
100
+ const { bottom } = useSafeAreaInsets()
101
+
102
+ return StyleSheet.create({
103
+ container: {
104
+ justifyContent: 'flex-start',
105
+ paddingTop: 12,
106
+ paddingBottom: bottom,
107
+ width: '100%',
108
+ backgroundColor: theme.colors.fillColorNeutral100Inverted,
109
+ height,
110
+ gap: 8,
111
+ },
112
+ authorList: {
113
+ flexDirection: 'row',
114
+ alignItems: 'center',
115
+ gap: 8,
116
+ paddingHorizontal: 12,
117
+ paddingVertical: 12,
118
+ },
119
+ reaction: {
120
+ paddingVertical: 12,
121
+ paddingHorizontal: 12,
122
+ flexDirection: 'row',
123
+ gap: 4,
124
+ },
125
+ actions: {
126
+ minHeight: 48,
127
+ borderBottomColor: theme.colors.fillColorNeutral040,
128
+ borderBottomWidth: 1,
129
+ },
130
+ })
131
+ }
@@ -0,0 +1 @@
1
+ export type AppName = 'Services' | 'Groups'
@@ -1,15 +1,23 @@
1
- import type { ResourceObject } from '../api_primitives'
1
+ import { ConversationBadgeResource } from './conversation_badge'
2
+ import { GroupResource } from './group_resource'
3
+ import { MemberAbilityResource } from './member_ability'
2
4
 
3
- export interface ConversationResource extends ResourceObject {
4
- title: string
5
- subtitle: string
5
+ export interface ConversationResource {
6
+ type: 'Conversation'
7
+ id: string
8
+ badges?: ConversationBadgeResource[]
6
9
  createdAt: string
7
- updatedAt: string
10
+ deleted?: boolean
11
+ groups?: GroupResource[]
12
+ previewAvatarUrls?: string[]
13
+ lastMessageAuthorId?: string
14
+ lastMessageAuthorName?: string
15
+ lastMessageCreatedAt?: string
16
+ lastMessageTextPreview?: string
17
+ memberAbility?: MemberAbilityResource
18
+ muted: boolean
8
19
  repliesDisabled: boolean
9
- lastMessageAuthorId: string
10
- lastMessageAuthorName: string
11
- lastMessageCreatedAt: string
12
- lastMessageTextPreview: string
20
+ title: string
13
21
  unreadCount: number
14
- muted: boolean
22
+ updatedAt: string
15
23
  }
@@ -0,0 +1,10 @@
1
+ import { AppName } from './app_name'
2
+
3
+ export interface ConversationBadgeResource {
4
+ type: 'ConversationBadge'
5
+ id: string
6
+ links: { self: string }
7
+ text: string | null
8
+ appName: AppName
9
+ pcoResourceType: string
10
+ }
@@ -0,0 +1,10 @@
1
+ import { AppName } from './app_name'
2
+
3
+ export interface GroupResource {
4
+ type: 'Group'
5
+ id: string
6
+ links: { self: string }
7
+ name: string | null
8
+ sourceAppName: AppName
9
+ sourceType: string
10
+ }
@@ -1,4 +1,5 @@
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'
@@ -0,0 +1,24 @@
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
+
11
+ export interface MemberResourceWithPerson extends MemberResource {
12
+ person: {
13
+ firstName: string
14
+ lastName: string
15
+ avatarUrl: string
16
+ child: boolean
17
+ id: string
18
+ type: 'Person'
19
+ }
20
+ }
21
+
22
+ export interface MemberBadge {
23
+ title: string
24
+ }
@@ -0,0 +1,5 @@
1
+ export interface MemberAbilityResource {
2
+ type: 'MemberAbility'
3
+ canUpdate: boolean
4
+ canDelete: boolean
5
+ }
@@ -5,5 +5,5 @@ export interface ReactionCountResource {
5
5
  count: number
6
6
  mine: number
7
7
  messageId: string
8
- authorIds: number[]
8
+ authorIds: string[]
9
9
  }
@@ -17,7 +17,7 @@ export function updateRecordInPagesData<T extends ResourceObject>({
17
17
  }: {
18
18
  data?: { pages: ApiCollection<T>[]; pageParams: any }
19
19
  record: T
20
- processRecord?: (_record: T) => T
20
+ processRecord?: (_next: T, _prev?: T) => T
21
21
  }) {
22
22
  if (!data) return data
23
23
 
@@ -26,7 +26,7 @@ export function updateRecordInPagesData<T extends ResourceObject>({
26
26
  const newData = page.data.map(message => {
27
27
  if (message.id === record.id) {
28
28
  foundRecord = true
29
- return processRecord(record)
29
+ return processRecord(record, message)
30
30
  }
31
31
  return message
32
32
  })
@@ -37,9 +37,9 @@ export function updateRecordInPagesData<T extends ResourceObject>({
37
37
  if (!foundRecord) {
38
38
  // Can be used to add as well but it's not at all efficient. It's better to use addRecordInPagesData.
39
39
  // This is a fallback for when the record is not found in the cache.
40
- const lastPage = { ...newPages[newPages.length - 1] }
41
- lastPage.data = [...lastPage.data, processRecord(record)]
42
- newPages[newPages.length - 1] = lastPage
40
+ const firstPage = { ...newPages[0] }
41
+ firstPage.data = [processRecord(record), ...firstPage.data]
42
+ newPages[0] = firstPage
43
43
  }
44
44
 
45
45
  return { ...data, pages: newPages }
@@ -52,15 +52,38 @@ export function addRecordInPagesData<T extends ResourceObject>({
52
52
  }: {
53
53
  data?: { pages: ApiCollection<T>[]; pageParams: any }
54
54
  record: T
55
- processRecord?: (_record: T) => T
55
+ processRecord?: (_next: T, _prev?: T) => T
56
56
  }) {
57
57
  if (!data) return data
58
58
 
59
59
  const newPages = [...data.pages]
60
- const lastPage = { ...newPages[newPages.length - 1] }
61
- lastPage.data = [...lastPage.data, processRecord(record)]
60
+ const firstPage = { ...newPages[0] }
61
+ firstPage.data = [processRecord(record), ...firstPage.data]
62
62
 
63
- newPages[newPages.length - 1] = lastPage
63
+ newPages[0] = firstPage
64
+
65
+ return { ...data, pages: newPages }
66
+ }
67
+
68
+ /**
69
+ * deleteRecordInPagesData
70
+ */
71
+ export function deleteRecordInPagesData<T extends ResourceObject>({
72
+ data,
73
+ record,
74
+ }: {
75
+ data?: { pages: ApiCollection<T>[]; pageParams: any }
76
+ record: T
77
+ }) {
78
+ if (!data) return data
79
+
80
+ const newPages = data.pages.map(page => {
81
+ const newData = page.data.filter(message => {
82
+ return message.id !== record.id
83
+ })
84
+
85
+ return { ...page, data: newData }
86
+ })
64
87
 
65
88
  return { ...data, pages: newPages }
66
89
  }
@@ -0,0 +1,25 @@
1
+ import { date as formatDate } from '@planningcenter/datetime-fmt'
2
+ import moment from 'moment-timezone'
3
+
4
+ type DateProps = string | number | Date
5
+
6
+ export function formatDatePreview(date?: DateProps) {
7
+ if (!date) return ''
8
+
9
+ const now = moment()
10
+ const isToday = now.isSame(date, 'day')
11
+ const isThisWeek = now.isSame(date, 'week')
12
+ const isThisYear = now.isSame(date, 'year')
13
+
14
+ if (isToday) return moment(date).format('h:mm a')
15
+ if (isThisWeek) return formatDate(date, { style: 'relative-short' })
16
+ if (isThisYear) return formatDate(date, { style: 'abbreviated' })
17
+
18
+ // TODO: Org date format
19
+ return formatShorterDate(date)
20
+ }
21
+
22
+ const formatShorterDate = (date: DateProps) => {
23
+ // Drop the century from the year
24
+ return formatDate(date, { style: 'short', year: true }).replace(/20(\d{2})/, '$1')
25
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"error_boundary.d.ts","sourceRoot":"","sources":["../../src/components/error_boundary.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAGhD,cAAM,aAAc,SAAQ,KAAK,CAAC,SAAS,CAAC,iBAAiB,CAAC;IAAE,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;CAAE,CAAC,CAAC;IACtF,KAAK;;;MAGJ;IAED,iBAAiB,CAAC,KAAK,EAAE,GAAG;IAI5B,WAAW,CAAC,KAAK,EAAE,GAAG;IAItB,MAAM;CAOP;AAED,eAAe,aAAa,CAAA"}
@@ -1,24 +0,0 @@
1
- import React from 'react';
2
- import { Text } from 'react-native';
3
- class ErrorBoundary extends React.Component {
4
- state = {
5
- error: null,
6
- unsubscriber: () => { },
7
- };
8
- componentDidCatch(error) {
9
- this.handleError(error);
10
- }
11
- handleError(error) {
12
- this.setState({ error });
13
- }
14
- render() {
15
- if (this.state.error) {
16
- return <Text>{JSON.stringify(this.state.error, null, 2)}</Text>;
17
- }
18
- else {
19
- return this.props.children;
20
- }
21
- }
22
- }
23
- export default ErrorBoundary;
24
- //# sourceMappingURL=error_boundary.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"error_boundary.js","sourceRoot":"","sources":["../../src/components/error_boundary.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAA;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAEnC,MAAM,aAAc,SAAQ,KAAK,CAAC,SAAsD;IACtF,KAAK,GAAG;QACN,KAAK,EAAE,IAAI;QACX,YAAY,EAAE,GAAG,EAAE,GAAE,CAAC;KACvB,CAAA;IAED,iBAAiB,CAAC,KAAU;QAC1B,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;IACzB,CAAC;IAED,WAAW,CAAC,KAAU;QACpB,IAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;IAC1B,CAAC;IAED,MAAM;QACJ,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YACrB,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAA;QACjE,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAA;QAC5B,CAAC;IACH,CAAC;CACF;AAED,eAAe,aAAa,CAAA","sourcesContent":["import React, { PropsWithChildren } from 'react'\nimport { Text } from 'react-native'\n\nclass ErrorBoundary extends React.Component<PropsWithChildren<{ onReset?: () => void }>> {\n state = {\n error: null,\n unsubscriber: () => {},\n }\n\n componentDidCatch(error: any) {\n this.handleError(error)\n }\n\n handleError(error: any) {\n this.setState({ error })\n }\n\n render() {\n if (this.state.error) {\n return <Text>{JSON.stringify(this.state.error, null, 2)}</Text>\n } else {\n return this.props.children\n }\n }\n}\n\nexport default ErrorBoundary\n"]}
@@ -1,27 +0,0 @@
1
- import React, { PropsWithChildren } from 'react'
2
- import { Text } from 'react-native'
3
-
4
- class ErrorBoundary extends React.Component<PropsWithChildren<{ onReset?: () => void }>> {
5
- state = {
6
- error: null,
7
- unsubscriber: () => {},
8
- }
9
-
10
- componentDidCatch(error: any) {
11
- this.handleError(error)
12
- }
13
-
14
- handleError(error: any) {
15
- this.setState({ error })
16
- }
17
-
18
- render() {
19
- if (this.state.error) {
20
- return <Text>{JSON.stringify(this.state.error, null, 2)}</Text>
21
- } else {
22
- return this.props.children
23
- }
24
- }
25
- }
26
-
27
- export default ErrorBoundary