chat 1.0.8 → 4.0.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 (327) hide show
  1. package/dist/chunk-ACQNDPTB.js +356 -0
  2. package/dist/chunk-ACQNDPTB.js.map +1 -0
  3. package/dist/index.d.ts +1312 -0
  4. package/dist/index.js +1433 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/jsx-runtime-D7zHSnXe.d.ts +349 -0
  7. package/dist/jsx-runtime.d.ts +1 -0
  8. package/dist/jsx-runtime.js +17 -0
  9. package/dist/jsx-runtime.js.map +1 -0
  10. package/package.json +61 -97
  11. package/lib/module/ChatContext/index.js +0 -2
  12. package/lib/module/ChatContext/index.js.map +0 -1
  13. package/lib/module/ChatContext/types.js +0 -2
  14. package/lib/module/ChatContext/types.js.map +0 -1
  15. package/lib/module/classes/Chat/index.js +0 -2
  16. package/lib/module/classes/Chat/index.js.map +0 -1
  17. package/lib/module/classes/Chat/types.js +0 -2
  18. package/lib/module/classes/Chat/types.js.map +0 -1
  19. package/lib/module/classes/Inbox/index.js +0 -2
  20. package/lib/module/classes/Inbox/index.js.map +0 -1
  21. package/lib/module/classes/Inbox/types.js +0 -2
  22. package/lib/module/classes/Inbox/types.js.map +0 -1
  23. package/lib/module/classes/Message/index.js +0 -2
  24. package/lib/module/classes/Message/index.js.map +0 -1
  25. package/lib/module/classes/Message/types.js +0 -2
  26. package/lib/module/classes/Message/types.js.map +0 -1
  27. package/lib/module/classes/Reaction/index.js +0 -2
  28. package/lib/module/classes/Reaction/index.js.map +0 -1
  29. package/lib/module/classes/Reaction/types.js +0 -2
  30. package/lib/module/classes/Reaction/types.js.map +0 -1
  31. package/lib/module/classes/Room/index.js +0 -2
  32. package/lib/module/classes/Room/index.js.map +0 -1
  33. package/lib/module/classes/Room/types.js +0 -2
  34. package/lib/module/classes/Room/types.js.map +0 -1
  35. package/lib/module/classes/index.js +0 -2
  36. package/lib/module/classes/index.js.map +0 -1
  37. package/lib/module/components/Avatar/index.js +0 -2
  38. package/lib/module/components/Avatar/index.js.map +0 -1
  39. package/lib/module/components/Chat/Bubble/index.js +0 -2
  40. package/lib/module/components/Chat/Bubble/index.js.map +0 -1
  41. package/lib/module/components/Chat/Composer/Input/index.js +0 -2
  42. package/lib/module/components/Chat/Composer/Input/index.js.map +0 -1
  43. package/lib/module/components/Chat/Composer/Send/index.js +0 -2
  44. package/lib/module/components/Chat/Composer/Send/index.js.map +0 -1
  45. package/lib/module/components/Chat/Composer/index.js +0 -2
  46. package/lib/module/components/Chat/Composer/index.js.map +0 -1
  47. package/lib/module/components/Chat/Media/Image/index.js +0 -2
  48. package/lib/module/components/Chat/Media/Image/index.js.map +0 -1
  49. package/lib/module/components/Chat/Media/index.js +0 -2
  50. package/lib/module/components/Chat/Media/index.js.map +0 -1
  51. package/lib/module/components/Chat/Message/Swiper/Action/index.js +0 -2
  52. package/lib/module/components/Chat/Message/Swiper/Action/index.js.map +0 -1
  53. package/lib/module/components/Chat/Message/Swiper/index.js +0 -2
  54. package/lib/module/components/Chat/Message/Swiper/index.js.map +0 -1
  55. package/lib/module/components/Chat/Message/Touchable/index.js +0 -2
  56. package/lib/module/components/Chat/Message/Touchable/index.js.map +0 -1
  57. package/lib/module/components/Chat/Message/index.js +0 -2
  58. package/lib/module/components/Chat/Message/index.js.map +0 -1
  59. package/lib/module/components/Chat/SystemMessage/index.js +0 -2
  60. package/lib/module/components/Chat/SystemMessage/index.js.map +0 -1
  61. package/lib/module/components/Chat/TypingFooter/index.js +0 -2
  62. package/lib/module/components/Chat/TypingFooter/index.js.map +0 -1
  63. package/lib/module/components/Chat/index.js +0 -2
  64. package/lib/module/components/Chat/index.js.map +0 -1
  65. package/lib/module/components/Chat/types.js +0 -2
  66. package/lib/module/components/Chat/types.js.map +0 -1
  67. package/lib/module/components/Chat-Old/Bubble/index.js +0 -2
  68. package/lib/module/components/Chat-Old/Bubble/index.js.map +0 -1
  69. package/lib/module/components/Chat-Old/Composer/Input/index.js +0 -2
  70. package/lib/module/components/Chat-Old/Composer/Input/index.js.map +0 -1
  71. package/lib/module/components/Chat-Old/Composer/Send/index.js +0 -2
  72. package/lib/module/components/Chat-Old/Composer/Send/index.js.map +0 -1
  73. package/lib/module/components/Chat-Old/Composer/index.js +0 -2
  74. package/lib/module/components/Chat-Old/Composer/index.js.map +0 -1
  75. package/lib/module/components/Chat-Old/Message/index.js +0 -2
  76. package/lib/module/components/Chat-Old/Message/index.js.map +0 -1
  77. package/lib/module/components/Chat-Old/Swiper/Action/index.js +0 -2
  78. package/lib/module/components/Chat-Old/Swiper/Action/index.js.map +0 -1
  79. package/lib/module/components/Chat-Old/Swiper/index.js +0 -2
  80. package/lib/module/components/Chat-Old/Swiper/index.js.map +0 -1
  81. package/lib/module/components/Chat-Old/SystemMessage/index.js +0 -2
  82. package/lib/module/components/Chat-Old/SystemMessage/index.js.map +0 -1
  83. package/lib/module/components/Chat-Old/index.js +0 -2
  84. package/lib/module/components/Chat-Old/index.js.map +0 -1
  85. package/lib/module/components/Chat-Old/types.js +0 -2
  86. package/lib/module/components/Chat-Old/types.js.map +0 -1
  87. package/lib/module/components/ChatProvider/index.js +0 -2
  88. package/lib/module/components/ChatProvider/index.js.map +0 -1
  89. package/lib/module/components/ChatProvider/types.js +0 -2
  90. package/lib/module/components/ChatProvider/types.js.map +0 -1
  91. package/lib/module/components/Inbox/Item/Circle/index.js +0 -2
  92. package/lib/module/components/Inbox/Item/Circle/index.js.map +0 -1
  93. package/lib/module/components/Inbox/Item/Circle/types.js +0 -2
  94. package/lib/module/components/Inbox/Item/Circle/types.js.map +0 -1
  95. package/lib/module/components/Inbox/Item/Initials/index.js +0 -2
  96. package/lib/module/components/Inbox/Item/Initials/index.js.map +0 -1
  97. package/lib/module/components/Inbox/Item/ItemDate/index.js +0 -2
  98. package/lib/module/components/Inbox/Item/ItemDate/index.js.map +0 -1
  99. package/lib/module/components/Inbox/Item/Separator/index.js +0 -2
  100. package/lib/module/components/Inbox/Item/Separator/index.js.map +0 -1
  101. package/lib/module/components/Inbox/Item/Subtitle/index.js +0 -2
  102. package/lib/module/components/Inbox/Item/Subtitle/index.js.map +0 -1
  103. package/lib/module/components/Inbox/Item/Swipeable/index.js +0 -2
  104. package/lib/module/components/Inbox/Item/Swipeable/index.js.map +0 -1
  105. package/lib/module/components/Inbox/Item/Title/index.js +0 -2
  106. package/lib/module/components/Inbox/Item/Title/index.js.map +0 -1
  107. package/lib/module/components/Inbox/Item/UnreadIndicator/index.js +0 -2
  108. package/lib/module/components/Inbox/Item/UnreadIndicator/index.js.map +0 -1
  109. package/lib/module/components/Inbox/Item/index.js +0 -2
  110. package/lib/module/components/Inbox/Item/index.js.map +0 -1
  111. package/lib/module/components/Inbox/index.js +0 -2
  112. package/lib/module/components/Inbox/index.js.map +0 -1
  113. package/lib/module/components/Inbox/question.md +0 -21
  114. package/lib/module/components/Inbox/readme.md +0 -21
  115. package/lib/module/components/Inbox/types.js +0 -2
  116. package/lib/module/components/Inbox/types.js.map +0 -1
  117. package/lib/module/components/RoomCreator/Content/Footer/Button/index.js +0 -2
  118. package/lib/module/components/RoomCreator/Content/Footer/Button/index.js.map +0 -1
  119. package/lib/module/components/RoomCreator/Content/Footer/Input/index.js +0 -2
  120. package/lib/module/components/RoomCreator/Content/Footer/Input/index.js.map +0 -1
  121. package/lib/module/components/RoomCreator/Content/Footer/index.js +0 -2
  122. package/lib/module/components/RoomCreator/Content/Footer/index.js.map +0 -1
  123. package/lib/module/components/RoomCreator/Content/Item/Icon/index.js +0 -2
  124. package/lib/module/components/RoomCreator/Content/Item/Icon/index.js.map +0 -1
  125. package/lib/module/components/RoomCreator/Content/Item/index.js +0 -2
  126. package/lib/module/components/RoomCreator/Content/Item/index.js.map +0 -1
  127. package/lib/module/components/RoomCreator/Content/index.js +0 -2
  128. package/lib/module/components/RoomCreator/Content/index.js.map +0 -1
  129. package/lib/module/components/RoomCreator/Header/index.js +0 -2
  130. package/lib/module/components/RoomCreator/Header/index.js.map +0 -1
  131. package/lib/module/components/RoomCreator/index.js +0 -2
  132. package/lib/module/components/RoomCreator/index.js.map +0 -1
  133. package/lib/module/components/RoomCreator/types.js +0 -2
  134. package/lib/module/components/RoomCreator/types.js.map +0 -1
  135. package/lib/module/components/TypingIndicator/index.js +0 -2
  136. package/lib/module/components/TypingIndicator/index.js.map +0 -1
  137. package/lib/module/components/index.js +0 -2
  138. package/lib/module/components/index.js.map +0 -1
  139. package/lib/module/helpers/getInitials.js +0 -2
  140. package/lib/module/helpers/getInitials.js.map +0 -1
  141. package/lib/module/helpers/sortByAvatar.js +0 -2
  142. package/lib/module/helpers/sortByAvatar.js.map +0 -1
  143. package/lib/module/hooks/index.js +0 -2
  144. package/lib/module/hooks/index.js.map +0 -1
  145. package/lib/module/hooks/useCreateRoom/index.js +0 -2
  146. package/lib/module/hooks/useCreateRoom/index.js.map +0 -1
  147. package/lib/module/hooks/useCreator/index.js +0 -2
  148. package/lib/module/hooks/useCreator/index.js.map +0 -1
  149. package/lib/module/hooks/useInbox/index.js +0 -2
  150. package/lib/module/hooks/useInbox/index.js.map +0 -1
  151. package/lib/module/hooks/useInbox/types.js +0 -2
  152. package/lib/module/hooks/useInbox/types.js.map +0 -1
  153. package/lib/module/hooks/useMessages/index.js +0 -2
  154. package/lib/module/hooks/useMessages/index.js.map +0 -1
  155. package/lib/module/hooks/useMessages/types.js +0 -2
  156. package/lib/module/hooks/useMessages/types.js.map +0 -1
  157. package/lib/module/hooks/useRoom/index.js +0 -2
  158. package/lib/module/hooks/useRoom/index.js.map +0 -1
  159. package/lib/module/hooks/useRoom/types.js +0 -2
  160. package/lib/module/hooks/useRoom/types.js.map +0 -1
  161. package/lib/module/hooks/useSend/useSendToGroup/index.js +0 -2
  162. package/lib/module/hooks/useSend/useSendToGroup/index.js.map +0 -1
  163. package/lib/module/hooks/useSend/useSendToPeople/index.js +0 -2
  164. package/lib/module/hooks/useSend/useSendToPeople/index.js.map +0 -1
  165. package/lib/module/hooks/useTyping/index.js +0 -2
  166. package/lib/module/hooks/useTyping/index.js.map +0 -1
  167. package/lib/module/hooks/useTypingOLD/index.js +0 -2
  168. package/lib/module/hooks/useTypingOLD/index.js.map +0 -1
  169. package/lib/module/hooks/useTypingOLD/types.js +0 -2
  170. package/lib/module/hooks/useTypingOLD/types.js.map +0 -1
  171. package/lib/module/hooks/useViewMessages/index.js +0 -2
  172. package/lib/module/hooks/useViewMessages/index.js.map +0 -1
  173. package/lib/module/hooks/useViewMessages/types.js +0 -2
  174. package/lib/module/hooks/useViewMessages/types.js.map +0 -1
  175. package/lib/module/hooks/useViewMessagesOld/index.js +0 -2
  176. package/lib/module/hooks/useViewMessagesOld/index.js.map +0 -1
  177. package/lib/module/index.js +0 -2
  178. package/lib/module/index.js.map +0 -1
  179. package/lib/typescript/ChatContext/index.d.ts +0 -2
  180. package/lib/typescript/ChatContext/types.d.ts +0 -4
  181. package/lib/typescript/classes/Chat/index.d.ts +0 -14
  182. package/lib/typescript/classes/Chat/types.d.ts +0 -21
  183. package/lib/typescript/classes/Inbox/types.d.ts +0 -2
  184. package/lib/typescript/classes/Message/index.d.ts +0 -47
  185. package/lib/typescript/classes/Message/types.d.ts +0 -66
  186. package/lib/typescript/classes/Reaction/index.d.ts +0 -17
  187. package/lib/typescript/classes/Reaction/types.d.ts +0 -33
  188. package/lib/typescript/classes/Room/index.d.ts +0 -42
  189. package/lib/typescript/classes/Room/types.d.ts +0 -112
  190. package/lib/typescript/classes/index.d.ts +0 -4
  191. package/lib/typescript/components/Avatar/index.d.ts +0 -4
  192. package/lib/typescript/components/Chat/Bubble/index.d.ts +0 -4
  193. package/lib/typescript/components/Chat/Composer/Input/index.d.ts +0 -7
  194. package/lib/typescript/components/Chat/Composer/Send/index.d.ts +0 -4
  195. package/lib/typescript/components/Chat/Composer/index.d.ts +0 -8
  196. package/lib/typescript/components/Chat/Media/Image/index.d.ts +0 -7
  197. package/lib/typescript/components/Chat/Media/index.d.ts +0 -4
  198. package/lib/typescript/components/Chat/Message/Touchable/index.d.ts +0 -4
  199. package/lib/typescript/components/Chat/Message/index.d.ts +0 -8
  200. package/lib/typescript/components/Chat/SystemMessage/index.d.ts +0 -4
  201. package/lib/typescript/components/Chat/TypingFooter/index.d.ts +0 -4
  202. package/lib/typescript/components/Chat/index.d.ts +0 -8
  203. package/lib/typescript/components/Chat/types.d.ts +0 -843
  204. package/lib/typescript/components/ChatProvider/index.d.ts +0 -10
  205. package/lib/typescript/components/ChatProvider/types.d.ts +0 -7
  206. package/lib/typescript/components/Inbox/Item/Initials/index.d.ts +0 -4
  207. package/lib/typescript/components/Inbox/Item/ItemDate/index.d.ts +0 -4
  208. package/lib/typescript/components/Inbox/Item/Separator/index.d.ts +0 -6
  209. package/lib/typescript/components/Inbox/Item/Subtitle/index.d.ts +0 -3
  210. package/lib/typescript/components/Inbox/Item/Swipeable/index.d.ts +0 -4
  211. package/lib/typescript/components/Inbox/Item/Title/index.d.ts +0 -3
  212. package/lib/typescript/components/Inbox/Item/UnreadIndicator/index.d.ts +0 -4
  213. package/lib/typescript/components/Inbox/Item/index.d.ts +0 -6
  214. package/lib/typescript/components/Inbox/index.d.ts +0 -4
  215. package/lib/typescript/components/Inbox/types.d.ts +0 -304
  216. package/lib/typescript/components/RoomCreator/Content/Footer/Button/index.d.ts +0 -4
  217. package/lib/typescript/components/RoomCreator/Content/Footer/Input/index.d.ts +0 -4
  218. package/lib/typescript/components/RoomCreator/Content/Footer/index.d.ts +0 -3
  219. package/lib/typescript/components/RoomCreator/Content/Item/Icon/index.d.ts +0 -4
  220. package/lib/typescript/components/RoomCreator/Content/Item/index.d.ts +0 -4
  221. package/lib/typescript/components/RoomCreator/Content/index.d.ts +0 -4
  222. package/lib/typescript/components/RoomCreator/Header/index.d.ts +0 -4
  223. package/lib/typescript/components/RoomCreator/index.d.ts +0 -4
  224. package/lib/typescript/components/RoomCreator/types.d.ts +0 -208
  225. package/lib/typescript/components/TypingIndicator/index.d.ts +0 -9
  226. package/lib/typescript/components/index.d.ts +0 -12
  227. package/lib/typescript/helpers/getInitials.d.ts +0 -1
  228. package/lib/typescript/hooks/index.d.ts +0 -8
  229. package/lib/typescript/hooks/useCreator/index.d.ts +0 -27
  230. package/lib/typescript/hooks/useInbox/index.d.ts +0 -29
  231. package/lib/typescript/hooks/useInbox/types.d.ts +0 -5
  232. package/lib/typescript/hooks/useMessages/index.d.ts +0 -24
  233. package/lib/typescript/hooks/useMessages/types.d.ts +0 -5
  234. package/lib/typescript/hooks/useRoom/index.d.ts +0 -26
  235. package/lib/typescript/hooks/useRoom/types.d.ts +0 -5
  236. package/lib/typescript/hooks/useSend/useSendToGroup/index.d.ts +0 -6
  237. package/lib/typescript/hooks/useSend/useSendToPeople/index.d.ts +0 -6
  238. package/lib/typescript/hooks/useTyping/index.d.ts +0 -36
  239. package/lib/typescript/hooks/useViewMessages/index.d.ts +0 -18
  240. package/lib/typescript/hooks/useViewMessages/types.d.ts +0 -20
  241. package/lib/typescript/index.d.ts +0 -11
  242. package/readme.md +0 -201
  243. package/src/ChatContext/index.tsx +0 -9
  244. package/src/ChatContext/types.ts +0 -4
  245. package/src/classes/Chat/index.ts +0 -46
  246. package/src/classes/Chat/types.ts +0 -23
  247. package/src/classes/Inbox/index.ts +0 -12
  248. package/src/classes/Inbox/types.ts +0 -3
  249. package/src/classes/Message/index.ts +0 -310
  250. package/src/classes/Message/types.ts +0 -118
  251. package/src/classes/Reaction/index.ts +0 -108
  252. package/src/classes/Reaction/types.ts +0 -37
  253. package/src/classes/Room/index.ts +0 -323
  254. package/src/classes/Room/types.ts +0 -161
  255. package/src/classes/index.ts +0 -4
  256. package/src/components/Avatar/index.tsx +0 -25
  257. package/src/components/Chat/Bubble/index.tsx +0 -139
  258. package/src/components/Chat/Composer/Input/index.tsx +0 -45
  259. package/src/components/Chat/Composer/Send/index.tsx +0 -51
  260. package/src/components/Chat/Composer/index.tsx +0 -187
  261. package/src/components/Chat/Media/Image/index.tsx +0 -26
  262. package/src/components/Chat/Media/index.tsx +0 -11
  263. package/src/components/Chat/Message/Swiper/Action/index.tsx +0 -7
  264. package/src/components/Chat/Message/Swiper/index.tsx +0 -32
  265. package/src/components/Chat/Message/Touchable/index.tsx +0 -60
  266. package/src/components/Chat/Message/index.tsx +0 -328
  267. package/src/components/Chat/SystemMessage/index.tsx +0 -44
  268. package/src/components/Chat/TypingFooter/index.tsx +0 -48
  269. package/src/components/Chat/index.tsx +0 -596
  270. package/src/components/Chat/types.ts +0 -913
  271. package/src/components/Chat-Old/Bubble/index.tsx +0 -58
  272. package/src/components/Chat-Old/Composer/Input/index.tsx +0 -34
  273. package/src/components/Chat-Old/Composer/Send/index.tsx +0 -37
  274. package/src/components/Chat-Old/Composer/index.tsx +0 -131
  275. package/src/components/Chat-Old/Message/index.tsx +0 -160
  276. package/src/components/Chat-Old/Swiper/Action/index.tsx +0 -7
  277. package/src/components/Chat-Old/Swiper/index.tsx +0 -30
  278. package/src/components/Chat-Old/SystemMessage/index.tsx +0 -44
  279. package/src/components/Chat-Old/index.tsx +0 -356
  280. package/src/components/Chat-Old/types.ts +0 -752
  281. package/src/components/ChatProvider/index.tsx +0 -31
  282. package/src/components/ChatProvider/types.ts +0 -8
  283. package/src/components/Inbox/Item/Circle/index.tsx +0 -47
  284. package/src/components/Inbox/Item/Circle/types.ts +0 -8
  285. package/src/components/Inbox/Item/Initials/index.tsx +0 -41
  286. package/src/components/Inbox/Item/ItemDate/index.tsx +0 -26
  287. package/src/components/Inbox/Item/Separator/index.tsx +0 -13
  288. package/src/components/Inbox/Item/Subtitle/index.tsx +0 -23
  289. package/src/components/Inbox/Item/Swipeable/index.tsx +0 -143
  290. package/src/components/Inbox/Item/Title/index.tsx +0 -23
  291. package/src/components/Inbox/Item/UnreadIndicator/index.tsx +0 -84
  292. package/src/components/Inbox/Item/index.tsx +0 -307
  293. package/src/components/Inbox/index.tsx +0 -315
  294. package/src/components/Inbox/question.md +0 -21
  295. package/src/components/Inbox/readme.md +0 -21
  296. package/src/components/Inbox/types.ts +0 -371
  297. package/src/components/RoomCreator/Content/Footer/Button/index.tsx +0 -55
  298. package/src/components/RoomCreator/Content/Footer/Input/index.tsx +0 -27
  299. package/src/components/RoomCreator/Content/Footer/index.tsx +0 -72
  300. package/src/components/RoomCreator/Content/Item/Icon/index.tsx +0 -16
  301. package/src/components/RoomCreator/Content/Item/index.tsx +0 -87
  302. package/src/components/RoomCreator/Content/index.tsx +0 -75
  303. package/src/components/RoomCreator/Header/index.tsx +0 -74
  304. package/src/components/RoomCreator/index.tsx +0 -177
  305. package/src/components/RoomCreator/types.ts +0 -233
  306. package/src/components/TypingIndicator/index.tsx +0 -169
  307. package/src/components/index.ts +0 -18
  308. package/src/helpers/getInitials.ts +0 -11
  309. package/src/helpers/sortByAvatar.ts +0 -1
  310. package/src/hooks/index.ts +0 -8
  311. package/src/hooks/useCreateRoom/index.ts +0 -34
  312. package/src/hooks/useCreator/index.ts +0 -33
  313. package/src/hooks/useInbox/index.ts +0 -76
  314. package/src/hooks/useInbox/types.ts +0 -6
  315. package/src/hooks/useMessages/index.ts +0 -109
  316. package/src/hooks/useMessages/types.ts +0 -6
  317. package/src/hooks/useRoom/index.ts +0 -82
  318. package/src/hooks/useRoom/types.ts +0 -6
  319. package/src/hooks/useSend/useSendToGroup/index.ts +0 -38
  320. package/src/hooks/useSend/useSendToPeople/index.ts +0 -38
  321. package/src/hooks/useTyping/index.ts +0 -154
  322. package/src/hooks/useTypingOLD/index.ts +0 -67
  323. package/src/hooks/useTypingOLD/types.ts +0 -7
  324. package/src/hooks/useViewMessages/index.ts +0 -61
  325. package/src/hooks/useViewMessages/types.ts +0 -22
  326. package/src/hooks/useViewMessagesOld/index.ts +0 -39
  327. package/src/index.ts +0 -13
