@planningcenter/chat-react-native 4.5.1-qa-staging.12 → 4.5.1-qa-staging.14

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 (116) hide show
  1. package/build/components/conversation/message.d.ts.map +1 -1
  2. package/build/components/conversation/message.js +73 -64
  3. package/build/components/conversation/message.js.map +1 -1
  4. package/build/components/conversation/message_list.d.ts.map +1 -1
  5. package/build/components/conversation/message_list.js +106 -89
  6. package/build/components/conversation/message_list.js.map +1 -1
  7. package/build/components/conversation/pinned_messages_bar.d.ts +4 -0
  8. package/build/components/conversation/pinned_messages_bar.d.ts.map +1 -0
  9. package/build/components/conversation/pinned_messages_bar.js +188 -0
  10. package/build/components/conversation/pinned_messages_bar.js.map +1 -0
  11. package/build/components/conversation/pinned_tag.d.ts +5 -0
  12. package/build/components/conversation/pinned_tag.d.ts.map +1 -0
  13. package/build/components/conversation/pinned_tag.js +89 -0
  14. package/build/components/conversation/pinned_tag.js.map +1 -0
  15. package/build/hooks/use_conversation.d.ts.map +1 -1
  16. package/build/hooks/use_conversation.js +1 -1
  17. package/build/hooks/use_conversation.js.map +1 -1
  18. package/build/hooks/use_conversation_messages_jolt_events.d.ts.map +1 -1
  19. package/build/hooks/use_conversation_messages_jolt_events.js +89 -52
  20. package/build/hooks/use_conversation_messages_jolt_events.js.map +1 -1
  21. package/build/hooks/use_features.d.ts +1 -0
  22. package/build/hooks/use_features.d.ts.map +1 -1
  23. package/build/hooks/use_features.js +1 -0
  24. package/build/hooks/use_features.js.map +1 -1
  25. package/build/hooks/use_message_pin.d.ts +11 -0
  26. package/build/hooks/use_message_pin.d.ts.map +1 -0
  27. package/build/hooks/use_message_pin.js +189 -0
  28. package/build/hooks/use_message_pin.js.map +1 -0
  29. package/build/hooks/use_pinned_messages.d.ts +8 -0
  30. package/build/hooks/use_pinned_messages.d.ts.map +1 -0
  31. package/build/hooks/use_pinned_messages.js +70 -0
  32. package/build/hooks/use_pinned_messages.js.map +1 -0
  33. package/build/icons/font_awesome.js +6 -6
  34. package/build/icons/font_awesome.js.map +1 -1
  35. package/build/navigation/index.d.ts +5 -0
  36. package/build/navigation/index.d.ts.map +1 -1
  37. package/build/navigation/index.js +5 -0
  38. package/build/navigation/index.js.map +1 -1
  39. package/build/screens/avatar_picker/constants.d.ts.map +1 -1
  40. package/build/screens/avatar_picker/constants.js +5 -3
  41. package/build/screens/avatar_picker/constants.js.map +1 -1
  42. package/build/screens/conversation/pinned_messages_screen.d.ts +7 -0
  43. package/build/screens/conversation/pinned_messages_screen.d.ts.map +1 -0
  44. package/build/screens/conversation/pinned_messages_screen.js +372 -0
  45. package/build/screens/conversation/pinned_messages_screen.js.map +1 -0
  46. package/build/screens/conversation_screen.d.ts.map +1 -1
  47. package/build/screens/conversation_screen.js +102 -88
  48. package/build/screens/conversation_screen.js.map +1 -1
  49. package/build/screens/design_system_screen.js +6 -3
  50. package/build/screens/design_system_screen.js.map +1 -1
  51. package/build/screens/message_actions_screen.d.ts.map +1 -1
  52. package/build/screens/message_actions_screen.js +135 -57
  53. package/build/screens/message_actions_screen.js.map +1 -1
  54. package/build/types/jolt_events/index.d.ts +4 -2
  55. package/build/types/jolt_events/index.d.ts.map +1 -1
  56. package/build/types/jolt_events/index.js.map +1 -1
  57. package/build/types/jolt_events/pin_events.d.ts +19 -0
  58. package/build/types/jolt_events/pin_events.d.ts.map +1 -0
  59. package/build/types/jolt_events/pin_events.js +2 -0
  60. package/build/types/jolt_events/pin_events.js.map +1 -0
  61. package/build/types/resources/member_ability.d.ts +1 -0
  62. package/build/types/resources/member_ability.d.ts.map +1 -1
  63. package/build/types/resources/member_ability.js.map +1 -1
  64. package/build/types/resources/message.d.ts +2 -0
  65. package/build/types/resources/message.d.ts.map +1 -1
  66. package/build/types/resources/message.js.map +1 -1
  67. package/build/utils/cache/messages_cache.d.ts +1 -0
  68. package/build/utils/cache/messages_cache.d.ts.map +1 -1
  69. package/build/utils/cache/messages_cache.js +19 -0
  70. package/build/utils/cache/messages_cache.js.map +1 -1
  71. package/build/utils/pinned_message_preview.d.ts +3 -0
  72. package/build/utils/pinned_message_preview.d.ts.map +1 -0
  73. package/build/utils/pinned_message_preview.js +7 -0
  74. package/build/utils/pinned_message_preview.js.map +1 -0
  75. package/build/utils/request/get_pinned_messages.d.ts +18 -0
  76. package/build/utils/request/get_pinned_messages.d.ts.map +1 -0
  77. package/build/utils/request/get_pinned_messages.js +18 -0
  78. package/build/utils/request/get_pinned_messages.js.map +1 -0
  79. package/build/utils/request/messages_data_options.d.ts.map +1 -1
  80. package/build/utils/request/messages_data_options.js +1 -1
  81. package/build/utils/request/messages_data_options.js.map +1 -1
  82. package/build/vendor/font_awesome_pro_solid_icons.d.ts +6 -6
  83. package/build/vendor/font_awesome_pro_solid_icons.d.ts.map +1 -1
  84. package/build/vendor/font_awesome_pro_solid_icons.js +6 -6
  85. package/build/vendor/font_awesome_pro_solid_icons.js.map +1 -1
  86. package/package.json +3 -3
  87. package/src/__tests__/hooks/use_message_pin.test.tsx +107 -0
  88. package/src/__tests__/hooks/use_pinned_messages.test.tsx +46 -0
  89. package/src/__tests__/utils/update_cache_with_pin.test.ts +54 -0
  90. package/src/components/conversation/__tests__/pinned_messages_bar.test.tsx +62 -0
  91. package/src/components/conversation/message.tsx +9 -1
  92. package/src/components/conversation/message_list.tsx +17 -4
  93. package/src/components/conversation/pinned_messages_bar.tsx +64 -0
  94. package/src/components/conversation/pinned_tag.tsx +32 -0
  95. package/src/hooks/use_conversation.ts +1 -0
  96. package/src/hooks/use_conversation_messages_jolt_events.ts +19 -1
  97. package/src/hooks/use_features.ts +1 -0
  98. package/src/hooks/use_message_pin.ts +86 -0
  99. package/src/hooks/use_pinned_messages.ts +16 -0
  100. package/src/icons/font_awesome.ts +12 -12
  101. package/src/navigation/index.tsx +8 -0
  102. package/src/screens/avatar_picker/__tests__/constants.test.ts +16 -0
  103. package/src/screens/avatar_picker/constants.ts +11 -6
  104. package/src/screens/conversation/pinned_messages_screen.tsx +155 -0
  105. package/src/screens/conversation_screen.tsx +3 -0
  106. package/src/screens/design_system_screen.tsx +10 -6
  107. package/src/screens/message_actions_screen.tsx +38 -0
  108. package/src/types/jolt_events/index.ts +4 -1
  109. package/src/types/jolt_events/pin_events.ts +20 -0
  110. package/src/types/resources/member_ability.ts +1 -0
  111. package/src/types/resources/message.ts +2 -0
  112. package/src/utils/cache/messages_cache.ts +22 -0
  113. package/src/utils/pinned_message_preview.ts +9 -0
  114. package/src/utils/request/get_pinned_messages.ts +19 -0
  115. package/src/utils/request/messages_data_options.ts +2 -0
  116. package/src/vendor/font_awesome_pro_solid_icons.ts +6 -6
