@planningcenter/chat-react-native 3.42.2-qa-staging.1 → 3.42.2-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 (46) hide show
  1. package/build/components/conversations/conversation_preview.d.ts.map +1 -1
  2. package/build/components/conversations/conversation_preview.js +12 -46
  3. package/build/components/conversations/conversation_preview.js.map +1 -1
  4. package/build/components/conversations/unread_count_badge.d.ts +1 -2
  5. package/build/components/conversations/unread_count_badge.d.ts.map +1 -1
  6. package/build/components/conversations/unread_count_badge.js +4 -5
  7. package/build/components/conversations/unread_count_badge.js.map +1 -1
  8. package/build/hooks/use_conversation.d.ts.map +1 -1
  9. package/build/hooks/use_conversation.js +0 -2
  10. package/build/hooks/use_conversation.js.map +1 -1
  11. package/build/hooks/use_conversation_jolt_events.d.ts.map +1 -1
  12. package/build/hooks/use_conversation_jolt_events.js +19 -4
  13. package/build/hooks/use_conversation_jolt_events.js.map +1 -1
  14. package/build/hooks/use_conversation_messages.d.ts +1 -0
  15. package/build/hooks/use_conversation_messages.d.ts.map +1 -1
  16. package/build/hooks/use_conversation_messages.js +2 -2
  17. package/build/hooks/use_conversation_messages.js.map +1 -1
  18. package/build/hooks/use_conversations_actions.d.ts.map +1 -1
  19. package/build/hooks/use_conversations_actions.js +1 -3
  20. package/build/hooks/use_conversations_actions.js.map +1 -1
  21. package/build/hooks/use_mark_latest_message_read.d.ts.map +1 -1
  22. package/build/hooks/use_mark_latest_message_read.js +4 -3
  23. package/build/hooks/use_mark_latest_message_read.js.map +1 -1
  24. package/build/screens/conversation_screen.d.ts.map +1 -1
  25. package/build/screens/conversation_screen.js +2 -2
  26. package/build/screens/conversation_screen.js.map +1 -1
  27. package/build/screens/conversations/components/list_header_component.js +1 -1
  28. package/build/screens/conversations/components/list_header_component.js.map +1 -1
  29. package/build/types/resources/conversation.d.ts +1 -10
  30. package/build/types/resources/conversation.d.ts.map +1 -1
  31. package/build/types/resources/conversation.js.map +1 -1
  32. package/build/utils/request/conversation.d.ts.map +1 -1
  33. package/build/utils/request/conversation.js +0 -2
  34. package/build/utils/request/conversation.js.map +1 -1
  35. package/package.json +3 -3
  36. package/src/components/conversations/conversation_preview.tsx +23 -58
  37. package/src/components/conversations/unread_count_badge.tsx +4 -13
  38. package/src/hooks/use_conversation.ts +0 -2
  39. package/src/hooks/use_conversation_jolt_events.ts +19 -3
  40. package/src/hooks/use_conversation_messages.ts +6 -5
  41. package/src/hooks/use_conversations_actions.ts +1 -3
  42. package/src/hooks/use_mark_latest_message_read.ts +4 -3
  43. package/src/screens/conversation_screen.tsx +4 -2
  44. package/src/screens/conversations/components/list_header_component.tsx +6 -6
  45. package/src/types/resources/conversation.ts +1 -11
  46. package/src/utils/request/conversation.ts +0 -2
@@ -63,7 +63,7 @@ export function useConversationJoltEvents({ conversationId }: Props) {
63
63
  data: {
64
64
  ...prev.data,
65
65
  latestReadMessageSortKey: latest_read_message_sort_key,
66
- unreadReaction: false,
66
+ unreadReactionCount: 0,
67
67
  },
68
68
  }
69
69
  })