@@ -1,34 +0,0 @@
1
- import { useState, useRef, useEffect } from 'react'
2
- import { NewRoomModel } from '../../classes/Room/types'
3
- import Room from '../../classes/Room'
4
-
5
- function useCreateRoom<RoomModel extends NewRoomModel>() {
6
- const [loading, setLoading] = useState(false)
7
- const [error, setError] = useState(null)
8
- const roomRef = useRef<RoomModel | null>(null)
9
- const recipientsRef = useRef<string[] | null>(null)
10
-
11
- useEffect(() => {
12
- const start = async () => {
13
- if (loading && roomRef.current && recipientsRef.current) {
14
- try {
15
- roomRef.current = null
16
- recipientsRef.current = null
17
- await new Room(roomRef.current).create()
18
- } catch (e) {
19
- console.error('useCreateRoom hook error:', e)
20
- }
21
- }
22
- }
23
- start()
24
- }, [loading])
25
-
26
- const create = (room: RoomModel) => {
27
- roomRef.current = room
28
- setLoading(true)
29
- }
30
-
31
- return { create, loading, error }
32
- }
33
-
34
- export default useCreateRoom
@@ -1,33 +0,0 @@
1
- import { useRef, MutableRefObject } from 'react'
2
- import { RoomCreatorRef } from '../../components/RoomCreator/types'
3
-
4
- /**
5
- * React hook for managing RoomCreator component in usechat
6
- *
7
- * @returns An array with a ref and then convenience functions for the creator
8
- * [ref, { open, close }]
9
- *
10
- * **Required** In order for the methods to work, you must pass creator to sheetRef prop.
11
- *
12
- * @example
13
- * ```javascript
14
- * export default () => {
15
- * const [creator, { open, close }]
16
- *
17
- * // ...some other method
18
- * const onPress = () => open()
19
- *
20
- * return <RoomCreator sheetRef={creator} />
21
- * }
22
- * ```
23
- */
24
- export default (): [
25
- MutableRefObject<RoomCreatorRef | undefined>,
26
- { open: () => void; close: () => void }
27
- ] => {
28
- const creator = useRef<RoomCreatorRef>()
29
- const open = () => creator.current && creator.current.open()
30
- const close = () => creator.current && creator.current.close()
31
-
32
- return [creator, { open, close }]
33
- }
@@ -1,76 +0,0 @@
1
- import { useFuego } from '@nandorojo/fuego'
2
- import { useMemo } from 'react'
3
- import { WhereFilterOp } from '@firebase/firestore-types'
4
- import { QueryDataHandler } from '@nandorojo/fuego/lib/typescript/hooks/useFuego/types'
5
- import { OrderByItem } from '@nandorojo/fuego/lib/typescript/FuegoQuery/types'
6
- import { fuego } from '../../components/ChatProvider/index'
7
- import { chat } from '../../components/ChatProvider'
8
- import { ExistingRoomDocument } from '../../classes/Room/types'
9
- import { InboxModel } from '../../classes/Inbox/types'
10
- import { UseInboxConfig } from './types'
11
- import { Room } from '../..'
12
-
13
- const orderBy: OrderByItem = ['lastMessage.createdAt', 'desc']
14
-
15
- /**
16
- * React hook to query the chat inbox in realtime. Used with the [Juice.Inbox] component from Juice.
17
- *
18
- * @example
19
- * ```
20
- * const { data } = useInbox()
21
- *
22
- * return <Juice.Inbox rooms={data} />
23
- * ```
24
- *
25
- * @returns
26
- * { data, loading, path, error } and other values returned by useFuego() hook. Data is properly formatted for rendering.
27
- */
28
- export default (
29
- config: UseInboxConfig = {},
30
- options: QueryDataHandler<ExistingRoomDocument> = {}
31
- ) => {
32
- const currentUser = fuego.auth().currentUser as firebase.User
33
- const uid = config.uid || (currentUser && currentUser.uid)
34
-
35
- const where: [string, WhereFilterOp, string] = useMemo(() => {
36
- // useMemo to avoid re-making the array every render,
37
- // since that would refresh the useFuego each time
38
- return ['currentMembers', 'array-contains' as WhereFilterOp, uid]
39
- // if the uid updates, then it recreates
40
- // re: [uid]
41
- }, [uid])
42
-
43
- const path = chat.roomsCollection
44
- const query = useMemo(
45
- () => ({
46
- listen: true,
47
- where,
48
- orderBy,
49
- ...config,
50
- path
51
- }),
52
- [config, where, path]
53
- )
54
- const { data, ...response } = useFuego<ExistingRoomDocument>(query, options)
55
- const rooms = useMemo(() => {
56
- function isListOfRoomDocs(
57
- inbox: typeof data
58
- ): inbox is ExistingRoomDocument[] {
59
- return !!(inbox as ExistingRoomDocument[])
60
- }
61
- if (data && isListOfRoomDocs(data)) {
62
- const formatted: InboxModel = data.map(room => ({
63
- ...room,
64
- lastMessage: {
65
- ...room.lastMessage,
66
- createdAt: room.lastMessage.createdAt.toDate()
67
- },
68
- unreadCount: new Room(room).getUnreadCount()
69
- }))
70
- return formatted
71
- }
72
- return []
73
- }, [data])
74
-
75
- return { data: rooms, ...response, path }
76
- }
@@ -1,6 +0,0 @@
1
- import { FuegoQueryConfig } from '@nandorojo/fuego/lib/typescript/FuegoQuery/types'
2
-
3
- export interface UseInboxConfig extends Omit<FuegoQueryConfig, 'path'> {
4
- uid?: string
5
- listen?: boolean
6
- }
@@ -1,109 +0,0 @@
1
- import { useMemo, useCallback, useState, useEffect, useRef } from 'react'
2
- import { useFuego } from '@nandorojo/fuego'
3
- import { UseMessagesConfig } from './types'
4
- import Room from '../../classes/Room'
5
- import {
6
- NewMessageModel,
7
- EditMessageModel,
8
- MessageModelDocument,
9
- } from '../../classes/Message/types'
10
- import Message from '../../classes/Message'
11
- import {
12
- UseQueryConfig,
13
- QueryDataHandler,
14
- } from '@nandorojo/fuego/lib/typescript/hooks/useFuego/types'
15
-
16
- const LIMIT = 30
17
-
18
- const orderBy: UseQueryConfig['orderBy'] = ['createdAt', 'desc']
19
- /**
20
- * React hook to set up a lisener for a room's messages
21
- *
22
- * @param { id } the roomId, along with other query options from `useFuego` hook
23
- *
24
- * @returns { data: formattedMessages, loading, error, ref, path, empty, send, edit, fetchMore }
25
- * data is formatted for rendering.
26
- */
27
- export default (
28
- { id, ...config }: UseMessagesConfig,
29
- options: QueryDataHandler<MessageModelDocument> = {}
30
- ) => {
31
- const { messagesPath: path } = new Room({ id })
32
- const [limit, setLimit] = useState(LIMIT)
33
- const currentLimit = useRef(limit)
34
- const latestFetchMoreId = useRef<null | string>(null)
35
- const query = useMemo(
36
- () => ({
37
- listen: true,
38
- orderBy,
39
- ...config,
40
- path,
41
- limit,
42
- }),
43
- [path, config, limit]
44
- )
45
- useEffect(() => {
46
- currentLimit.current = limit
47
- }, [limit])
48
- const { data, loading, error, ref } = useFuego<MessageModelDocument>(
49
- query,
50
- options
51
- )
52
- const send = useCallback(
53
- (message: NewMessageModel[]) => {
54
- return new Message(message as NewMessageModel[]).formatForSend().send(id)
55
- },
56
- [id]
57
- )
58
- const edit = useCallback(
59
- (message: EditMessageModel) => {
60
- return new Message(message).edit(id)
61
- },
62
- [id]
63
- )
64
- const formattedMessages: NewMessageModel[] = useMemo(() => {
65
- function isArrayOfMessageDocuments(
66
- m: typeof data
67
- ): m is MessageModelDocument[] {
68
- return !!(m as MessageModelDocument[])
69
- }
70
- if (data && isArrayOfMessageDocuments(data)) {
71
- const formatted: NewMessageModel[] = new Message(
72
- data
73
- ).formatForRender() as NewMessageModel[]
74
- return formatted
75
- }
76
- return []
77
- }, [data])
78
- const fetchMore = () => {
79
- const lastMessageId =
80
- formattedMessages[formattedMessages.length - 1] &&
81
- formattedMessages[formattedMessages.length - 1].id
82
- // make sure we don't fetch more if the latest message is unchanged, or if it doesn't even exist
83
- if (lastMessageId && lastMessageId !== latestFetchMoreId.current) {
84
- latestFetchMoreId.current = lastMessageId
85
- setLimit(l => l + LIMIT)
86
- }
87
- }
88
- const empty: boolean = useMemo(
89
- () => !(formattedMessages && formattedMessages.length),
90
- [formattedMessages]
91
- )
92
-
93
- const fetchingMore = loading && formattedMessages.length
94
-
95
- // TODO add reply to message function
96
-
97
- return {
98
- data: formattedMessages,
99
- loading,
100
- error,
101
- ref,
102
- path,
103
- empty,
104
- send,
105
- edit,
106
- fetchMore,
107
- fetchingMore,
108
- }
109
- }
@@ -1,6 +0,0 @@
1
- import { FuegoQueryConfig } from '@nandorojo/fuego/lib/typescript/FuegoQuery/types'
2
-
3
- export interface UseMessagesConfig extends Omit<FuegoQueryConfig, 'path'> {
4
- id: string
5
- listen?: boolean
6
- }
@@ -1,82 +0,0 @@
1
- import { useFuego } from '@nandorojo/fuego'
2
- import Room from '../../classes/Room'
3
- import {
4
- EditRoomModel,
5
- RoomPropertiesModel,
6
- CreateCallableRoomModel,
7
- ExistingRoomDocument,
8
- ExistingRoomModel
9
- } from '../../classes/Room/types'
10
- import { UseRoomType } from './types'
11
- import { QueryDataHandler } from '@nandorojo/fuego/lib/typescript/hooks/useFuego/types'
12
- import { useMemo } from 'react'
13
-
14
- /**
15
- * Fetches or subscribes to a chatroom. It automatically handles unmounts, etc.
16
- *
17
- * @param config - config dictionary.
18
- * @param config.id - Required: the unique ID for this chatroom, typically generated by the backend. If using the [[useInbox]] hook, each item in [[useInbox]]'s data array has this ID.
19
- * @param config.listen Boolean to determine if this room should update state as a subscription. Default false.
20
- * @param options - added options dictionary for useRoom
21
- *
22
- * @remarks Look at the fuego library's useFuego hook to see all the available arguments for config and options.
23
- *
24
- * @returns { data: room, loading, error, ref, create, edit, usersAreTyping, namesOfUsersTyping } data is formatted for rendering room.
25
- */
26
-
27
- export default (
28
- { id, ...config }: UseRoomType,
29
- options: QueryDataHandler<ExistingRoomDocument> = {}
30
- ) => {
31
- const { path } = new Room({ id } as RoomPropertiesModel)
32
- const { data, loading, error, ref } = useFuego<ExistingRoomDocument>(
33
- {
34
- ...config,
35
- path
36
- },
37
- options
38
- )
39
- const create = (room: CreateCallableRoomModel) => {
40
- return new Room(room).createViaCallable()
41
- }
42
- const edit = (room: EditRoomModel) => {
43
- return new Room(room).edit()
44
- }
45
- const members = data && (data as ExistingRoomDocument).members
46
- const usersAreTyping = useMemo(() => {
47
- return !!(members && new Room({ members }).getUsersTyping().length)
48
- }, [members])
49
- const namesOfUsersTyping = useMemo(() => {
50
- return (
51
- (members &&
52
- new Room({ members }).getUsersTyping().map(user => user.name)) ||
53
- []
54
- )
55
- }, [members])
56
- const room = useMemo(() => {
57
- function isDocument(r: typeof data): r is ExistingRoomDocument {
58
- return !!(r as ExistingRoomDocument)
59
- }
60
- if (data && isDocument(data)) {
61
- const model: ExistingRoomModel = {
62
- ...data,
63
- lastMessage: {
64
- ...data.lastMessage,
65
- createdAt: data.lastMessage.createdAt.toDate()
66
- }
67
- }
68
- return model
69
- }
70
- return null
71
- }, [data])
72
- return {
73
- data: room,
74
- loading,
75
- error,
76
- ref,
77
- create,
78
- edit,
79
- usersAreTyping,
80
- namesOfUsersTyping
81
- }
82
- }
@@ -1,6 +0,0 @@
1
- import { FuegoQueryConfig } from '@nandorojo/fuego/lib/typescript/FuegoQuery/types'
2
-
3
- export interface UseRoomType extends Omit<FuegoQueryConfig, 'path'> {
4
- id: string
5
- listen?: boolean
6
- }
@@ -1,38 +0,0 @@
1
- import { useState, useRef, useEffect, useCallback } from 'react'
2
- import { NewMessageModel } from '../../../classes/Message/types'
3
- import Message from '../../../classes/Message'
4
-
5
- export default function<MessageModel extends NewMessageModel>() {
6
- const [uploading, setUploading] = useState(false)
7
- const [error, setError] = useState(null)
8
- const messageRef = useRef<MessageModel | null>(null)
9
- const recipientsRef = useRef<string[] | null>(null)
10
-
11
- useEffect(() => {
12
- if (uploading) {
13
- const run = async () => {
14
- try {
15
- if (messageRef.current && recipientsRef.current)
16
- await new Message(messageRef.current).sendToGroup(
17
- recipientsRef.current
18
- )
19
- messageRef.current = null
20
- recipientsRef.current = null
21
- setUploading(false)
22
- } catch (e) {
23
- console.error(`failure sending message from useSendToPeople`, e)
24
- setError(e)
25
- }
26
- }
27
- run()
28
- }
29
- }, [uploading])
30
-
31
- const send = useCallback((message: MessageModel, recipients: string[]) => {
32
- messageRef.current = message
33
- recipientsRef.current = recipients
34
- setUploading(true)
35
- }, [])
36
-
37
- return { send, uploading, error }
38
- }
@@ -1,38 +0,0 @@
1
- import { useState, useRef, useEffect, useCallback } from 'react'
2
- import { NewMessageModel } from '../../../classes/Message/types'
3
- import Message from '../../../classes/Message'
4
-
5
- export default function<MessageModel extends NewMessageModel>() {
6
- const [uploading, setUploading] = useState(false)
7
- const [error, setError] = useState(null)
8
- const messageRef = useRef<MessageModel | null>(null)
9
- const recipientsRef = useRef<string[] | null>(null)
10
-
11
- useEffect(() => {
12
- if (uploading) {
13
- const run = async () => {
14
- try {
15
- if (messageRef.current && recipientsRef.current)
16
- await new Message(messageRef.current).sendToPeople(
17
- recipientsRef.current
18
- )
19
- messageRef.current = null
20
- recipientsRef.current = null
21
- setUploading(false)
22
- } catch (e) {
23
- console.error(`failure sending message from useSendToPeople`, e)
24
- setError(e)
25
- }
26
- }
27
- run()
28
- }
29
- }, [uploading])
30
-
31
- const send = useCallback((message: MessageModel, recipients: string[]) => {
32
- messageRef.current = message
33
- recipientsRef.current = recipients
34
- setUploading(true)
35
- }, [])
36
-
37
- return { send, uploading, error }
38
- }
@@ -1,154 +0,0 @@
1
- import { useEffect, useState, useMemo, useRef } from 'react'
2
- import { useFuegoContext } from '@nandorojo/fuego'
3
- import { Typing } from '../../classes/Room/types'
4
-
5
- /**
6
- * useTyping automatically updates the backend whenever a user is typing.
7
- *
8
- * @param options - A dictionary to configure the typing.
9
- * @param options.roomId - **Required** unique id of the room you're typing in.
10
- * @param options.text - **Required** The current text state of your chat input
11
- * @param options.delay (Optional) Set the timeout delay to mark typing false. Set null if you don't want a time out.
12
- *
13
- * @example
14
- * ```javascript
15
- * // input text state
16
- * const [text, setText] = useState('')
17
- * // let's say we're getting our room id from our react-navigation params
18
- * const navigation = useNavigation()
19
- * const roomId = navigation.params.id
20
- *
21
- * useTyping({ roomId, text })
22
- *
23
- * <ChatComponent text={text} onChangeText={setText} />
24
- * ```
25
- *
26
- * @returns
27
- * Doesn't return anything. We live in an undefined world, I suppose.
28
- *
29
- * @remarks
30
- * The actual data of who is typing is stored in the chatroom object.
31
- * If you want to get this data realtime in a room, consider using useRoom({ listen: true }). This data will also be in useInbox().
32
- * See docs for useRoom or useInbox for more.
33
- *
34
- */
35
- export default ({
36
- roomId,
37
- text,
38
- delay = 5000
39
- }: {
40
- roomId: string
41
- text: string
42
- delay?: number | null
43
- }) => {
44
- const { auth, firebase } = useFuegoContext()
45
- const [ready, setReady] = useState(false)
46
- const { currentUser } = auth()
47
- try {
48
- if (!currentUser)
49
- throw new Error(
50
- '🤯 error in useTyping hook. Looks like there is not a valid user signed in. \nConsider using the FuegoGate component from @nandorojo/fuego and wrapping it around your app.'
51
- )
52
- } catch (e) {
53
- console.error(e)
54
- }
55
- const { uid } = currentUser as firebase.User
56
- const databaseRef = useMemo(() => firebase.database().ref(`/typing/${uid}`), [
57
- uid,
58
- firebase
59
- ])
60
- const previouslyTyped = useRef('')
61
-
62
- const timer = useRef<NodeJS.Timeout>()
63
-
64
- const lastStateSent = useRef<IsTyping['state']>('nothing')
65
-
66
- // initialize the typing set to false when we disconnect
67
- // once that is set up, then we can mark that we are indeed typing elsewhere
68
- // ^ that will be done in the next hook
69
- useEffect(() => {
70
- const subscriptionRef = firebase.database().ref('.info/connected')
71
- const notTyping: IsTyping = {
72
- state: 'nothing',
73
- lastChanged: firebase.database.ServerValue.TIMESTAMP,
74
- roomId
75
- }
76
-
77
- subscriptionRef.on('value', async snapshot => {
78
- if (!snapshot.val()) return
79
-
80
- try {
81
- await databaseRef.onDisconnect().set(notTyping)
82
- setReady(true)
83
- } catch (e) {
84
- console.error(`useTyping error within snapshot listener ${e}`)
85
- }
86
- })
87
-
88
- return () => {
89
- // clean up the listener on unmount
90
- subscriptionRef.off('value')
91
- ;(async () => {
92
- try {
93
- lastStateSent.current = notTyping.state
94
- await databaseRef.set(notTyping)
95
- } catch (e) {
96
- console.error('useTyping errored on unmount setting not typing')
97
- }
98
- })()
99
- }
100
- }, [roomId, databaseRef, firebase])
101
-
102
- // every time we type something new, upload that we're typing
103
- // and after a certain delay, we mark typing false
104
- // however, if we type before that timer has completed,
105
- // we clean it up and start it over
106
- useEffect(() => {
107
- try {
108
- // we're ready to upload from the previous effect
109
- // ...and the text we typed just changed.
110
- // if text is empty, set to false
111
- if (ready && text !== previouslyTyped.current) {
112
- previouslyTyped.current = text
113
-
114
- const notTyping: IsTyping = {
115
- state: 'nothing',
116
- lastChanged: firebase.database.ServerValue.TIMESTAMP,
117
- roomId
118
- }
119
- const isTyping: IsTyping = {
120
- state: 'typing',
121
- lastChanged: firebase.database.ServerValue.TIMESTAMP,
122
- roomId
123
- }
124
-
125
- // if the text is empty, we set it to not typing
126
- const setValue = text ? isTyping : notTyping
127
-
128
- // don't resend the state we just sent to avoid redundancy
129
- if (setValue.state !== lastStateSent.current) {
130
- lastStateSent.current = setValue.state
131
- databaseRef.set(setValue)
132
- }
133
-
134
- // only need a notTyping timer timer if we're typing
135
- if (delay !== null && setValue.state === 'typing') {
136
- timer.current = setTimeout(() => {
137
- lastStateSent.current = notTyping.state
138
- databaseRef.set(notTyping)
139
- }, delay)
140
- }
141
- }
142
- } catch (e) {
143
- console.error('error in useTyping after timer', e)
144
- }
145
-
146
- return () => {
147
- if (timer.current) clearTimeout(timer.current)
148
- }
149
- }, [ready, text, roomId, delay, uid, databaseRef, firebase])
150
- }
151
-
152
- interface IsTyping extends Typing {
153
- roomId: string
154
- }
@@ -1,67 +0,0 @@
1
- import { useEffect, useRef } from 'react'
2
- import { Room } from '../../index'
3
- import { fuego } from '../../components/ChatProvider'
4
- import { UseTypingConfig } from './types'
5
-
6
- /**
7
- * useTyping updates the backend every time a user types, setting it to false after a certain delay.
8
- *
9
- * @param config { text, id } A dictionary that takes in the Input's current text value and the chatroom ID.
10
- * @param delay How long the timer delay should be before the backend is told we're no longer typing.
11
- *
12
- * @returns undefined
13
- */
14
- export default (config: UseTypingConfig, delay: number = 1500) => {
15
- const { text = '', id } = config
16
- const { path } = new Room({ id })
17
- const ref = fuego.db.doc(path)
18
- const timer = useRef<number>()
19
- const user = fuego.auth().currentUser as firebase.User
20
- const uid = (user && user.uid) || 'tester_name'
21
- // ensures that typing only happens on update, not on mount
22
- const mounted = useRef(false)
23
- const lastTyped = useRef(0)
24
-
25
- useEffect(() => {
26
- try {
27
- if (mounted.current) {
28
- const typedAt = Date.now()
29
- // const last = lastTyped.current
30
- lastTyped.current = typedAt
31
- // if ((typedAt - last) / 1000 >= delay) {
32
- ref.update({
33
- [`members.${uid}.typing`]: true
34
- // [`members.${uid}.lastTyped`]: new Date()
35
- })
36
- timer.current = setTimeout(() => {
37
- ref.update({
38
- [`members.${uid}.typing`]: false
39
- })
40
- }, delay)
41
- // }
42
- } else {
43
- mounted.current = true
44
- }
45
- } catch (e) {
46
- console.error('use typing update error', e)
47
- }
48
-
49
- return () => {
50
- // cleanup on update
51
- if (timer.current) clearTimeout(timer.current)
52
- }
53
- }, [text, uid, delay, path])
54
-
55
- useEffect(() => {
56
- return () => {
57
- try {
58
- // mark indicator as false
59
- ref.update({
60
- [`members.${uid}.typing`]: false
61
- })
62
- } catch (e) {
63
- console.error('unmount usetyping error', e)
64
- }
65
- }
66
- }, [])
67
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * useTyping updates the backend every time a user types, setting it to false after a certain delay.
3
- */
4
- export interface UseTypingConfig {
5
- text: string
6
- id: string
7
- }