@sendbird/uikit-react-native 3.1.2 → 3.2.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 (317) hide show
  1. package/README.md +67 -42
  2. package/lib/commonjs/components/ChannelInput/MessageToReplyPreview.js +145 -0
  3. package/lib/commonjs/components/ChannelInput/MessageToReplyPreview.js.map +1 -0
  4. package/lib/commonjs/components/ChannelInput/SendInput.js +147 -312
  5. package/lib/commonjs/components/ChannelInput/SendInput.js.map +1 -1
  6. package/lib/commonjs/components/ChannelInput/VoiceMessageInput.js +238 -0
  7. package/lib/commonjs/components/ChannelInput/VoiceMessageInput.js.map +1 -0
  8. package/lib/commonjs/components/ChannelInput/index.js +5 -1
  9. package/lib/commonjs/components/ChannelInput/index.js.map +1 -1
  10. package/lib/commonjs/components/ChannelMessageList/index.js +1 -1
  11. package/lib/commonjs/components/ChannelMessageList/index.js.map +1 -1
  12. package/lib/commonjs/components/GroupChannelMessageRenderer/GroupChannelMessageParentMessage.js +24 -13
  13. package/lib/commonjs/components/GroupChannelMessageRenderer/GroupChannelMessageParentMessage.js.map +1 -1
  14. package/lib/commonjs/components/GroupChannelMessageRenderer/index.js +100 -5
  15. package/lib/commonjs/components/GroupChannelMessageRenderer/index.js.map +1 -1
  16. package/lib/commonjs/components/MessageSearchResultItem.js +1 -0
  17. package/lib/commonjs/components/MessageSearchResultItem.js.map +1 -1
  18. package/lib/commonjs/components/OpenChannelMessageRenderer/index.js +1 -0
  19. package/lib/commonjs/components/OpenChannelMessageRenderer/index.js.map +1 -1
  20. package/lib/commonjs/components/ReactionBottomSheets/ReactionUserListBottomSheet.js +2 -2
  21. package/lib/commonjs/components/ReactionBottomSheets/ReactionUserListBottomSheet.js.map +1 -1
  22. package/lib/commonjs/components/ReactionBottomSheets/index.js.map +1 -1
  23. package/lib/commonjs/components/StatusComposition.js.map +1 -1
  24. package/lib/commonjs/constants.js +5 -1
  25. package/lib/commonjs/constants.js.map +1 -1
  26. package/lib/commonjs/containers/GroupChannelPreviewContainer.js +1 -0
  27. package/lib/commonjs/containers/GroupChannelPreviewContainer.js.map +1 -1
  28. package/lib/commonjs/containers/InternalErrorBoundaryContainer.js.map +1 -1
  29. package/lib/commonjs/containers/SendbirdUIKitContainer.js +72 -34
  30. package/lib/commonjs/containers/SendbirdUIKitContainer.js.map +1 -1
  31. package/lib/commonjs/contexts/PlatformServiceCtx.js +16 -12
  32. package/lib/commonjs/contexts/PlatformServiceCtx.js.map +1 -1
  33. package/lib/commonjs/contexts/ReactionCtx.js +3 -2
  34. package/lib/commonjs/contexts/ReactionCtx.js.map +1 -1
  35. package/lib/commonjs/contexts/SendbirdChatCtx.js +2 -0
  36. package/lib/commonjs/contexts/SendbirdChatCtx.js.map +1 -1
  37. package/lib/commonjs/domain/groupChannel/component/GroupChannelMessageList.js +27 -42
  38. package/lib/commonjs/domain/groupChannel/component/GroupChannelMessageList.js.map +1 -1
  39. package/lib/commonjs/domain/groupChannel/module/moduleContext.js +109 -5
  40. package/lib/commonjs/domain/groupChannel/module/moduleContext.js.map +1 -1
  41. package/lib/commonjs/domain/groupChannel/types.js.map +1 -1
  42. package/lib/commonjs/domain/userList/types.js.map +1 -1
  43. package/lib/commonjs/fragments/createGroupChannelFragment.js +30 -4
  44. package/lib/commonjs/fragments/createGroupChannelFragment.js.map +1 -1
  45. package/lib/commonjs/fragments/createMessageSearchFragment.js +1 -1
  46. package/lib/commonjs/fragments/createMessageSearchFragment.js.map +1 -1
  47. package/lib/commonjs/hooks/useChannelInputItems.js +211 -0
  48. package/lib/commonjs/hooks/useChannelInputItems.js.map +1 -0
  49. package/lib/commonjs/hooks/useConnection.js +1 -1
  50. package/lib/commonjs/hooks/useConnection.js.map +1 -1
  51. package/lib/commonjs/hooks/useVoiceMessageInput.js +207 -0
  52. package/lib/commonjs/hooks/useVoiceMessageInput.js.map +1 -0
  53. package/lib/commonjs/index.js +32 -0
  54. package/lib/commonjs/index.js.map +1 -1
  55. package/lib/commonjs/libs/MentionManager.js.map +1 -1
  56. package/lib/commonjs/libs/SBUUtils.js +4 -0
  57. package/lib/commonjs/libs/SBUUtils.js.map +1 -1
  58. package/lib/commonjs/libs/VoiceMessageConfig.js +30 -0
  59. package/lib/commonjs/libs/VoiceMessageConfig.js.map +1 -0
  60. package/lib/commonjs/localization/StringSet.type.js.map +1 -1
  61. package/lib/commonjs/localization/createBaseStringSet.js +24 -9
  62. package/lib/commonjs/localization/createBaseStringSet.js.map +1 -1
  63. package/lib/commonjs/platform/createFileService.expo.js +10 -0
  64. package/lib/commonjs/platform/createFileService.expo.js.map +1 -1
  65. package/lib/commonjs/platform/createFileService.native.js +19 -0
  66. package/lib/commonjs/platform/createFileService.native.js.map +1 -1
  67. package/lib/commonjs/platform/createPlayerService.expo.js +137 -0
  68. package/lib/commonjs/platform/createPlayerService.expo.js.map +1 -0
  69. package/lib/commonjs/platform/createPlayerService.native.js +139 -0
  70. package/lib/commonjs/platform/createPlayerService.native.js.map +1 -0
  71. package/lib/commonjs/platform/createRecorderService.expo.js +158 -0
  72. package/lib/commonjs/platform/createRecorderService.expo.js.map +1 -0
  73. package/lib/commonjs/platform/createRecorderService.native.js +157 -0
  74. package/lib/commonjs/platform/createRecorderService.native.js.map +1 -0
  75. package/lib/commonjs/platform/types.js.map +1 -1
  76. package/lib/commonjs/types.js.map +1 -1
  77. package/lib/commonjs/version.js +1 -1
  78. package/lib/commonjs/version.js.map +1 -1
  79. package/lib/module/components/ChannelInput/MessageToReplyPreview.js +137 -0
  80. package/lib/module/components/ChannelInput/MessageToReplyPreview.js.map +1 -0
  81. package/lib/module/components/ChannelInput/SendInput.js +149 -314
  82. package/lib/module/components/ChannelInput/SendInput.js.map +1 -1
  83. package/lib/module/components/ChannelInput/VoiceMessageInput.js +228 -0
  84. package/lib/module/components/ChannelInput/VoiceMessageInput.js.map +1 -0
  85. package/lib/module/components/ChannelInput/index.js +5 -1
  86. package/lib/module/components/ChannelInput/index.js.map +1 -1
  87. package/lib/module/components/ChannelMessageList/index.js +2 -2
  88. package/lib/module/components/ChannelMessageList/index.js.map +1 -1
  89. package/lib/module/components/GroupChannelMessageRenderer/GroupChannelMessageParentMessage.js +24 -13
  90. package/lib/module/components/GroupChannelMessageRenderer/GroupChannelMessageParentMessage.js.map +1 -1
  91. package/lib/module/components/GroupChannelMessageRenderer/index.js +99 -6
  92. package/lib/module/components/GroupChannelMessageRenderer/index.js.map +1 -1
  93. package/lib/module/components/MessageSearchResultItem.js +2 -1
  94. package/lib/module/components/MessageSearchResultItem.js.map +1 -1
  95. package/lib/module/components/OpenChannelMessageRenderer/index.js +1 -0
  96. package/lib/module/components/OpenChannelMessageRenderer/index.js.map +1 -1
  97. package/lib/module/components/ReactionBottomSheets/ReactionUserListBottomSheet.js +2 -2
  98. package/lib/module/components/ReactionBottomSheets/ReactionUserListBottomSheet.js.map +1 -1
  99. package/lib/module/components/ReactionBottomSheets/index.js.map +1 -1
  100. package/lib/module/components/StatusComposition.js.map +1 -1
  101. package/lib/module/constants.js +2 -0
  102. package/lib/module/constants.js.map +1 -1
  103. package/lib/module/containers/GroupChannelPreviewContainer.js +2 -1
  104. package/lib/module/containers/GroupChannelPreviewContainer.js.map +1 -1
  105. package/lib/module/containers/InternalErrorBoundaryContainer.js.map +1 -1
  106. package/lib/module/containers/SendbirdUIKitContainer.js +74 -36
  107. package/lib/module/containers/SendbirdUIKitContainer.js.map +1 -1
  108. package/lib/module/contexts/PlatformServiceCtx.js +14 -11
  109. package/lib/module/contexts/PlatformServiceCtx.js.map +1 -1
  110. package/lib/module/contexts/ReactionCtx.js +3 -2
  111. package/lib/module/contexts/ReactionCtx.js.map +1 -1
  112. package/lib/module/contexts/SendbirdChatCtx.js +2 -0
  113. package/lib/module/contexts/SendbirdChatCtx.js.map +1 -1
  114. package/lib/module/domain/groupChannel/component/GroupChannelMessageList.js +28 -43
  115. package/lib/module/domain/groupChannel/component/GroupChannelMessageList.js.map +1 -1
  116. package/lib/module/domain/groupChannel/module/moduleContext.js +111 -7
  117. package/lib/module/domain/groupChannel/module/moduleContext.js.map +1 -1
  118. package/lib/module/domain/groupChannel/types.js.map +1 -1
  119. package/lib/module/domain/userList/types.js.map +1 -1
  120. package/lib/module/fragments/createGroupChannelFragment.js +32 -6
  121. package/lib/module/fragments/createGroupChannelFragment.js.map +1 -1
  122. package/lib/module/fragments/createMessageSearchFragment.js +1 -1
  123. package/lib/module/fragments/createMessageSearchFragment.js.map +1 -1
  124. package/lib/module/hooks/useChannelInputItems.js +203 -0
  125. package/lib/module/hooks/useChannelInputItems.js.map +1 -0
  126. package/lib/module/hooks/useConnection.js +1 -1
  127. package/lib/module/hooks/useConnection.js.map +1 -1
  128. package/lib/module/hooks/useVoiceMessageInput.js +199 -0
  129. package/lib/module/hooks/useVoiceMessageInput.js.map +1 -0
  130. package/lib/module/index.js +4 -0
  131. package/lib/module/index.js.map +1 -1
  132. package/lib/module/libs/MentionManager.js.map +1 -1
  133. package/lib/module/libs/SBUUtils.js +4 -0
  134. package/lib/module/libs/SBUUtils.js.map +1 -1
  135. package/lib/module/libs/VoiceMessageConfig.js +23 -0
  136. package/lib/module/libs/VoiceMessageConfig.js.map +1 -0
  137. package/lib/module/localization/StringSet.type.js.map +1 -1
  138. package/lib/module/localization/createBaseStringSet.js +25 -10
  139. package/lib/module/localization/createBaseStringSet.js.map +1 -1
  140. package/lib/module/platform/createFileService.expo.js +10 -0
  141. package/lib/module/platform/createFileService.expo.js.map +1 -1
  142. package/lib/module/platform/createFileService.native.js +19 -0
  143. package/lib/module/platform/createFileService.native.js.map +1 -1
  144. package/lib/module/platform/createPlayerService.expo.js +129 -0
  145. package/lib/module/platform/createPlayerService.expo.js.map +1 -0
  146. package/lib/module/platform/createPlayerService.native.js +132 -0
  147. package/lib/module/platform/createPlayerService.native.js.map +1 -0
  148. package/lib/module/platform/createRecorderService.expo.js +150 -0
  149. package/lib/module/platform/createRecorderService.expo.js.map +1 -0
  150. package/lib/module/platform/createRecorderService.native.js +149 -0
  151. package/lib/module/platform/createRecorderService.native.js.map +1 -0
  152. package/lib/module/platform/types.js.map +1 -1
  153. package/lib/module/types.js.map +1 -1
  154. package/lib/module/version.js +1 -1
  155. package/lib/module/version.js.map +1 -1
  156. package/lib/typescript/src/components/ChannelCover.d.ts +2 -1
  157. package/lib/typescript/src/components/ChannelInput/AttachmentsButton.d.ts +2 -1
  158. package/lib/typescript/src/components/ChannelInput/MessageToReplyPreview.d.ts +7 -0
  159. package/lib/typescript/src/components/ChannelInput/VoiceMessageInput.d.ts +11 -0
  160. package/lib/typescript/src/components/ChannelInput/index.d.ts +7 -3
  161. package/lib/typescript/src/components/ChannelMessageList/index.d.ts +1 -1
  162. package/lib/typescript/src/components/FileViewer.d.ts +2 -1
  163. package/lib/typescript/src/components/GroupChannelMessageRenderer/GroupChannelMessageDateSeparator.d.ts +2 -1
  164. package/lib/typescript/src/components/GroupChannelMessageRenderer/GroupChannelMessageFocusAnimation.d.ts +1 -1
  165. package/lib/typescript/src/components/GroupChannelMessageRenderer/GroupChannelMessageOutgoingStatus.d.ts +1 -1
  166. package/lib/typescript/src/components/GroupChannelMessageRenderer/GroupChannelMessageParentMessage.d.ts +4 -2
  167. package/lib/typescript/src/components/NewMessagesButton.d.ts +1 -1
  168. package/lib/typescript/src/components/OpenChannelMessageRenderer/OpenChannelMessageDateSeparator.d.ts +2 -1
  169. package/lib/typescript/src/components/ProviderLayout.d.ts +1 -1
  170. package/lib/typescript/src/components/ReactionAddons/BottomSheetReactionAddon.d.ts +2 -1
  171. package/lib/typescript/src/components/ReactionAddons/MessageReactionAddon.d.ts +2 -1
  172. package/lib/typescript/src/components/ReactionAddons/ReactionRoundedButton.d.ts +3 -2
  173. package/lib/typescript/src/components/ReactionAddons/index.d.ts +3 -2
  174. package/lib/typescript/src/components/ReactionBottomSheets/ReactionListBottomSheet.d.ts +2 -1
  175. package/lib/typescript/src/components/ReactionBottomSheets/ReactionUserListBottomSheet.d.ts +2 -1
  176. package/lib/typescript/src/components/ReactionBottomSheets/index.d.ts +4 -4
  177. package/lib/typescript/src/components/ScrollToBottomButton.d.ts +1 -1
  178. package/lib/typescript/src/components/StatusComposition.d.ts +4 -4
  179. package/lib/typescript/src/components/TypedPlaceholder.d.ts +2 -1
  180. package/lib/typescript/src/components/UserActionBar.d.ts +2 -1
  181. package/lib/typescript/src/components/UserSelectableBar.d.ts +2 -1
  182. package/lib/typescript/src/constants.d.ts +2 -0
  183. package/lib/typescript/src/containers/GroupChannelPreviewContainer.d.ts +2 -1
  184. package/lib/typescript/src/containers/InternalErrorBoundaryContainer.d.ts +3 -3
  185. package/lib/typescript/src/containers/SendbirdUIKitContainer.d.ts +19 -8
  186. package/lib/typescript/src/contexts/LocalizationCtx.d.ts +1 -1
  187. package/lib/typescript/src/contexts/PlatformServiceCtx.d.ts +8 -8
  188. package/lib/typescript/src/contexts/ReactionCtx.d.ts +5 -2
  189. package/lib/typescript/src/contexts/SendbirdChatCtx.d.ts +6 -3
  190. package/lib/typescript/src/contexts/UserProfileCtx.d.ts +1 -1
  191. package/lib/typescript/src/domain/groupChannel/component/GroupChannelHeader.d.ts +2 -1
  192. package/lib/typescript/src/domain/groupChannel/component/GroupChannelInput.d.ts +1 -1
  193. package/lib/typescript/src/domain/groupChannel/component/GroupChannelMessageList.d.ts +1 -1
  194. package/lib/typescript/src/domain/groupChannel/component/GroupChannelStatusEmpty.d.ts +2 -1
  195. package/lib/typescript/src/domain/groupChannel/component/GroupChannelStatusLoading.d.ts +2 -1
  196. package/lib/typescript/src/domain/groupChannel/component/GroupChannelSuggestedMentionList.d.ts +2 -1
  197. package/lib/typescript/src/domain/groupChannel/types.d.ts +45 -0
  198. package/lib/typescript/src/domain/groupChannelBannedUsers/component/GroupChannelBannedUsersHeader.d.ts +2 -1
  199. package/lib/typescript/src/domain/groupChannelBannedUsers/component/GroupChannelBannedUsersList.d.ts +2 -1
  200. package/lib/typescript/src/domain/groupChannelBannedUsers/component/GroupChannelBannedUsersStatusEmpty.d.ts +2 -1
  201. package/lib/typescript/src/domain/groupChannelBannedUsers/component/GroupChannelBannedUsersStatusLoading.d.ts +2 -1
  202. package/lib/typescript/src/domain/groupChannelList/component/GroupChannelListHeader.d.ts +2 -1
  203. package/lib/typescript/src/domain/groupChannelList/component/GroupChannelListList.d.ts +2 -1
  204. package/lib/typescript/src/domain/groupChannelList/component/GroupChannelListStatusEmpty.d.ts +2 -1
  205. package/lib/typescript/src/domain/groupChannelList/component/GroupChannelListStatusLoading.d.ts +2 -1
  206. package/lib/typescript/src/domain/groupChannelList/component/GroupChannelListTypeSelector.d.ts +2 -1
  207. package/lib/typescript/src/domain/groupChannelModeration/component/GroupChannelModerationHeader.d.ts +2 -1
  208. package/lib/typescript/src/domain/groupChannelModeration/component/GroupChannelModerationMenu.d.ts +2 -1
  209. package/lib/typescript/src/domain/groupChannelMutedMembers/component/GroupChannelMutedMembersHeader.d.ts +2 -1
  210. package/lib/typescript/src/domain/groupChannelMutedMembers/component/GroupChannelMutedMembersList.d.ts +2 -1
  211. package/lib/typescript/src/domain/groupChannelMutedMembers/component/GroupChannelMutedMembersStatusEmpty.d.ts +2 -1
  212. package/lib/typescript/src/domain/groupChannelMutedMembers/component/GroupChannelMutedMembersStatusLoading.d.ts +2 -1
  213. package/lib/typescript/src/domain/groupChannelNotifications/component/GroupChannelNotificationsHeader.d.ts +2 -1
  214. package/lib/typescript/src/domain/groupChannelNotifications/component/GroupChannelNotificationsView.d.ts +2 -1
  215. package/lib/typescript/src/domain/groupChannelOperators/component/GroupChannelOperatorsHeader.d.ts +2 -1
  216. package/lib/typescript/src/domain/groupChannelOperators/component/GroupChannelOperatorsList.d.ts +2 -1
  217. package/lib/typescript/src/domain/groupChannelOperators/component/GroupChannelOperatorsStatusEmpty.d.ts +2 -1
  218. package/lib/typescript/src/domain/groupChannelOperators/component/GroupChannelOperatorsStatusLoading.d.ts +2 -1
  219. package/lib/typescript/src/domain/groupChannelSettings/component/GroupChannelSettingsHeader.d.ts +2 -1
  220. package/lib/typescript/src/domain/groupChannelSettings/component/GroupChannelSettingsInfo.d.ts +2 -1
  221. package/lib/typescript/src/domain/groupChannelSettings/component/GroupChannelSettingsMenu.d.ts +2 -1
  222. package/lib/typescript/src/domain/messageSearch/component/MessageSearchHeader.d.ts +2 -1
  223. package/lib/typescript/src/domain/messageSearch/component/MessageSearchList.d.ts +2 -1
  224. package/lib/typescript/src/domain/messageSearch/component/MessageSearchStatusEmpty.d.ts +2 -1
  225. package/lib/typescript/src/domain/messageSearch/component/MessageSearchStatusLoading.d.ts +2 -1
  226. package/lib/typescript/src/domain/openChannel/component/OpenChannelHeader.d.ts +2 -2
  227. package/lib/typescript/src/domain/openChannel/component/OpenChannelInput.d.ts +1 -1
  228. package/lib/typescript/src/domain/openChannel/component/OpenChannelMessageList.d.ts +1 -1
  229. package/lib/typescript/src/domain/openChannel/component/OpenChannelStatusEmpty.d.ts +2 -1
  230. package/lib/typescript/src/domain/openChannel/component/OpenChannelStatusLoading.d.ts +2 -1
  231. package/lib/typescript/src/domain/openChannelBannedUsers/component/OpenChannelBannedUsersHeader.d.ts +2 -1
  232. package/lib/typescript/src/domain/openChannelBannedUsers/component/OpenChannelBannedUsersList.d.ts +2 -1
  233. package/lib/typescript/src/domain/openChannelBannedUsers/component/OpenChannelBannedUsersStatusEmpty.d.ts +2 -1
  234. package/lib/typescript/src/domain/openChannelBannedUsers/component/OpenChannelBannedUsersStatusLoading.d.ts +2 -1
  235. package/lib/typescript/src/domain/openChannelCreate/component/OpenChannelCreateHeader.d.ts +2 -1
  236. package/lib/typescript/src/domain/openChannelCreate/component/OpenChannelCreateProfileInput.d.ts +2 -1
  237. package/lib/typescript/src/domain/openChannelCreate/component/OpenChannelCreateStatusLoading.d.ts +2 -1
  238. package/lib/typescript/src/domain/openChannelList/component/OpenChannelListHeader.d.ts +2 -1
  239. package/lib/typescript/src/domain/openChannelList/component/OpenChannelListList.d.ts +2 -1
  240. package/lib/typescript/src/domain/openChannelList/component/OpenChannelListStatusEmpty.d.ts +2 -1
  241. package/lib/typescript/src/domain/openChannelList/component/OpenChannelListStatusLoading.d.ts +2 -1
  242. package/lib/typescript/src/domain/openChannelModeration/component/OpenChannelModerationHeader.d.ts +2 -1
  243. package/lib/typescript/src/domain/openChannelModeration/component/OpenChannelModerationMenu.d.ts +2 -1
  244. package/lib/typescript/src/domain/openChannelMutedParticipants/component/OpenChannelMutedParticipantsHeader.d.ts +2 -1
  245. package/lib/typescript/src/domain/openChannelMutedParticipants/component/OpenChannelMutedParticipantsList.d.ts +2 -1
  246. package/lib/typescript/src/domain/openChannelMutedParticipants/component/OpenChannelMutedParticipantsStatusEmpty.d.ts +2 -1
  247. package/lib/typescript/src/domain/openChannelMutedParticipants/component/OpenChannelMutedParticipantsStatusLoading.d.ts +2 -1
  248. package/lib/typescript/src/domain/openChannelOperators/component/OpenChannelOperatorsHeader.d.ts +2 -1
  249. package/lib/typescript/src/domain/openChannelOperators/component/OpenChannelOperatorsList.d.ts +2 -1
  250. package/lib/typescript/src/domain/openChannelOperators/component/OpenChannelOperatorsStatusEmpty.d.ts +2 -1
  251. package/lib/typescript/src/domain/openChannelOperators/component/OpenChannelOperatorsStatusLoading.d.ts +2 -1
  252. package/lib/typescript/src/domain/openChannelSettings/component/OpenChannelSettingsHeader.d.ts +2 -1
  253. package/lib/typescript/src/domain/openChannelSettings/component/OpenChannelSettingsInfo.d.ts +2 -1
  254. package/lib/typescript/src/domain/openChannelSettings/component/OpenChannelSettingsMenu.d.ts +2 -1
  255. package/lib/typescript/src/domain/userList/component/UserListHeader.d.ts +3 -3
  256. package/lib/typescript/src/domain/userList/component/UserListList.d.ts +1 -1
  257. package/lib/typescript/src/domain/userList/component/UserListStatusEmpty.d.ts +2 -1
  258. package/lib/typescript/src/domain/userList/component/UserListStatusLoading.d.ts +2 -1
  259. package/lib/typescript/src/domain/userList/types.d.ts +2 -2
  260. package/lib/typescript/src/hooks/useChannelInputItems.d.ts +10 -0
  261. package/lib/typescript/src/hooks/useVoiceMessageInput.d.ts +53 -0
  262. package/lib/typescript/src/index.d.ts +4 -0
  263. package/lib/typescript/src/libs/MentionManager.d.ts +2 -1
  264. package/lib/typescript/src/libs/SBUUtils.d.ts +1 -0
  265. package/lib/typescript/src/libs/VoiceMessageConfig.d.ts +25 -0
  266. package/lib/typescript/src/localization/StringSet.type.d.ts +7 -0
  267. package/lib/typescript/src/platform/createPlayerService.expo.d.ts +7 -0
  268. package/lib/typescript/src/platform/createPlayerService.native.d.ts +9 -0
  269. package/lib/typescript/src/platform/createRecorderService.expo.d.ts +7 -0
  270. package/lib/typescript/src/platform/createRecorderService.native.d.ts +9 -0
  271. package/lib/typescript/src/platform/types.d.ts +100 -1
  272. package/lib/typescript/src/types.d.ts +1 -1
  273. package/lib/typescript/src/version.d.ts +1 -1
  274. package/package.json +9 -11
  275. package/src/components/ChannelInput/MessageToReplyPreview.tsx +133 -0
  276. package/src/components/ChannelInput/SendInput.tsx +129 -320
  277. package/src/components/ChannelInput/VoiceMessageInput.tsx +206 -0
  278. package/src/components/ChannelInput/index.tsx +12 -4
  279. package/src/components/ChannelMessageList/index.tsx +3 -1
  280. package/src/components/GroupChannelMessageRenderer/GroupChannelMessageParentMessage.tsx +24 -11
  281. package/src/components/GroupChannelMessageRenderer/index.tsx +80 -3
  282. package/src/components/MessageSearchResultItem.tsx +2 -1
  283. package/src/components/OpenChannelMessageRenderer/index.tsx +1 -0
  284. package/src/components/ReactionBottomSheets/ReactionUserListBottomSheet.tsx +2 -2
  285. package/src/components/ReactionBottomSheets/index.tsx +3 -2
  286. package/src/components/StatusComposition.tsx +3 -3
  287. package/src/constants.ts +2 -0
  288. package/src/containers/GroupChannelPreviewContainer.tsx +2 -0
  289. package/src/containers/InternalErrorBoundaryContainer.tsx +1 -1
  290. package/src/containers/SendbirdUIKitContainer.tsx +103 -59
  291. package/src/contexts/PlatformServiceCtx.tsx +22 -20
  292. package/src/contexts/ReactionCtx.tsx +7 -5
  293. package/src/contexts/SendbirdChatCtx.tsx +10 -2
  294. package/src/domain/groupChannel/component/GroupChannelMessageList.tsx +29 -43
  295. package/src/domain/groupChannel/module/moduleContext.tsx +119 -7
  296. package/src/domain/groupChannel/types.ts +41 -0
  297. package/src/domain/userList/types.ts +2 -2
  298. package/src/fragments/createGroupChannelFragment.tsx +32 -5
  299. package/src/fragments/createMessageSearchFragment.tsx +1 -1
  300. package/src/hooks/useChannelInputItems.ts +215 -0
  301. package/src/hooks/useConnection.ts +1 -1
  302. package/src/hooks/useVoiceMessageInput.ts +237 -0
  303. package/src/index.ts +4 -0
  304. package/src/libs/MentionManager.tsx +1 -1
  305. package/src/libs/SBUUtils.ts +5 -0
  306. package/src/libs/VoiceMessageConfig.ts +28 -0
  307. package/src/localization/StringSet.type.ts +8 -0
  308. package/src/localization/createBaseStringSet.ts +27 -11
  309. package/src/platform/createFileService.expo.ts +10 -0
  310. package/src/platform/createFileService.native.ts +19 -0
  311. package/src/platform/createPlayerService.expo.tsx +142 -0
  312. package/src/platform/createPlayerService.native.tsx +148 -0
  313. package/src/platform/createRecorderService.expo.tsx +160 -0
  314. package/src/platform/createRecorderService.native.tsx +170 -0
  315. package/src/platform/types.ts +114 -1
  316. package/src/types.ts +1 -1
  317. package/src/version.ts +1 -1