@@ -87,9 +87,25 @@ export function useConversationJoltEvents({ conversationId }: Props) {
87
87
 
88
88
  const handleReactionJoltEvent = useCallback(
89
89
  (event: JoltReactionEvent) => {
90
- if (event.data.data.author_id === currentPersonId) return
90
+ queryClient.setQueryData<ApiResource<ConversationResource>>(queryKey, prev => {
91
+ if (!prev?.data) return prev
91
92
 
92
- queryClient.invalidateQueries({ queryKey })
93
+ if (event.data.data.author_id === currentPersonId) {
94
+ return prev
95
+ }
96
+
97
+ return {
98
+ ...prev,
99
+ data: {
100
+ ...prev.data,
101
+ // Not a real count, just a derived value from Jolt events so we can
102
+ // determine if we should mark the conversation as read
103
+ unreadReactionCount: prev.data.unreadReactionCount
104
+ ? prev.data.unreadReactionCount + 1
105
+ : 1,
106
+ },
107
+ }
108
+ })
93
109
  },
94
110
  [queryClient, queryKey, currentPersonId]
95
111
  )
@@ -7,10 +7,11 @@ export const useConversationMessages = (
7
7
  { conversation_id, reply_root_id }: { conversation_id: number; reply_root_id?: string | null },
8
8
  opts?: SuspensePaginatorOptions
9
9
  ) => {
10
- const { data, refetch, isRefetching, fetchNextPage } = useSuspensePaginator<MessageResource>(
11
- getMessagesRequestArgs({ conversation_id, reply_root_id }),
12
- opts
13
- )
10
+ const { data, refetch, isRefetching, fetchNextPage, hasNextPage } =
11
+ useSuspensePaginator<MessageResource>(
12
+ getMessagesRequestArgs({ conversation_id, reply_root_id }),
13
+ opts
14
+ )
14
15
  const queryKey = getMessagesQueryKey({ conversation_id, reply_root_id })
15
16
  const messages = useMemo(
16
17
  () =>
@@ -24,5 +25,5 @@ export const useConversationMessages = (
24
25
  [data]
25
26
  )
26
27
 
27
- return { messages, refetch, isRefetching, fetchNextPage, queryKey }
28
+ return { messages, refetch, isRefetching, fetchNextPage, hasNextPage, queryKey }
28
29
  }
@@ -20,7 +20,7 @@ export const useConversationsMarkRead = ({
20
20
  currentPersonCache.update({}, person => {
21
21
  const currentUnread = person.unreadCount
22
22
  const updatedUnread = read ? Math.max(currentUnread - 1, 0) : currentUnread + 1
23
- return { ...person, unreadCount: updatedUnread }
23
+ return { ...person, unreadCount: updatedUnread, unreadReactionCount: 0 }
24
24
  })
25
25
  }
26
26
 
@@ -29,7 +29,6 @@ export const useConversationsMarkRead = ({
29
29
  update({
30
30
  ...conversation,
31
31
  unreadCount: read ? 0 : 1,
32
- ...(read ? { unreadReaction: false } : {}),
33
32
  })
34
33
  handlePersonUnreadCount(read)
35
34
  },
@@ -107,7 +106,6 @@ export const useMarkAllRead = () => {
107
106
  onMutate: () => {
108
107
  updateAll({
109
108
  unreadCount: 0,
110
- unreadReaction: false,
111
109
  })
112
110
  },
113
111
  mutationKey: ['markAllRead', args],
@@ -17,9 +17,9 @@ export function useMarkLatestMessageRead({ conversation }: Props) {
17
17
  [markRead]
18
18
  )
19
19
  const unreadCount = conversation.unreadCount
20
- const unreadReaction = conversation.unreadReaction
20
+ const unreadReactionCount = conversation.unreadReactionCount || 0
21
21
 
22
- const shouldMarkRead = Boolean(unreadCount >= 1 || unreadReaction || !firedOnce.current)
22
+ const shouldMarkRead = Boolean(unreadCount >= 1 || unreadReactionCount > 0 || !firedOnce.current)
23
23
  const appState = useAppState()
24
24
  const isActive = appState === 'active'
25
25
 
@@ -29,5 +29,6 @@ export function useMarkLatestMessageRead({ conversation }: Props) {
29
29
  firedOnce.current = true
30
30
 
31
31
  debouncedMarkRead(true)
32
- }, [debouncedMarkRead, isActive, shouldMarkRead, unreadReaction])
32
+ // keeping unreadReactionCount in the dependency array to watch for changes
33
+ }, [debouncedMarkRead, isActive, shouldMarkRead, unreadReactionCount])
33
34
  }
@@ -89,7 +89,7 @@ function ConversationScreenContent({ route }: ConversationScreenProps) {
89
89
  const { conversation_id, editing_message_id, reply_root_id, reply_root_author_name } =
90
90
  route.params
91
91
  const { data: conversation } = useConversation(route.params)
92
- const { messages, fetchNextPage } = useConversationMessages({
92
+ const { messages, fetchNextPage, hasNextPage } = useConversationMessages({
93
93
  conversation_id,
94
94
  reply_root_id,
95
95
  })
@@ -181,7 +181,9 @@ function ConversationScreenContent({ route }: ConversationScreenProps) {
181
181
  onScroll={trackScroll}
182
182
  scrollEventThrottle={10}
183
183
  ListFooterComponent={
184
- <ConversationStartBanner conversation={conversation} hasMessages={true} />
184
+ hasNextPage ? null : (
185
+ <ConversationStartBanner conversation={conversation} hasMessages={true} />
186
+ )
185
187
  }
186
188
  renderItem={({ item }) => {
187
189
  if (item.type === 'DateSeparator') {
@@ -158,6 +158,12 @@ export const ListHeaderComponent = () => {
158
158
  </TextButton>
159
159
  </View>
160
160
  <View style={styles.actionsContainer}>
161
+ <ListHeaderActionButton
162
+ name="general.cog"
163
+ onPress={handleChatSettings}
164
+ accessibilityLabel="Chat settings"
165
+ maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER_LANDMARK}
166
+ />
161
167
  {canCreateConversations && (
162
168
  <ListHeaderActionButton
163
169
  name="churchCenter.signups"
@@ -167,12 +173,6 @@ export const ListHeaderComponent = () => {
167
173
  maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER_LANDMARK}
168
174
  />
169
175
  )}
170
- <ListHeaderActionButton
171
- name="general.cog"
172
- onPress={handleChatSettings}
173
- accessibilityLabel="Chat settings"
174
- maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER_LANDMARK}
175
- />
176
176
  {shouldShowHeaderFiltersButton && <ToggleButton {...moreFiltersButtonProps} />}
177
177
  </View>
178
178
  </View>
@@ -3,25 +3,15 @@ import { ConversationBadgeResource } from './conversation_badge'
3
3
  import { ConversationMembershipResource } from './conversation_membership'
4
4
  import { GroupResource } from './group_resource'
5
5
  import { MemberAbilityResource } from './member_ability'
6
- import { ReactionCountResource } from './reaction'
7
6
 
8
7
  export type ConversationDisabledReason = 'safety_check' | 'direct_messages_disabled'
9
8
 
10
- export interface ConversationPreviewData {
11
- kind: 'reaction' | 'message'
12
- authorName: string
13
- value: ReactionCountResource['value'] | null
14
- text: string
15
- createdAt: string
16
- }
17
-
18
9
  export interface ConversationResource {
19
10
  type: 'Conversation'
20
11
  id: number
21
12
  badges?: ConversationBadgeResource[]
22
13
  analyticsMetadata?: AnalyticsMetadataResource
23
14
  conversationMembership?: Partial<ConversationMembershipResource>
24
- conversationPreview: ConversationPreviewData | null
25
15
  createdAt: string
26
16
  deleted?: boolean
27
17
  directMessage?: boolean
@@ -44,6 +34,6 @@ export interface ConversationResource {
44
34
  repliesDisabled: boolean
45
35
  title: string
46
36
  unreadCount: number
47
- unreadReaction: boolean
37
+ unreadReactionCount?: number // Derived from Jolt events
48
38
  updatedAt: string
49
39
  }
@@ -38,7 +38,6 @@ export const getConversationsRequestArgs = ({
38
38
  Conversation: [
39
39
  'created_at',
40
40
  'badges',
41
- 'conversation_preview',
42
41
  'disabled',
43
42
  'disabled_reason',
44
43
  'groups',
@@ -56,7 +55,6 @@ export const getConversationsRequestArgs = ({
56
55
  'replies_disabled',
57
56
  'title',
58
57
  'unread_count',
59
- 'unread_reaction',
60
58
  'updated_at',
61
59
  ],
62
60
  AnalyticsMetadata: ['metadata'],