@planningcenter/chat-react-native 3.18.0-rc.4 → 3.18.0-rc.5

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/conversation/message.d.ts +2 -1
  2. package/build/components/conversation/message.d.ts.map +1 -1
  3. package/build/components/conversation/message.js +5 -5
  4. package/build/components/conversation/message.js.map +1 -1
  5. package/build/components/conversation/message_form.js +5 -2
  6. package/build/components/conversation/message_form.js.map +1 -1
  7. package/build/components/conversation/reply_connectors.d.ts.map +1 -1
  8. package/build/components/conversation/reply_connectors.js +0 -5
  9. package/build/components/conversation/reply_connectors.js.map +1 -1
  10. package/build/hooks/use_features.d.ts +9 -0
  11. package/build/hooks/use_features.d.ts.map +1 -0
  12. package/build/hooks/use_features.js +35 -0
  13. package/build/hooks/use_features.js.map +1 -0
  14. package/build/screens/conversation_screen.d.ts +2 -1
  15. package/build/screens/conversation_screen.d.ts.map +1 -1
  16. package/build/screens/conversation_screen.js +12 -6
  17. package/build/screens/conversation_screen.js.map +1 -1
  18. package/build/screens/message_actions_screen.js +4 -2
  19. package/build/screens/message_actions_screen.js.map +1 -1
  20. package/build/types/resources/feature_resource.d.ts +7 -0
  21. package/build/types/resources/feature_resource.d.ts.map +1 -0
  22. package/build/types/resources/feature_resource.js +2 -0
  23. package/build/types/resources/feature_resource.js.map +1 -0
  24. package/build/utils/index.d.ts +0 -1
  25. package/build/utils/index.d.ts.map +1 -1
  26. package/build/utils/index.js +0 -1
  27. package/build/utils/index.js.map +1 -1
  28. package/build/utils/request/get_features.d.ts +11 -0
  29. package/build/utils/request/get_features.d.ts.map +1 -0
  30. package/build/utils/request/get_features.js +18 -0
  31. package/build/utils/request/get_features.js.map +1 -0
  32. package/package.json +2 -2
  33. package/src/components/conversation/message.tsx +8 -4
  34. package/src/components/conversation/message_form.tsx +4 -2
  35. package/src/components/conversation/reply_connectors.tsx +0 -3
  36. package/src/hooks/use_features.ts +47 -0
  37. package/src/screens/conversation_screen.tsx +17 -5
  38. package/src/screens/message_actions_screen.tsx +4 -2
  39. package/src/types/resources/feature_resource.ts +6 -0
  40. package/src/utils/index.ts +0 -1
  41. package/src/utils/request/get_features.ts +20 -0
  42. package/build/utils/replies_local_feature_flag.d.ts +0 -2
  43. package/build/utils/replies_local_feature_flag.d.ts.map +0 -1
  44. package/build/utils/replies_local_feature_flag.js +0 -3
  45. package/build/utils/replies_local_feature_flag.js.map +0 -1
  46. package/src/utils/replies_local_feature_flag.ts +0 -2
@@ -35,7 +35,7 @@ import { CONVERSATION_MESSAGE_LIST_PADDING_HORIZONTAL } from '../utils/styles'
35
35
  import { useConversationJoltEvents } from '../hooks/use_conversation_jolt_events'
36
36
  import { JumpToBottomButton } from '../components/conversation/jump_to_bottom_button'
37
37
  import { ReplyShadowMessage } from '../components/conversation/reply_shadow_message'
38
- import { REPLIES_FEATURE_ENABLED } from '../utils'
38
+ import { availableFeatures, useFeatures } from '../hooks/use_features'
39
39
 
40
40
  export type ConversationRouteProps = {
41
41
  conversation_id: number
@@ -66,7 +66,13 @@ export function ConversationScreen({ route }: ConversationScreenProps) {
66
66
  useConversationMessagesJoltEvents({ conversationId: conversation_id })
67
67
  useEnsureConversationsRouteExists()
68
68
  useMarkLatestMessageRead({ conversation, messages })
69
- const messagesWithSeparators = groupMessages({ ms: messages, inReplyScreen: !!reply_root_id })
69
+ const { featureEnabled } = useFeatures()
70
+ const repliesEnabled = featureEnabled(availableFeatures.threaded_replies)
71
+ const messagesWithSeparators = groupMessages({
72
+ ms: messages,
73
+ inReplyScreen: !!reply_root_id,
74
+ repliesEnabled,
75
+ })
70
76
  const noMessages = messagesWithSeparators.length === 0
71
77
 
72
78
  const { repliesDisabled, memberAbility, badges, title } = conversation
@@ -164,6 +170,7 @@ export function ConversationScreen({ route }: ConversationScreenProps) {
164
170
  conversation_id={conversation_id}
165
171
  latestReadMessageSortKey={conversation?.latestReadMessageSortKey}
166
172
  inReplyScreen={!!reply_root_id}
173
+ repliesEnabled={repliesEnabled}
167
174
  />
168
175
  )
169
176
  }}