@@ -2,7 +2,7 @@ import React, { useLayoutEffect, useMemo, useRef, useState } from 'react';
2
2
  import { Platform } from 'react-native';
3
3
  import { SafeAreaProvider } from 'react-native-safe-area-context';
4
4
 
5
- import Sendbird, { DeviceOsPlatform, SendbirdPlatform, SendbirdProduct } from '@sendbird/chat';
5
+ import SendbirdChat, { DeviceOsPlatform, SendbirdChatParams, SendbirdPlatform, SendbirdProduct } from '@sendbird/chat';
6
6
  import { GroupChannelModule } from '@sendbird/chat/groupChannel';
7
7
  import { OpenChannelModule } from '@sendbird/chat/openChannel';
8
8
  import type { HeaderStyleContextType, UIKitTheme } from '@sendbird/uikit-react-native-foundation';
@@ -18,7 +18,6 @@ import { SBUConfig, UIKitConfigProvider } from '@sendbird/uikit-tools';
18
18
  import type {
19
19
  PartialDeep,
20
20
  SendbirdChatSDK,
21
- SendbirdEncryption,
22
21
  SendbirdGroupChannel,
23
22
  SendbirdGroupChannelCreateParams,
24
23
  SendbirdMember,
@@ -38,6 +37,7 @@ import ImageCompressionConfig from '../libs/ImageCompressionConfig';
38
37
  import InternalLocalCacheStorage from '../libs/InternalLocalCacheStorage';
39
38
  import MentionConfig, { MentionConfigInterface } from '../libs/MentionConfig';
40
39
  import MentionManager from '../libs/MentionManager';
40
+ import VoiceMessageConfig, { VoiceMessageConfigInterface } from '../libs/VoiceMessageConfig';
41
41
  import StringSetEn from '../localization/StringSet.en';
42
42
  import type { StringSet } from '../localization/StringSet.type';
43
43
  import SBUDynamicModule from '../platform/dynamicModule';
@@ -46,13 +46,14 @@ import type {
46
46
  FileServiceInterface,
47
47
  MediaServiceInterface,
48
48
  NotificationServiceInterface,
49
+ PlayerServiceInterface,
50
+ RecorderServiceInterface,
49
51
  } from '../platform/types';
50
52
  import type { ErrorBoundaryProps, LocalCacheStorage } from '../types';
51
53
  import VERSION from '../version';
52
54
  import InternalErrorBoundaryContainer from './InternalErrorBoundaryContainer';
53
55
 
54
56
  const NetInfo = SBUDynamicModule.get('@react-native-community/netinfo', 'warn');
55
- type UnimplementedFeatures = 'enableVoiceMessage' | 'threadReplySelectType' | 'replyType';
56
57
  export const SendbirdUIKit = Object.freeze({
57
58
  VERSION,
58
59
  PLATFORM: Platform.OS.toLowerCase(),
@@ -63,6 +64,27 @@ export const SendbirdUIKit = Object.freeze({
63
64
  },
64
65
  });
65
66
 
67
+ type UnimplementedFeatures = 'threadReplySelectType' | 'replyType';
68
+ export type ChatOmittedInitParams = Omit<
69
+ SendbirdChatParams<[GroupChannelModule, OpenChannelModule]>,
70
+ (typeof chatOmitKeys)[number]
71
+ >;
72
+
73
+ const chatOmitKeys = [
74
+ 'appId',
75
+ 'newInstance',
76
+ 'modules',
77
+ 'debugMode',
78
+ 'appVersion',
79
+ 'localCacheEnabled',
80
+ 'useAsyncStorageStore',
81
+ ] as const;
82
+ function sanitizeChatOptions<T extends Record<string, unknown>>(chatOptions: T): T {
83
+ const opts = { ...chatOptions };
84
+ chatOmitKeys.forEach((key) => delete opts[key]);
85
+ return opts;
86
+ }
87
+
66
88
  export type SendbirdUIKitContainerProps = React.PropsWithChildren<{
67
89
  appId: string;
68
90
  platformServices: {
@@ -70,12 +92,14 @@ export type SendbirdUIKitContainerProps = React.PropsWithChildren<{
70
92
  notification: NotificationServiceInterface;
71
93
  clipboard: ClipboardServiceInterface;
72
94
  media: MediaServiceInterface;
95
+ player: PlayerServiceInterface;
96
+ recorder: RecorderServiceInterface;
73
97
  };
74
98
  chatOptions: {
75
99
  localCacheStorage: LocalCacheStorage;
76
- localCacheEncryption?: SendbirdEncryption;
77
100
  onInitialized?: (sdkInstance: SendbirdChatSDK) => SendbirdChatSDK;
78
- } & Partial<ChatRelatedFeaturesInUIKit>;
101
+ } & Partial<ChatOmittedInitParams> &
102
+ Partial<ChatRelatedFeaturesInUIKit>;
79
103
  uikitOptions?: PartialDeep<{
80
104
  common: SBUConfig['common'];
81
105
  groupChannel: Omit<SBUConfig['groupChannel']['channel'], UnimplementedFeatures> & {
@@ -98,7 +122,7 @@ export type SendbirdUIKitContainerProps = React.PropsWithChildren<{
98
122
  errorBoundary?: {
99
123
  disabled?: boolean;
100
124
  onError?: (props: ErrorBoundaryProps) => void;
101
- ErrorInfoComponent?: (props: ErrorBoundaryProps) => JSX.Element;
125
+ ErrorInfoComponent?: (props: ErrorBoundaryProps) => React.ReactNode;
102
126
  };
103
127
  toast?: {
104
128
  dismissTimeout?: number;
@@ -110,24 +134,29 @@ export type SendbirdUIKitContainerProps = React.PropsWithChildren<{
110
134
  users: SendbirdUser[] | SendbirdMember[],
111
135
  ) => SendbirdGroupChannelCreateParams | Promise<SendbirdGroupChannelCreateParams>;
112
136
  };
137
+ reaction?: {
138
+ onPressUserProfile?: (user: SendbirdUser | SendbirdMember) => void;
139
+ };
113
140
  userMention?: Pick<Partial<MentionConfigInterface>, 'mentionLimit' | 'suggestionLimit' | 'debounceMills'>;
114
141
  imageCompression?: Partial<ImageCompressionConfigInterface>;
142
+ voiceMessage?: PartialDeep<VoiceMessageConfigInterface>;
115
143
  }>;
116
144
 
117
- const SendbirdUIKitContainer = ({
118
- children,
119
- appId,
120
- chatOptions,
121
- uikitOptions,
122
- platformServices,
123
- localization,
124
- styles,
125
- errorBoundary,
126
- toast,
127
- userProfile,
128
- userMention,
129
- imageCompression,
130
- }: SendbirdUIKitContainerProps) => {
145
+ const SendbirdUIKitContainer = (props: SendbirdUIKitContainerProps) => {
146
+ const {
147
+ children,
148
+ appId,
149
+ chatOptions,
150
+ uikitOptions,
151
+ platformServices,
152
+ localization,
153
+ styles,
154
+ errorBoundary,
155
+ toast,
156
+ userProfile,
157
+ reaction,
158
+ } = props;
159
+
131
160
  if (!chatOptions.localCacheStorage) {
132
161
  throw new Error('SendbirdUIKitContainer: chatOptions.localCacheStorage is required');
133
162
  }
@@ -139,35 +168,18 @@ const SendbirdUIKitContainer = ({
139
168
 
140
169
  const [internalStorage] = useState(() => new InternalLocalCacheStorage(chatOptions.localCacheStorage));
141
170
  const [sdkInstance, setSdkInstance] = useState<SendbirdChatSDK>(() => {
142
- const sendbird = initializeSendbird(appId, { internalStorage, ...chatOptions });
171
+ const sendbird = initializeSendbird(appId, { internalStorage, ...sanitizeChatOptions(chatOptions) });
143
172
  unsubscribes.current = sendbird.unsubscribes;
144
173
  return sendbird.chatSDK;
145
174
  });
146
175
 
176
+ const { imageCompressionConfig, voiceMessageConfig, mentionConfig } = useConfigInstance(props);
147
177
  const emojiManager = useMemo(() => new EmojiManager(internalStorage), [internalStorage]);
148
-
149
- const mentionManager = useMemo(() => {
150
- const config = new MentionConfig({
151
- mentionLimit: userMention?.mentionLimit || MentionConfig.DEFAULT.MENTION_LIMIT,
152
- suggestionLimit: userMention?.suggestionLimit || MentionConfig.DEFAULT.SUGGESTION_LIMIT,
153
- debounceMills: userMention?.debounceMills ?? MentionConfig.DEFAULT.DEBOUNCE_MILLS,
154
- delimiter: MentionConfig.DEFAULT.DELIMITER,
155
- trigger: MentionConfig.DEFAULT.TRIGGER,
156
- });
157
- return new MentionManager(config);
158
- }, [userMention?.mentionLimit, userMention?.suggestionLimit, userMention?.debounceMills]);
159
-
160
- const imageCompressionConfig = useMemo(() => {
161
- return new ImageCompressionConfig({
162
- compressionRate: imageCompression?.compressionRate || ImageCompressionConfig.DEFAULT.COMPRESSION_RATE,
163
- width: imageCompression?.width,
164
- height: imageCompression?.height,
165
- });
166
- }, [imageCompression?.compressionRate, imageCompression?.width, imageCompression?.height]);
178
+ const mentionManager = useMemo(() => new MentionManager(mentionConfig), [mentionConfig]);
167
179
 
168
180
  useLayoutEffect(() => {
169
181
  if (!isFirstMount) {
170
- const sendbird = initializeSendbird(appId, { internalStorage, ...chatOptions });
182
+ const sendbird = initializeSendbird(appId, { internalStorage, ...sanitizeChatOptions(chatOptions) });
171
183
  setSdkInstance(sendbird.chatSDK);
172
184
  unsubscribes.current = sendbird.unsubscribes;
173
185
  }
@@ -210,6 +222,7 @@ const SendbirdUIKitContainer = ({
210
222
  emojiManager={emojiManager}
211
223
  mentionManager={mentionManager}
212
224
  imageCompressionConfig={imageCompressionConfig}
225
+ voiceMessageConfig={voiceMessageConfig}
213
226
  enableAutoPushTokenRegistration={
214
227
  chatOptions.enableAutoPushTokenRegistration ?? SendbirdUIKit.DEFAULT.AUTO_PUSH_TOKEN_REGISTRATION
215
228
  }
@@ -224,6 +237,9 @@ const SendbirdUIKitContainer = ({
224
237
  notificationService={platformServices.notification}
225
238
  clipboardService={platformServices.clipboard}
226
239
  mediaService={platformServices.media}
240
+ playerService={platformServices.player}
241
+ recorderService={platformServices.recorder}
242
+ voiceMessageConfig={voiceMessageConfig}
227
243
  >
228
244
  <UIKitThemeProvider theme={styles?.theme ?? LightUIKitTheme}>
229
245
  <HeaderStyleProvider
@@ -232,12 +248,8 @@ const SendbirdUIKitContainer = ({
232
248
  statusBarTranslucent={styles?.statusBarTranslucent ?? true}
233
249
  >
234
250
  <ToastProvider dismissTimeout={toast?.dismissTimeout}>
235
- <UserProfileProvider
236
- onCreateChannel={userProfile?.onCreateChannel}
237
- onBeforeCreateChannel={userProfile?.onBeforeCreateChannel}
238
- statusBarTranslucent={styles?.statusBarTranslucent ?? true}
239
- >
240
- <ReactionProvider>
251
+ <UserProfileProvider {...userProfile} statusBarTranslucent={styles?.statusBarTranslucent ?? true}>
252
+ <ReactionProvider {...reaction}>
241
253
  <LocalizationContext.Consumer>
242
254
  {(value) => {
243
255
  const STRINGS = value?.STRINGS || defaultStringSet;
@@ -270,25 +282,22 @@ const SendbirdUIKitContainer = ({
270
282
  );
271
283
  };
272
284
 
273
- const initializeSendbird = (
274
- appId: string,
275
- options: {
276
- internalStorage?: InternalLocalCacheStorage;
277
- onInitialized?: (sdk: SendbirdChatSDK) => SendbirdChatSDK;
278
- localCacheEncryption?: SendbirdEncryption;
279
- },
280
- ) => {
285
+ interface InitOptions extends ChatOmittedInitParams {
286
+ internalStorage: InternalLocalCacheStorage;
287
+ onInitialized?: (sdk: SendbirdChatSDK) => SendbirdChatSDK;
288
+ }
289
+ const initializeSendbird = (appId: string, options: InitOptions) => {
281
290
  let chatSDK: SendbirdChatSDK;
282
291
  const unsubscribes: Array<() => void> = [];
283
- const { internalStorage, localCacheEncryption, onInitialized } = options;
292
+ const { internalStorage, onInitialized, ...chatInitParams } = options;
284
293
 
285
- chatSDK = Sendbird.init({
294
+ chatSDK = SendbirdChat.init({
295
+ ...chatInitParams,
286
296
  appId,
287
297
  newInstance: true,
288
298
  modules: [new GroupChannelModule(), new OpenChannelModule()],
289
- localCacheEnabled: Boolean(internalStorage),
299
+ localCacheEnabled: true,
290
300
  useAsyncStorageStore: internalStorage as never,
291
- localCacheEncryption,
292
301
  });
293
302
 
294
303
  if (onInitialized) {
@@ -368,4 +377,39 @@ function getReactNativeVersion() {
368
377
  return `${major}.${minor}.${patch}`;
369
378
  }
370
379
 
380
+ const useConfigInstance = ({ imageCompression, userMention, voiceMessage }: SendbirdUIKitContainerProps) => {
381
+ const mentionConfig = useMemo(() => {
382
+ return new MentionConfig({
383
+ mentionLimit: userMention?.mentionLimit || MentionConfig.DEFAULT.MENTION_LIMIT,
384
+ suggestionLimit: userMention?.suggestionLimit || MentionConfig.DEFAULT.SUGGESTION_LIMIT,
385
+ debounceMills: userMention?.debounceMills ?? MentionConfig.DEFAULT.DEBOUNCE_MILLS,
386
+ delimiter: MentionConfig.DEFAULT.DELIMITER,
387
+ trigger: MentionConfig.DEFAULT.TRIGGER,
388
+ });
389
+ }, [userMention?.mentionLimit, userMention?.suggestionLimit, userMention?.debounceMills]);
390
+
391
+ const imageCompressionConfig = useMemo(() => {
392
+ return new ImageCompressionConfig({
393
+ compressionRate: imageCompression?.compressionRate || ImageCompressionConfig.DEFAULT.COMPRESSION_RATE,
394
+ width: imageCompression?.width,
395
+ height: imageCompression?.height,
396
+ });
397
+ }, [imageCompression?.compressionRate, imageCompression?.width, imageCompression?.height]);
398
+
399
+ const voiceMessageConfig = useMemo(() => {
400
+ return new VoiceMessageConfig({
401
+ recorder: {
402
+ minDuration: voiceMessage?.recorder?.minDuration ?? VoiceMessageConfig.DEFAULT.RECORDER.MIN_DURATION,
403
+ maxDuration: voiceMessage?.recorder?.maxDuration ?? VoiceMessageConfig.DEFAULT.RECORDER.MAX_DURATION,
404
+ },
405
+ });
406
+ }, [voiceMessage?.recorder?.minDuration, voiceMessage?.recorder?.maxDuration]);
407
+
408
+ return {
409
+ mentionConfig,
410
+ imageCompressionConfig,
411
+ voiceMessageConfig,
412
+ };
413
+ };
414
+
371
415
  export default SendbirdUIKitContainer;
@@ -1,37 +1,39 @@
1
- import React from 'react';
1
+ import React, { useEffect } from 'react';
2
2
 
3
+ import { useAppState } from '@sendbird/uikit-utils';
4
+
5
+ import VoiceMessageConfig from '../libs/VoiceMessageConfig';
3
6
  import type {
4
7
  ClipboardServiceInterface,
5
8
  FileServiceInterface,
6
9
  MediaServiceInterface,
7
10
  NotificationServiceInterface,
11
+ PlayerServiceInterface,
12
+ RecorderServiceInterface,
8
13
  } from '../platform/types';
9
14
 
10
- type Props = React.PropsWithChildren<{
11
- fileService: FileServiceInterface;
12
- clipboardService: ClipboardServiceInterface;
13
- notificationService: NotificationServiceInterface;
14
- mediaService: MediaServiceInterface;
15
- }>;
16
-
17
15
  export type PlatformServiceContextType = {
18
16
  fileService: FileServiceInterface;
19
17
  clipboardService: ClipboardServiceInterface;
20
18
  notificationService: NotificationServiceInterface;
21
19
  mediaService: MediaServiceInterface;
20
+ recorderService: RecorderServiceInterface;
21
+ playerService: PlayerServiceInterface;
22
22
  };
23
+ type Props = React.PropsWithChildren<PlatformServiceContextType & { voiceMessageConfig: VoiceMessageConfig }>;
23
24
 
24
25
  export const PlatformServiceContext = React.createContext<PlatformServiceContextType | null>(null);
25
- export const PlatformServiceProvider = ({
26
- children,
27
- fileService,
28
- clipboardService,
29
- notificationService,
30
- mediaService,
31
- }: Props) => {
32
- return (
33
- <PlatformServiceContext.Provider value={{ fileService, clipboardService, notificationService, mediaService }}>
34
- {children}
35
- </PlatformServiceContext.Provider>
36
- );
26
+ export const PlatformServiceProvider = ({ children, voiceMessageConfig, ...services }: Props) => {
27
+ useEffect(() => {
28
+ services.recorderService.options.minDuration = voiceMessageConfig.recorder.minDuration;
29
+ services.recorderService.options.maxDuration = voiceMessageConfig.recorder.maxDuration;
30
+ }, [voiceMessageConfig]);
31
+
32
+ useAppState('change', (state) => {
33
+ if (state !== 'active') {
34
+ Promise.allSettled([services.playerService.reset(), services.recorderService.reset()]);
35
+ }
36
+ });
37
+
38
+ return <PlatformServiceContext.Provider value={services}>{children}</PlatformServiceContext.Provider>;
37
39
  };
@@ -3,7 +3,7 @@ import React, { useCallback, useContext, useReducer, useRef, useState } from 're
3
3
  import type { SendbirdBaseChannel, SendbirdBaseMessage } from '@sendbird/uikit-utils';
4
4
  import { NOOP } from '@sendbird/uikit-utils';
5
5
 
6
- import { ReactionBottomSheets } from '../components/ReactionBottomSheets';
6
+ import { ReactionBottomSheetProps, ReactionBottomSheets } from '../components/ReactionBottomSheets';
7
7
  import { LocalizationContext } from '../contexts/LocalizationCtx';
8
8
  import { SendbirdChatContext } from '../contexts/SendbirdChatCtx';
9
9
  import { UserProfileContext } from '../contexts/UserProfileCtx';
@@ -19,10 +19,12 @@ export type ReactionContextType = {
19
19
  focusIndex: number;
20
20
  } & State;
21
21
 
22
- type Props = React.PropsWithChildren<{}>;
22
+ type Props = React.PropsWithChildren<{
23
+ onPressUserProfile?: ReactionBottomSheetProps['onPressUserProfile'];
24
+ }>;
23
25
 
24
26
  export const ReactionContext = React.createContext<ReactionContextType | null>(null);
25
- export const ReactionProvider = ({ children }: Props) => {
27
+ export const ReactionProvider = ({ children, onPressUserProfile }: Props) => {
26
28
  const chatCtx = useContext(SendbirdChatContext);
27
29
  const localizationCtx = useContext(LocalizationContext);
28
30
  const userProfileCtx = useContext(UserProfileContext);
@@ -73,11 +75,11 @@ export const ReactionProvider = ({ children }: Props) => {
73
75
  focusIndex: reactionUserListFocusIndex,
74
76
  };
75
77
 
76
- const sheetProps = {
78
+ const sheetProps: Omit<ReactionBottomSheetProps, 'visible' | 'onClose'> = {
77
79
  chatCtx,
78
80
  reactionCtx,
79
81
  localizationCtx,
80
- userProfileCtx,
82
+ onPressUserProfile: onPressUserProfile ?? userProfileCtx.show,
81
83
  onDismiss: () => {
82
84
  setState({});
83
85
  closeResolver.current?.();
@@ -13,6 +13,7 @@ import { confirmAndMarkAsDelivered, useAppState, useForceUpdate } from '@sendbir
13
13
  import type EmojiManager from '../libs/EmojiManager';
14
14
  import type ImageCompressionConfig from '../libs/ImageCompressionConfig';
15
15
  import type MentionManager from '../libs/MentionManager';
16
+ import type VoiceMessageConfig from '../libs/VoiceMessageConfig';
16
17
  import type { FileType } from '../platform/types';
17
18
 
18
19
  export interface ChatRelatedFeaturesInUIKit {
@@ -23,18 +24,23 @@ export interface ChatRelatedFeaturesInUIKit {
23
24
 
24
25
  interface Props extends ChatRelatedFeaturesInUIKit, React.PropsWithChildren {
25
26
  sdkInstance: SendbirdChatSDK;
27
+
26
28
  emojiManager: EmojiManager;
27
29
  mentionManager: MentionManager;
28
30
  imageCompressionConfig: ImageCompressionConfig;
31
+ voiceMessageConfig: VoiceMessageConfig;
29
32
  }
30
33
 
31
34
  export type SendbirdChatContextType = {
32
35
  sdk: SendbirdChatSDK;
36
+ currentUser?: SendbirdUser;
37
+ setCurrentUser: React.Dispatch<React.SetStateAction<SendbirdUser | undefined>>;
38
+
39
+ // feature related instances
33
40
  emojiManager: EmojiManager;
34
41
  mentionManager: MentionManager;
35
42
  imageCompressionConfig: ImageCompressionConfig;
36
- currentUser?: SendbirdUser;
37
- setCurrentUser: React.Dispatch<React.SetStateAction<SendbirdUser | undefined>>;
43
+ voiceMessageConfig: VoiceMessageConfig;
38
44
 
39
45
  // helper functions
40
46
  updateCurrentUserInfo: (nickname?: string, profile?: string | FileType) => Promise<SendbirdUser>;
@@ -84,6 +90,7 @@ export const SendbirdChatProvider = ({
84
90
  emojiManager,
85
91
  mentionManager,
86
92
  imageCompressionConfig,
93
+ voiceMessageConfig,
87
94
  enableAutoPushTokenRegistration,
88
95
  enableUseUserIdForNickname,
89
96
  enableImageCompression,
@@ -155,6 +162,7 @@ export const SendbirdChatProvider = ({
155
162
  emojiManager,
156
163
  mentionManager,
157
164
  imageCompressionConfig,
165
+ voiceMessageConfig,
158
166
  currentUser,
159
167
  setCurrentUser,
160
168
 
@@ -1,5 +1,4 @@
1
- import React, { useContext, useEffect, useRef } from 'react';
2
- import type { FlatList } from 'react-native';
1
+ import React, { useContext, useEffect } from 'react';
3
2
 
4
3
  import { useChannelHandler } from '@sendbird/uikit-chat-hooks';
5
4
  import { useToast } from '@sendbird/uikit-react-native-foundation';
@@ -18,45 +17,32 @@ const GroupChannelMessageList = (props: GroupChannelProps['MessageList']) => {
18
17
  const { sdk } = useSendbirdChat();
19
18
  const { setMessageToEdit, setMessageToReply } = useContext(GroupChannelContexts.Fragment);
20
19
  const { subscribe } = useContext(GroupChannelContexts.PubSub);
20
+ const { flatListRef, lazyScrollToBottom, lazyScrollToIndex } = useContext(GroupChannelContexts.MessageList);
21
21
 
22
22
  const id = useUniqHandlerId('GroupChannelMessageList');
23
- const ref = useRef<FlatList<SendbirdMessage>>(null);
24
23
  const isFirstMount = useIsFirstMount();
25
24
 
26
- // FIXME: Workaround, should run after data has been applied to UI.
27
- const lazyScrollToBottom = (animated = false, timeout = 0) => {
28
- setTimeout(() => {
29
- ref.current?.scrollToOffset({ offset: 0, animated });
30
- }, timeout);
31
- };
25
+ const scrollToMessageWithCreatedAt = useFreshCallback(
26
+ (createdAt: number, focusAnimated: boolean, timeout: number): boolean => {
27
+ const foundMessageIndex = props.messages.findIndex((it) => it.createdAt === createdAt);
28
+ const isIncludedInList = foundMessageIndex > -1;
32
29
 
33
- // FIXME: Workaround, should run after data has been applied to UI.
34
- const lazyScrollToIndex = (index = 0, animated = false, timeout = 0) => {
35
- setTimeout(() => {
36
- ref.current?.scrollToIndex({ index, animated, viewPosition: 0.5 });
37
- }, timeout);
38
- };
39
-
40
- const scrollToMessage = useFreshCallback((createdAt: number, focusAnimated = false): boolean => {
41
- const foundMessageIndex = props.messages.findIndex((it) => it.createdAt === createdAt);
42
- const isIncludedInList = foundMessageIndex > -1;
43
-
44
- if (isIncludedInList) {
45
- if (focusAnimated) {
46
- setTimeout(() => props.onUpdateSearchItem({ startingPoint: createdAt }), MESSAGE_FOCUS_ANIMATION_DELAY);
47
- }
48
- lazyScrollToIndex(foundMessageIndex, true, isFirstMount ? MESSAGE_SEARCH_SAFE_SCROLL_DELAY : 0);
49
- } else {
50
- if (props.channel.messageOffsetTimestamp <= createdAt) {
51
- if (focusAnimated) props.onUpdateSearchItem({ startingPoint: createdAt });
52
- props.onResetMessageListWithStartingPoint(createdAt);
30
+ if (isIncludedInList) {
31
+ if (focusAnimated) {
32
+ setTimeout(() => props.onUpdateSearchItem({ startingPoint: createdAt }), MESSAGE_FOCUS_ANIMATION_DELAY);
33
+ }
34
+ lazyScrollToIndex({ index: foundMessageIndex, animated: true, timeout });
53
35
  } else {
54
- return false;
36
+ if (props.channel.messageOffsetTimestamp <= createdAt) {
37
+ if (focusAnimated) props.onUpdateSearchItem({ startingPoint: createdAt });
38
+ props.onResetMessageListWithStartingPoint(createdAt);
39
+ } else {
40
+ return false;
41
+ }
55
42
  }
56
- }
57
-
58
- return true;
59
- });
43
+ return true;
44
+ },
45
+ );
60
46
 
61
47
  const scrollToBottom = useFreshCallback((animated = false) => {
62
48
  if (props.hasNext()) {
@@ -65,10 +51,10 @@ const GroupChannelMessageList = (props: GroupChannelProps['MessageList']) => {
65
51
 
66
52
  props.onResetMessageList(() => {
67
53
  props.onScrolledAwayFromBottom(false);
68
- lazyScrollToBottom(animated);
54
+ lazyScrollToBottom({ animated });
69
55
  });
70
56
  } else {
71
- lazyScrollToBottom(animated);
57
+ lazyScrollToBottom({ animated });
72
58
  }
73
59
  });
74
60
 
@@ -79,7 +65,7 @@ const GroupChannelMessageList = (props: GroupChannelProps['MessageList']) => {
79
65
  const isRecentMessage = recentMessage && recentMessage.messageId === event.messageId;
80
66
  const scrollReachedBottomAndCanScroll = !props.scrolledAwayFromBottom && !props.hasNext();
81
67
  if (isRecentMessage && scrollReachedBottomAndCanScroll) {
82
- lazyScrollToBottom(true, 250);
68
+ lazyScrollToBottom({ animated: true, timeout: 250 });
83
69
  }
84
70
  },
85
71
  });
@@ -102,24 +88,24 @@ const GroupChannelMessageList = (props: GroupChannelProps['MessageList']) => {
102
88
  });
103
89
  }, [props.scrolledAwayFromBottom]);
104
90
 
105
- // Only trigger once when message list mount with initial props.searchItem
106
- // - Search screen + searchItem > mount message list
107
- // - Reset message list + searchItem > re-mount message list
108
91
  useEffect(() => {
92
+ // Only trigger once when message list mount with initial props.searchItem
93
+ // - Search screen + searchItem > mount message list
94
+ // - Reset message list + searchItem > re-mount message list
109
95
  if (isFirstMount && props.searchItem) {
110
- scrollToMessage(props.searchItem.startingPoint);
96
+ scrollToMessageWithCreatedAt(props.searchItem.startingPoint, false, MESSAGE_SEARCH_SAFE_SCROLL_DELAY);
111
97
  }
112
98
  }, [isFirstMount]);
113
99
 
114
100
  const onPressParentMessage = useFreshCallback((message: SendbirdMessage) => {
115
- const canScrollToParent = scrollToMessage(message.createdAt, true);
101
+ const canScrollToParent = scrollToMessageWithCreatedAt(message.createdAt, true, 0);
116
102
  if (!canScrollToParent) toast.show(STRINGS.TOAST.FIND_PARENT_MSG_ERROR, 'error');
117
103
  });
118
104
 
119
105
  return (
120
106
  <ChannelMessageList
121
107
  {...props}
122
- ref={ref}
108
+ ref={flatListRef}
123
109
  onReplyMessage={setMessageToReply}
124
110
  onEditMessage={setMessageToEdit}
125
111
  onPressParentMessage={onPressParentMessage}