@@ -5,9 +5,9 @@ import {
5
5
  faChurch,
6
6
  faCross,
7
7
  faDove,
8
- faHandsHeart,
8
+ faHandsHoldingHeart,
9
9
  faPersonRays,
10
- faPrayingHands,
10
+ faHandsPraying,
11
11
  faPodium,
12
12
  faDroplet,
13
13
  faPersonDrowning,
@@ -22,13 +22,13 @@ import {
22
22
  faBaby,
23
23
  faChildren,
24
24
  faMugHot,
25
- faVideoCamera,
25
+ faVideo,
26
26
  faMusic,
27
27
  faPianoKeyboard,
28
28
  faDrum,
29
29
  faUserGraduate,
30
30
  faCommentsQuestion,
31
- faPresentation,
31
+ faPresentationScreen,
32
32
  faMicrophoneStand,
33
33
  faIdBadge,
34
34
  faBookUser,
@@ -44,10 +44,10 @@ import {
44
44
  faPersonDress,
45
45
  faPerson,
46
46
  faSeedling,
47
- faCommentsAlt,
47
+ faMessages,
48
48
  faGlobe,
49
49
  faBookOpenReader,
50
- faRunning,
50
+ faPersonRunning,
51
51
  faLeaf,
52
52
  // General
53
53
  faPlateUtensils,
@@ -62,9 +62,9 @@ library.add(
62
62
  faChurch,
63
63
  faCross,
64
64
  faDove,
65
- faHandsHeart,
65
+ faHandsHoldingHeart,
66
66
  faPersonRays,
67
- faPrayingHands,
67
+ faHandsPraying,
68
68
  faPodium,
69
69
  faDroplet,
70
70
  faPersonDrowning,
@@ -79,13 +79,13 @@ library.add(
79
79
  faBaby,
80
80
  faChildren,
81
81
  faMugHot,
82
- faVideoCamera,
82
+ faVideo,
83
83
  faMusic,
84
84
  faPianoKeyboard,
85
85
  faDrum,
86
86
  faUserGraduate,
87
87
  faCommentsQuestion,
88
- faPresentation,
88
+ faPresentationScreen,
89
89
  faMicrophoneStand,
90
90
  faIdBadge,
91
91
  faBookUser,
@@ -101,10 +101,10 @@ library.add(
101
101
  faPersonDress,
102
102
  faPerson,
103
103
  faSeedling,
104
- faCommentsAlt,
104
+ faMessages,
105
105
  faGlobe,
106
106
  faBookOpenReader,
107
- faRunning,
107
+ faPersonRunning,
108
108
  faLeaf,
109
109
  // General
110
110
  faPlateUtensils,
@@ -27,6 +27,10 @@ import {
27
27
  MessageReadReceiptsScreen,
28
28
  MessageReadReceiptsScreenOptions,
29
29
  } from '../screens/conversation/message_read_receipts_screen'
30
+ import {
31
+ PinnedMessagesScreen,
32
+ PinnedMessagesScreenOptions,
33
+ } from '../screens/conversation/pinned_messages_screen'
30
34
  import { ConversationDetailsScreen } from '../screens/conversation_details_screen'
31
35
  import {
32
36
  ConversationFilterReceipientsScreenOptions,
@@ -366,6 +370,10 @@ export const ChatStack = createNativeStackNavigator({
366
370
  screen: MessageReadReceiptsScreen,
367
371
  options: MessageReadReceiptsScreenOptions,
368
372
  },
373
+ PinnedMessages: {
374
+ screen: PinnedMessagesScreen,
375
+ options: PinnedMessagesScreenOptions,
376
+ },
369
377
  BugReport: {
370
378
  screen: BugReportScreen,
371
379
  options: BugReportScreenOptions,
@@ -0,0 +1,16 @@
1
+ import * as vendoredIcons from '../../../vendor/font_awesome_pro_solid_icons'
2
+ import { AVATAR_ICON_KEYS } from '../constants'
3
+
4
+ const canonicalIconNames: string[] = Object.values(vendoredIcons).map(icon => icon.iconName)
5
+
6
+ describe('AVATAR_ICON_KEYS', () => {
7
+ it('only offers canonical icon names, never Font Awesome aliases', () => {
8
+ const aliases = AVATAR_ICON_KEYS.filter(key => !canonicalIconNames.includes(key))
9
+
10
+ expect(aliases).toEqual([])
11
+ })
12
+
13
+ it('has no duplicates', () => {
14
+ expect(new Set(AVATAR_ICON_KEYS).size).toBe(AVATAR_ICON_KEYS.length)
15
+ })
16
+ })
@@ -4,9 +4,9 @@ export const AVATAR_ICON_KEYS: string[] = [
4
4
  'church',
5
5
  'cross',
6
6
  'dove',
7
- 'hands-heart',
7
+ 'hands-holding-heart',
8
8
  'person-rays',
9
- 'praying-hands',
9
+ 'hands-praying',
10
10
  'podium',
11
11
  'droplet',
12
12
  'person-drowning',
@@ -21,13 +21,13 @@ export const AVATAR_ICON_KEYS: string[] = [
21
21
  'baby',
22
22
  'children',
23
23
  'mug-hot',
24
- 'video-camera',
24
+ 'video',
25
25
  'music',
26
26
  'piano-keyboard',
27
27
  'drum',
28
28
  'user-graduate',
29
29
  'comments-question',
30
- 'presentation',
30
+ 'presentation-screen',
31
31
  'microphone-stand',
32
32
  'id-badge',
33
33
  'book-user',
@@ -43,11 +43,16 @@ export const AVATAR_ICON_KEYS: string[] = [
43
43
  'person-dress',
44
44
  'person',
45
45
  'seedling',
46
- 'comments-alt',
46
+ 'messages',
47
47
  'globe',
48
48
  'book-open-reader',
49
- 'running',
49
+ 'person-running',
50
50
  'leaf',
51
+ // General
52
+ 'plate-utensils',
53
+ 'bullhorn',
54
+ 'car',
55
+ 'tag',
51
56
  ]
52
57
 
53
58
  export const GRID_COLUMNS = 6
@@ -0,0 +1,155 @@
1
+ import { PlatformPressable } from '@react-navigation/elements'
2
+ import { StackActions, StaticScreenProps, useNavigation } from '@react-navigation/native'
3
+ import { isNil, omitBy } from 'lodash'
4
+ import React, { useCallback, useMemo, useState } from 'react'
5
+ import { LayoutChangeEvent, Platform, StyleSheet, View } from 'react-native'
6
+ import { FlatList } from 'react-native-gesture-handler'
7
+ import { useSafeAreaInsets } from 'react-native-safe-area-context'
8
+ import { Icon, Text } from '../../components'
9
+ import FormSheet, { getFormSheetScreenOptions } from '../../components/primitive/form_sheet'
10
+ import { useTheme } from '../../hooks'
11
+ import { usePinnedMessages } from '../../hooks/use_pinned_messages'
12
+ import { MessageResource } from '../../types'
13
+ import { pinnedMessagePreview } from '../../utils/pinned_message_preview'
14
+ import { pluralize } from '../../utils/pluralize'
15
+
16
+ const LIST_BOTTOM_PADDING = 24
17
+
18
+ export const PinnedMessagesScreenOptions = getFormSheetScreenOptions({
19
+ sheetAllowedDetents: Platform.select({
20
+ android: [0.5, 0.94],
21
+ default: [0.5, 1],
22
+ }),
23
+ headerTitle: 'Pinned',
24
+ })
25
+
26
+ export type PinnedMessagesScreenProps = StaticScreenProps<{
27
+ conversation_id: number
28
+ }>
29
+
30
+ export function PinnedMessagesScreen({ route }: PinnedMessagesScreenProps) {
31
+ const styles = useStyles()
32
+ const navigation = useNavigation()
33
+ const [formSheetHeaderHeight, setFormSheetHeaderHeight] = useState(0)
34
+ const { bottom } = useSafeAreaInsets()
35
+ const { conversation_id } = route.params
36
+ const { pinnedMessages } = usePinnedMessages({ conversation_id })
37
+
38
+ const contentContainerPaddingBottomStyles = useMemo(() => {
39
+ return Platform.select({
40
+ android: { paddingBottom: bottom + LIST_BOTTOM_PADDING },
41
+ default: { paddingBottom: bottom + formSheetHeaderHeight + LIST_BOTTOM_PADDING },
42
+ })
43
+ }, [bottom, formSheetHeaderHeight])
44
+
45
+ const handleFormSheetHeaderLayout = useCallback((event: LayoutChangeEvent) => {
46
+ setFormSheetHeaderHeight(event.nativeEvent.layout.height)
47
+ }, [])
48
+
49
+ const jumpToMessage = useCallback(
50
+ (message: MessageResource) => {
51
+ const conversationRoute = navigation
52
+ .getState?.()
53
+ ?.routes?.find(r => r.name === 'Conversation')
54
+ const params = omitBy(
55
+ {
56
+ ...(conversationRoute?.params || {}),
57
+ conversation_id,
58
+ initial_message_id: message.id,
59
+ },
60
+ isNil
61
+ )
62
+ navigation.dispatch(StackActions.popTo('Conversation', params))
63
+ },
64
+ [navigation, conversation_id]
65
+ )
66
+
67
+ return (
68
+ <FormSheet.Root>
69
+ <View onLayout={handleFormSheetHeaderLayout}>
70
+ <FormSheet.Header>
71
+ <FormSheet.HeaderTitle>
72
+ Pinned ({pluralize(pinnedMessages.length, 'item')})
73
+ </FormSheet.HeaderTitle>
74
+ <FormSheet.HeaderActions>
75
+ <FormSheet.HeaderTextButton onPress={() => navigation.goBack()}>
76
+ Close
77
+ </FormSheet.HeaderTextButton>
78
+ </FormSheet.HeaderActions>
79
+ </FormSheet.Header>
80
+ </View>
81
+ <FlatList
82
+ data={pinnedMessages}
83
+ contentContainerStyle={[styles.contentContainer, contentContainerPaddingBottomStyles]}
84
+ keyExtractor={item => item.id}
85
+ renderItem={({ item }) => <PinnedMessageRow message={item} onPress={jumpToMessage} />}
86
+ nestedScrollEnabled
87
+ ListEmptyComponent={<Text style={styles.emptyText}>Nothing is pinned yet.</Text>}
88
+ />
89
+ </FormSheet.Root>
90
+ )
91
+ }
92
+
93
+ const PinnedMessageRow = ({
94
+ message,
95
+ onPress,
96
+ }: {
97
+ message: MessageResource
98
+ onPress: (message: MessageResource) => void
99
+ }) => {
100
+ const styles = useStyles()
101
+ const { colors } = useTheme()
102
+ const from = message.mine ? 'you' : message.author?.name || 'a deleted user'
103
+
104
+ return (
105
+ <PlatformPressable
106
+ testID={`pinned-message-${message.id}`}
107
+ style={styles.row}
108
+ accessibilityRole="button"
109
+ accessibilityHint="Jumps to this message in the conversation"
110
+ onPress={() => onPress(message)}
111
+ >
112
+ <Icon name="services.pin" size={18} color={colors.iconColorDefaultSecondary} />
113
+ <View style={styles.rowText}>
114
+ <Text numberOfLines={2} style={styles.preview}>
115
+ {pinnedMessagePreview(message)}
116
+ </Text>
117
+ <Text variant="footnote">Message from {from}</Text>
118
+ </View>
119
+ <Icon name="general.rightChevron" size={14} color={colors.iconColorDefaultSecondary} />
120
+ </PlatformPressable>
121
+ )
122
+ }
123
+
124
+ const useStyles = () => {
125
+ const { colors } = useTheme()
126
+
127
+ return StyleSheet.create({
128
+ contentContainer: {
129
+ paddingTop: 8,
130
+ },
131
+ row: {
132
+ flexDirection: 'row',
133
+ alignItems: 'center',
134
+ gap: 12,
135
+ paddingHorizontal: 16,
136
+ paddingVertical: 12,
137
+ borderBottomWidth: 1,
138
+ borderBottomColor: colors.borderColorDefaultBase,
139
+ },
140
+ rowText: {
141
+ flex: 1,
142
+ minWidth: 0,
143
+ gap: 2,
144
+ },
145
+ preview: {
146
+ fontWeight: '500',
147
+ },
148
+ emptyText: {
149
+ textAlign: 'center',
150
+ color: colors.textColorDefaultSecondary,
151
+ marginTop: 32,
152
+ fontSize: 16,
153
+ },
154
+ })
155
+ }
@@ -20,6 +20,7 @@ import {
20
20
  LeaderMessagesDisabledBanner,
21
21
  MemberMessagesDisabledBanner,
22
22
  } from '../components/conversation/messages_disabled_banners'
23
+ import { PinnedMessagesBar } from '../components/conversation/pinned_messages_bar'
23
24
  import { TypingIndicator } from '../components/conversation/typing_indicator'
24
25
  import { KeyboardView } from '../components/display/keyboard_view'
25
26
  import { useHeaderSlotReserve } from '../components/display/platform_modal_header_buttons'
@@ -170,6 +171,7 @@ function ConversationScreenContent({ route }: ConversationScreenProps) {
170
171
  useEffect(() => {
171
172
  if (!initial_message_id) return
172
173
 
174
+ setAnchorMessageId(initial_message_id)
173
175
  navigation.setParams({ initial_message_id: null })
174
176
  }, [initial_message_id, navigation])
175
177
 
@@ -201,6 +203,7 @@ function ConversationScreenContent({ route }: ConversationScreenProps) {
201
203
  return (
202
204
  <View style={styles.container}>
203
205
  <KeyboardView>
206
+ {!reply_root_id && <PinnedMessagesBar conversationId={conversation_id} />}
204
207
  {noMessages ? (
205
208
  <View style={styles.emptyState}>
206
209
  <ConversationStartBanner conversation={conversation} hasMessages={false} />
@@ -1128,9 +1128,9 @@ const FA_ICONS: { category: string; icons: IconName[] }[] = [
1128
1128
  'church',
1129
1129
  'cross',
1130
1130
  'dove',
1131
- 'hands-heart',
1131
+ 'hands-holding-heart',
1132
1132
  'person-rays',
1133
- 'praying-hands',
1133
+ 'hands-praying',
1134
1134
  'podium',
1135
1135
  'droplet',
1136
1136
  'person-drowning',
@@ -1149,13 +1149,13 @@ const FA_ICONS: { category: string; icons: IconName[] }[] = [
1149
1149
  'baby',
1150
1150
  'children',
1151
1151
  'mug-hot',
1152
- 'video-camera',
1152
+ 'video',
1153
1153
  'music',
1154
1154
  'piano-keyboard',
1155
1155
  'drum',
1156
1156
  'user-graduate',
1157
1157
  'comments-question',
1158
- 'presentation',
1158
+ 'presentation-screen',
1159
1159
  'microphone-stand',
1160
1160
  'id-badge',
1161
1161
  'book-user',
@@ -1175,13 +1175,17 @@ const FA_ICONS: { category: string; icons: IconName[] }[] = [
1175
1175
  'person-dress',
1176
1176
  'person',
1177
1177
  'seedling',
1178
- 'comments-alt',
1178
+ 'messages',
1179
1179
  'globe',
1180
1180
  'book-open-reader',
1181
- 'running',
1181
+ 'person-running',
1182
1182
  'leaf',
1183
1183
  ],
1184
1184
  },
1185
+ {
1186
+ category: 'General',
1187
+ icons: ['plate-utensils', 'bullhorn', 'car', 'tag'],
1188
+ },
1185
1189
  ]
1186
1190
 
1187
1191
  function FontAwesomeIconsSection({ isLast }: SectionProps) {
@@ -12,6 +12,7 @@ import { useApiClient } from '../hooks/use_api_client'
12
12
  import { useConversation } from '../hooks/use_conversation'
13
13
  import { useConversationMessages } from '../hooks/use_conversation_messages'
14
14
  import { availableFeatures, useFeatures } from '../hooks/use_features'
15
+ import { useMessagePin } from '../hooks/use_message_pin'
15
16
  import { useMessageReactionToggle } from '../hooks/use_message_reaction_toggle'
16
17
  import { MessageResource } from '../types'
17
18
  import { ReactionCountResource } from '../types/resources/reaction'
@@ -61,6 +62,7 @@ export function MessageActionsScreen({ route }: MessageActionsScreenProps) {
61
62
  conversation_id={conversation_id}
62
63
  conversationDisabled={!!conversation.disabled}
63
64
  canDeleteNonAuthoredMessages={canDeleteNonAuthoredMessages || false}
65
+ canPinNonAuthoredMessages={!!conversation.memberAbility?.canPin}
64
66
  refetchMessages={refetch}
65
67
  inReplyScreen={inReplyScreen}
66
68
  replyRootAuthorName={reply_root_author_name}
@@ -74,6 +76,7 @@ function MessageActionsScreenContent({
74
76
  conversation_id,
75
77
  conversationDisabled,
76
78
  canDeleteNonAuthoredMessages,
79
+ canPinNonAuthoredMessages,
77
80
  refetchMessages,
78
81
  inReplyScreen,
79
82
  replyRootAuthorName,
@@ -83,6 +86,7 @@ function MessageActionsScreenContent({
83
86
  conversation_id: number
84
87
  conversationDisabled: boolean
85
88
  canDeleteNonAuthoredMessages: boolean
89
+ canPinNonAuthoredMessages: boolean
86
90
  refetchMessages: () => void
87
91
  inReplyScreen?: boolean
88
92
  replyRootAuthorName?: string
@@ -244,8 +248,28 @@ function MessageActionsScreenContent({
244
248
  ])
245
249
  }, [handleRemoveLinkPreview])
246
250
 
251
+ const { pin, unpin, isPinning, isUnpinning } = useMessagePin({ conversation_id, message })
252
+ const isPinned = !!message.pinnedAt
253
+
254
+ const handlePinPress = useCallback(() => {
255
+ pin()
256
+ navigation.goBack()
257
+ }, [pin, navigation])
258
+
259
+ const handleUnpinPress = useCallback(() => {
260
+ unpin()
261
+ navigation.goBack()
262
+ }, [unpin, navigation])
263
+
247
264
  const showReportMessageAction =
248
265
  !message?.mine && featureEnabled(availableFeatures.message_reporting)
266
+ const isThreadReply = !!message.replyRootId && message.replyRootId !== message.id
267
+ const showPinMessageAction =
268
+ !inReplyScreen &&
269
+ !isThreadReply &&
270
+ !conversationDisabled &&
271
+ featureEnabled(availableFeatures.pinned_messages) &&
272
+ (message?.mine || canPinNonAuthoredMessages)
249
273
  const showDeleteMessageAction =
250
274
  !conversationDisabled && (message?.mine || canDeleteNonAuthoredMessages)
251
275
 
@@ -310,6 +334,20 @@ function MessageActionsScreenContent({
310
334
  accessibilityHint="Opens a modal with a list of people who read your message."
311
335
  />
312
336
  )}
337
+ {showPinMessageAction && (
338
+ <FormSheet.Action
339
+ onPress={isPinned ? handleUnpinPress : handlePinPress}
340
+ title={isPinned ? 'Unpin message' : 'Pin message'}
341
+ iconName="services.pin"
342
+ disabled={isPinning || isUnpinning}
343
+ accessibilityHint={
344
+ isPinned
345
+ ? 'Removes this message from the top of the chat.'
346
+ : 'Shows this message at the top of the chat for everyone.'
347
+ }
348
+ testID="pin-message-action"
349
+ />
350
+ )}
313
351
  {message?.mine && hasExpandedLink && !conversationDisabled && (
314
352
  <FormSheet.Action
315
353
  onPress={() => handleRemoveLinkPreviewConfirm()}
@@ -10,6 +10,7 @@ import type {
10
10
  MessageDeletedEvent,
11
11
  MessageUpdatedEvent,
12
12
  } from './message_events'
13
+ import type { PinCreatedEvent, PinDestroyedEvent } from './pin_events'
13
14
  import type { ReactionCreatedEvent, ReactionDeletedEvent } from './reaction_events'
14
15
  import type { TypingBroadcastEvent } from './typing_events'
15
16
 
@@ -21,6 +22,7 @@ export type JoltConversationEvent =
21
22
  export type JoltMessageEvent = MessageCreatedEvent | MessageUpdatedEvent | MessageDeletedEvent
22
23
  export type JoltReactionEvent = ReactionCreatedEvent | ReactionDeletedEvent
23
24
  export type JoltTypingEvent = TypingBroadcastEvent
25
+ export type JoltPinEvent = PinCreatedEvent | PinDestroyedEvent
24
26
  export type JoltAttachmentEvent = AttachmentFlaggedEvent
25
27
 
26
28
  export type CustomJoltEvent =
@@ -29,6 +31,7 @@ export type CustomJoltEvent =
29
31
  | JoltReactionEvent
30
32
  | JoltTypingEvent
31
33
  | JoltAttachmentEvent
34
+ | JoltPinEvent
32
35
 
33
36
  export type JoltEventName = CustomJoltEvent['event'] | 'STREAM_USER_UPDATED'
34
- export type JoltSubscriptionPattern = JoltEventName | 'reaction.*'
37
+ export type JoltSubscriptionPattern = JoltEventName | 'reaction.*' | 'pin.*'
@@ -0,0 +1,20 @@
1
+ import type { CustomMessage } from '@planningcenter/jolt-client/dist/types/JoltConnection'
2
+
3
+ interface PinEventData extends Record<string, unknown> {
4
+ data: {
5
+ conversation_id: number
6
+ message_sort_key: string
7
+ reply_root_id: string | null
8
+ pinned_at: string
9
+ }
10
+ }
11
+
12
+ export interface PinCreatedEvent extends CustomMessage {
13
+ event: 'pin.created'
14
+ data: PinEventData
15
+ }
16
+
17
+ export interface PinDestroyedEvent extends CustomMessage {
18
+ event: 'pin.destroyed'
19
+ data: PinEventData
20
+ }
@@ -8,4 +8,5 @@ export interface MemberAbilityResource {
8
8
  canMessageAvailableMembers: boolean
9
9
  canArchive: boolean
10
10
  canUnarchive: boolean
11
+ canPin?: boolean
11
12
  }
@@ -25,6 +25,8 @@ export interface MessageResource {
25
25
  personIdsForSystemEvent?: number[] | null
26
26
  systemTextParts?: { names: string[]; overflowCount: number; action: string } | null
27
27
  systemTextFormat?: SystemTextFormat | null
28
+ pinnedAt?: string | null
29
+ pinnedById?: number | null
28
30
 
29
31
  // Custom Local Properties we set for rendering
30
32
  renderAuthor?: boolean
@@ -191,6 +191,28 @@ export function applyMessageDeletionToCaches(
191
191
  }
192
192
  }
193
193
 
194
+ export function updateCacheWithPin(
195
+ queryClient: QueryClient,
196
+ conversationId: number,
197
+ messageSortKey: string,
198
+ pinnedAt: string | null,
199
+ replyRootId?: string | null
200
+ ) {
201
+ const queryKeys = [getMessagesQueryKey({ conversation_id: conversationId })]
202
+ if (replyRootId) queryKeys.push(getThreadedMessagesQueryKey(conversationId, replyRootId))
203
+
204
+ const record = { id: messageSortKey } as MessageResource
205
+ queryKeys.forEach(queryKey => {
206
+ queryClient.setQueryData<MessagesQueryData>(queryKey, prev =>
207
+ updateRecordInPagesData({
208
+ data: prev,
209
+ record,
210
+ processRecord: (_record, current) => ({ ...current, pinnedAt }),
211
+ })
212
+ )
213
+ })
214
+ }
215
+
194
216
  export function mergeMessageUpdate(
195
217
  record: MessageResource,
196
218
  current?: MessageResource
@@ -0,0 +1,9 @@
1
+ import { MessageResource } from '../types'
2
+ import { pluralize } from './pluralize'
3
+
4
+ export function pinnedMessagePreview(message: MessageResource) {
5
+ if (message.text) return message.text
6
+
7
+ const attachmentCount = message.attachments?.length ?? 0
8
+ return attachmentCount > 0 ? pluralize(attachmentCount, 'attachment') : ''
9
+ }
@@ -0,0 +1,19 @@
1
+ import { getRequestQueryKey } from '../../hooks/use_suspense_api'
2
+ import { getMessageFields } from './messages_data_options'
3
+
4
+ export const PINNED_MESSAGES_PER_PAGE = 50
5
+
6
+ export const getPinnedMessagesRequestArgs = ({ conversation_id }: { conversation_id: number }) => ({
7
+ url: `/me/conversations/${conversation_id}/pinned_messages`,
8
+ data: {
9
+ per_page: PINNED_MESSAGES_PER_PAGE,
10
+ fields: {
11
+ Message: getMessageFields.Message.filter(field => field !== 'reaction_counts'),
12
+ Person: getMessageFields.Person,
13
+ },
14
+ include: ['author'],
15
+ },
16
+ })
17
+
18
+ export const getPinnedMessagesQueryKey = (args: { conversation_id: number }) =>
19
+ getRequestQueryKey(getPinnedMessagesRequestArgs(args))
@@ -15,6 +15,8 @@ export const getMessageFields = {
15
15
  'person_ids_for_system_event',
16
16
  'system_text_parts',
17
17
  'system_text_format',
18
+ 'pinned_at',
19
+ 'pinned_by',
18
20
  ],
19
21
  Person: ['name', 'avatar'],
20
22
  ReactionCount: ['value', 'count', 'mine', 'message_id', 'author_ids'],
@@ -55,7 +55,7 @@ export const faDove: IconDefinition = {
55
55
  ],
56
56
  }
57
57
 
58
- export const faHandsHeart: IconDefinition = {
58
+ export const faHandsHoldingHeart: IconDefinition = {
59
59
  prefix: 'fas',
60
60
  iconName: 'hands-holding-heart',
61
61
  icon: [
@@ -79,7 +79,7 @@ export const faPersonRays: IconDefinition = {
79
79
  ],
80
80
  }
81
81
 
82
- export const faPrayingHands: IconDefinition = {
82
+ export const faHandsPraying: IconDefinition = {
83
83
  prefix: 'fas',
84
84
  iconName: 'hands-praying',
85
85
  icon: [
@@ -247,7 +247,7 @@ export const faMugHot: IconDefinition = {
247
247
  ],
248
248
  }
249
249
 
250
- export const faVideoCamera: IconDefinition = {
250
+ export const faVideo: IconDefinition = {
251
251
  prefix: 'fas',
252
252
  iconName: 'video',
253
253
  icon: [
@@ -319,7 +319,7 @@ export const faCommentsQuestion: IconDefinition = {
319
319
  ],
320
320
  }
321
321
 
322
- export const faPresentation: IconDefinition = {
322
+ export const faPresentationScreen: IconDefinition = {
323
323
  prefix: 'fas',
324
324
  iconName: 'presentation-screen',
325
325
  icon: [
@@ -499,7 +499,7 @@ export const faSeedling: IconDefinition = {
499
499
  ],
500
500
  }
501
501
 
502
- export const faCommentsAlt: IconDefinition = {
502
+ export const faMessages: IconDefinition = {
503
503
  prefix: 'fas',
504
504
  iconName: 'messages',
505
505
  icon: [
@@ -535,7 +535,7 @@ export const faBookOpenReader: IconDefinition = {
535
535
  ],
536
536
  }
537
537
 
538
- export const faRunning: IconDefinition = {
538
+ export const faPersonRunning: IconDefinition = {
539
539
  prefix: 'fas',
540
540
  iconName: 'person-running',
541
541
  icon: [