@@ -252,9 +259,14 @@ type ReplyShadowMessage = {
252
259
  interface GroupMessagesProps {
253
260
  ms: MessageResource[]
254
261
  inReplyScreen?: boolean
262
+ repliesEnabled?: boolean
255
263
  }
256
264
 
257
- export const groupMessages = ({ ms, inReplyScreen }: GroupMessagesProps) => {
265
+ export const groupMessages = ({
266
+ ms,
267
+ inReplyScreen,
268
+ repliesEnabled = false,
269
+ }: GroupMessagesProps) => {
258
270
  let enrichedMessages: (MessageResource | DateSeparator | ReplyShadowMessage)[] = []
259
271
  let encounteredOneOfMyMessages = false
260
272
 
@@ -298,7 +310,7 @@ export const groupMessages = ({ ms, inReplyScreen }: GroupMessagesProps) => {
298
310
  message.nextRendersAuthor = nextMessage?.renderAuthor
299
311
  message.isReplyShadowMessage = false
300
312
  message.nextIsReplyShadowMessage =
301
- REPLIES_FEATURE_ENABLED &&
313
+ repliesEnabled &&
302
314
  nextMessageInThread &&
303
315
  !nextMessageThreadRoot &&
304
316
  (nextMessageDifferentThread || nextMessageIsDateSeparator)
@@ -319,7 +331,7 @@ export const groupMessages = ({ ms, inReplyScreen }: GroupMessagesProps) => {
319
331
 
320
332
  enrichedMessages.push(message)
321
333
 
322
- if (insertReplyShadowMessage && REPLIES_FEATURE_ENABLED) {
334
+ if (insertReplyShadowMessage && repliesEnabled) {
323
335
  enrichedMessages.push({
324
336
  type: 'ReplyShadowMessage',
325
337
  id: `${message.id}-${message.replyRootId}`,
@@ -14,7 +14,7 @@ import { useMessageReactionToggle } from '../hooks/use_message_reaction_toggle'
14
14
  import { ReactionCountResource } from '../types/resources/reaction'
15
15
  import { Clipboard, Haptic } from '../utils/native_adapters'
16
16
  import { MessageResource } from '../types'
17
- import { REPLIES_FEATURE_ENABLED } from '../utils'
17
+ import { availableFeatures, useFeatures } from '../hooks/use_features'
18
18
 
19
19
  export const MessageActionsScreenOptions = getFormSheetScreenOptions({
20
20
  sheetAllowedDetents: [0.5],
@@ -76,6 +76,8 @@ function MessageActionsScreenContent({
76
76
  const navigation = useNavigation()
77
77
  const apiClient = useApiClient()
78
78
  const styles = useStyles()
79
+ const { featureEnabled } = useFeatures()
80
+ const repliesEnabled = featureEnabled(availableFeatures.threaded_replies)
79
81
 
80
82
  const myReactions = message?.reactionCounts
81
83
  .filter(reaction => reaction.mine)
@@ -190,7 +192,7 @@ function MessageActionsScreenContent({
190
192
  ))}
191
193
  </View>
192
194
  <View style={styles.actions}>
193
- {REPLIES_FEATURE_ENABLED && !inReplyScreen && (
195
+ {repliesEnabled && !inReplyScreen && (
194
196
  <FormSheet.Action
195
197
  onPress={handleReplyPress}
196
198
  title="Reply to message"
@@ -0,0 +1,6 @@
1
+ export interface FeatureResource {
2
+ type: 'Feature'
3
+ id: string
4
+ name: string
5
+ enabled: boolean
6
+ }
@@ -9,4 +9,3 @@ export * from './pluralize'
9
9
  export * from './destructure_chat_group_graph_id'
10
10
  export * from './convert_attachments_for_create'
11
11
  export * from './assert_keys_are_numbers'
12
- export * from './replies_local_feature_flag'
@@ -0,0 +1,20 @@
1
+ import { getRequestQueryKey } from '../../hooks/use_suspense_api'
2
+
3
+ export const getFeaturesRequestArgs = () => {
4
+ const url = '/me/features'
5
+
6
+ return {
7
+ url,
8
+ data: {
9
+ perPage: 100,
10
+ fields: {
11
+ Feature: ['name', 'enabled'],
12
+ },
13
+ },
14
+ }
15
+ }
16
+
17
+ export const getFeaturesQueryKey = () => {
18
+ const requestArgs = getFeaturesRequestArgs()
19
+ return getRequestQueryKey(requestArgs)
20
+ }
@@ -1,2 +0,0 @@
1
- export declare const REPLIES_FEATURE_ENABLED = false;
2
- //# sourceMappingURL=replies_local_feature_flag.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"replies_local_feature_flag.d.ts","sourceRoot":"","sources":["../../src/utils/replies_local_feature_flag.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,uBAAuB,QAAQ,CAAA"}
@@ -1,3 +0,0 @@
1
- // TODO: Replace this whole file with the flipper flag
2
- export const REPLIES_FEATURE_ENABLED = false;
3
- //# sourceMappingURL=replies_local_feature_flag.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"replies_local_feature_flag.js","sourceRoot":"","sources":["../../src/utils/replies_local_feature_flag.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,CAAA","sourcesContent":["// TODO: Replace this whole file with the flipper flag\nexport const REPLIES_FEATURE_ENABLED = false\n"]}
@@ -1,2 +0,0 @@
1
- // TODO: Replace this whole file with the flipper flag
2
- export const REPLIES_FEATURE_ENABLED = false