@weavy/uikit-react 14.0.4 → 15.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 (360) hide show
  1. package/.vscode/settings.json +2 -0
  2. package/changelog.md +6 -0
  3. package/dist/cjs/client/WeavyClient.d.ts +1 -0
  4. package/dist/cjs/components/Attachment.d.ts +5 -5
  5. package/dist/cjs/components/Blob.d.ts +9 -0
  6. package/dist/cjs/components/Comment.d.ts +18 -0
  7. package/dist/cjs/components/CommentCount.d.ts +7 -0
  8. package/dist/cjs/components/CommentEdit.d.ts +16 -0
  9. package/dist/cjs/components/CommentPlaceholder.d.ts +8 -0
  10. package/dist/cjs/components/CommentTrashed.d.ts +15 -0
  11. package/dist/cjs/components/CommentView.d.ts +18 -0
  12. package/dist/cjs/components/Comments.d.ts +8 -0
  13. package/dist/cjs/components/ConversationListItem.d.ts +1 -1
  14. package/dist/cjs/components/Dropzone.d.ts +10 -0
  15. package/dist/cjs/components/Editor.d.ts +25 -0
  16. package/dist/cjs/components/Embed.d.ts +8 -0
  17. package/dist/cjs/components/FileItem.d.ts +41 -0
  18. package/dist/cjs/components/FileList.d.ts +11 -0
  19. package/dist/cjs/components/FileVersions.d.ts +9 -0
  20. package/dist/cjs/components/Files.d.ts +4 -0
  21. package/dist/cjs/components/Image.d.ts +3 -3
  22. package/dist/cjs/components/MeetingCard.d.ts +1 -1
  23. package/dist/cjs/components/Meetings.d.ts +2 -1
  24. package/dist/cjs/components/Poll.d.ts +8 -0
  25. package/dist/cjs/components/PollOption.d.ts +10 -0
  26. package/dist/cjs/components/Post.d.ts +21 -0
  27. package/dist/cjs/components/PostEdit.d.ts +17 -0
  28. package/dist/cjs/components/PostList.d.ts +6 -0
  29. package/dist/cjs/components/PostPlaceholder.d.ts +8 -0
  30. package/dist/cjs/components/PostTrashed.d.ts +14 -0
  31. package/dist/cjs/components/PostView.d.ts +21 -0
  32. package/dist/cjs/components/Posts.d.ts +4 -0
  33. package/dist/cjs/components/Preview.d.ts +1 -3
  34. package/dist/cjs/components/PreviewFiles.d.ts +10 -0
  35. package/dist/cjs/components/Reactions.d.ts +6 -2
  36. package/dist/cjs/components/SearchUsers.d.ts +2 -1
  37. package/dist/cjs/contexts/CloudFilesContext.d.ts +9 -0
  38. package/dist/cjs/hooks/useApps.d.ts +1 -0
  39. package/dist/cjs/hooks/useCloudFiles.d.ts +3 -0
  40. package/dist/cjs/hooks/useCommentList.d.ts +1 -0
  41. package/dist/cjs/hooks/useEmbeds.d.ts +5 -0
  42. package/dist/cjs/hooks/useFileList.d.ts +1 -0
  43. package/dist/cjs/hooks/useFileUploader.d.ts +8 -0
  44. package/dist/cjs/hooks/useFileVersions.d.ts +2 -0
  45. package/dist/cjs/hooks/useInfiniteScroll.d.ts +4 -0
  46. package/dist/cjs/hooks/useIsFirstRender.d.ts +2 -0
  47. package/dist/cjs/hooks/useMutateApps.d.ts +5 -0
  48. package/dist/cjs/hooks/useMutateComment.d.ts +10 -0
  49. package/dist/cjs/hooks/useMutateConversationName.d.ts +1 -1
  50. package/dist/cjs/hooks/useMutateDeleteReaction.d.ts +3 -1
  51. package/dist/cjs/hooks/useMutateEditComment.d.ts +10 -0
  52. package/dist/cjs/hooks/useMutateEditPost.d.ts +10 -0
  53. package/dist/cjs/hooks/useMutateExternalBlobs.d.ts +2 -2
  54. package/dist/cjs/hooks/useMutateFile.d.ts +26 -0
  55. package/dist/cjs/hooks/useMutateFileRename.d.ts +5 -0
  56. package/dist/cjs/hooks/useMutateFileSubscribe.d.ts +7 -0
  57. package/dist/cjs/hooks/useMutateFileTrash.d.ts +10 -0
  58. package/dist/cjs/hooks/useMutateFileVersion.d.ts +7 -0
  59. package/dist/cjs/hooks/useMutateFiles.d.ts +2 -0
  60. package/dist/cjs/hooks/useMutateLeaveConversation.d.ts +4 -0
  61. package/dist/cjs/hooks/useMutateMessage.d.ts +2 -2
  62. package/dist/cjs/hooks/useMutatePost.d.ts +10 -0
  63. package/dist/cjs/hooks/useMutateReaction.d.ts +3 -1
  64. package/dist/cjs/hooks/useMutateRead.d.ts +1 -1
  65. package/dist/cjs/hooks/useMutateReplaceReaction.d.ts +6 -0
  66. package/dist/cjs/hooks/useMutateRestoreComment.d.ts +5 -0
  67. package/dist/cjs/hooks/useMutateRestorePost.d.ts +4 -0
  68. package/dist/cjs/hooks/useMutateStarred.d.ts +4 -0
  69. package/dist/cjs/hooks/useMutateSubscribe.d.ts +4 -0
  70. package/dist/cjs/hooks/useMutateTrashComment.d.ts +5 -0
  71. package/dist/cjs/hooks/useMutateTrashPost.d.ts +4 -0
  72. package/dist/cjs/hooks/useMutateTyping.d.ts +2 -0
  73. package/dist/cjs/hooks/useMutateUnsubscribe.d.ts +4 -0
  74. package/dist/cjs/hooks/useMutateVote.d.ts +5 -0
  75. package/dist/cjs/hooks/usePost.d.ts +1 -0
  76. package/dist/cjs/hooks/usePosts.d.ts +1 -0
  77. package/dist/cjs/hooks/usePostsList.d.ts +1 -0
  78. package/dist/cjs/hooks/useReactionList.d.ts +1 -0
  79. package/dist/cjs/hooks/useSessionState.d.ts +2 -0
  80. package/dist/cjs/hooks/useUnload.d.ts +2 -0
  81. package/dist/cjs/hooks/useUpdateEffect.d.ts +3 -0
  82. package/dist/cjs/hooks/useVotes.d.ts +1 -0
  83. package/dist/cjs/index.d.ts +3 -1
  84. package/dist/cjs/index.js +28 -6
  85. package/dist/cjs/index.js.map +1 -1
  86. package/dist/cjs/types/ConversationListItem.d.ts +1 -0
  87. package/dist/cjs/types/Files.d.ts +7 -0
  88. package/dist/cjs/types/Message.d.ts +2 -2
  89. package/dist/cjs/types/Posts.d.ts +4 -0
  90. package/dist/cjs/types/interfaces.d.ts +9 -0
  91. package/dist/cjs/types/types.d.ts +138 -22
  92. package/dist/cjs/ui/Dropdown.d.ts +18 -2
  93. package/dist/cjs/ui/Icon.d.ts +10 -2
  94. package/dist/cjs/ui/Overlay.d.ts +3 -1
  95. package/dist/cjs/ui/Sheet.d.ts +14 -0
  96. package/dist/cjs/ui/Spinner.d.ts +2 -1
  97. package/dist/cjs/utils/cacheUtils.d.ts +14 -0
  98. package/dist/cjs/utils/fileUtilities.d.ts +10 -1
  99. package/dist/cjs/utils/mentions.d.ts +6 -0
  100. package/dist/cjs/utils/openUrl.d.ts +1 -0
  101. package/dist/css/weavy-chat.css +637 -218
  102. package/dist/css/weavy-files.css +3046 -0
  103. package/dist/css/weavy-messenger.css +643 -213
  104. package/dist/css/weavy-posts.css +2773 -0
  105. package/dist/css/weavy.css +1749 -308
  106. package/dist/esm/client/WeavyClient.d.ts +1 -0
  107. package/dist/esm/components/Attachment.d.ts +5 -5
  108. package/dist/esm/components/Blob.d.ts +9 -0
  109. package/dist/esm/components/Comment.d.ts +18 -0
  110. package/dist/esm/components/CommentCount.d.ts +7 -0
  111. package/dist/esm/components/CommentEdit.d.ts +16 -0
  112. package/dist/esm/components/CommentPlaceholder.d.ts +8 -0
  113. package/dist/esm/components/CommentTrashed.d.ts +15 -0
  114. package/dist/esm/components/CommentView.d.ts +18 -0
  115. package/dist/esm/components/Comments.d.ts +8 -0
  116. package/dist/esm/components/ConversationListItem.d.ts +1 -1
  117. package/dist/esm/components/Dropzone.d.ts +10 -0
  118. package/dist/esm/components/Editor.d.ts +25 -0
  119. package/dist/esm/components/Embed.d.ts +8 -0
  120. package/dist/esm/components/FileItem.d.ts +41 -0
  121. package/dist/esm/components/FileList.d.ts +11 -0
  122. package/dist/esm/components/FileVersions.d.ts +9 -0
  123. package/dist/esm/components/Files.d.ts +4 -0
  124. package/dist/esm/components/Image.d.ts +3 -3
  125. package/dist/esm/components/MeetingCard.d.ts +1 -1
  126. package/dist/esm/components/Meetings.d.ts +2 -1
  127. package/dist/esm/components/Poll.d.ts +8 -0
  128. package/dist/esm/components/PollOption.d.ts +10 -0
  129. package/dist/esm/components/Post.d.ts +21 -0
  130. package/dist/esm/components/PostEdit.d.ts +17 -0
  131. package/dist/esm/components/PostList.d.ts +6 -0
  132. package/dist/esm/components/PostPlaceholder.d.ts +8 -0
  133. package/dist/esm/components/PostTrashed.d.ts +14 -0
  134. package/dist/esm/components/PostView.d.ts +21 -0
  135. package/dist/esm/components/Posts.d.ts +4 -0
  136. package/dist/esm/components/Preview.d.ts +1 -3
  137. package/dist/esm/components/PreviewFiles.d.ts +10 -0
  138. package/dist/esm/components/Reactions.d.ts +6 -2
  139. package/dist/esm/components/SearchUsers.d.ts +2 -1
  140. package/dist/esm/contexts/CloudFilesContext.d.ts +9 -0
  141. package/dist/esm/hooks/useApps.d.ts +1 -0
  142. package/dist/esm/hooks/useCloudFiles.d.ts +3 -0
  143. package/dist/esm/hooks/useCommentList.d.ts +1 -0
  144. package/dist/esm/hooks/useEmbeds.d.ts +5 -0
  145. package/dist/esm/hooks/useFileList.d.ts +1 -0
  146. package/dist/esm/hooks/useFileUploader.d.ts +8 -0
  147. package/dist/esm/hooks/useFileVersions.d.ts +2 -0
  148. package/dist/esm/hooks/useInfiniteScroll.d.ts +4 -0
  149. package/dist/esm/hooks/useIsFirstRender.d.ts +2 -0
  150. package/dist/esm/hooks/useMutateApps.d.ts +5 -0
  151. package/dist/esm/hooks/useMutateComment.d.ts +10 -0
  152. package/dist/esm/hooks/useMutateConversationName.d.ts +1 -1
  153. package/dist/esm/hooks/useMutateDeleteReaction.d.ts +3 -1
  154. package/dist/esm/hooks/useMutateEditComment.d.ts +10 -0
  155. package/dist/esm/hooks/useMutateEditPost.d.ts +10 -0
  156. package/dist/esm/hooks/useMutateExternalBlobs.d.ts +2 -2
  157. package/dist/esm/hooks/useMutateFile.d.ts +26 -0
  158. package/dist/esm/hooks/useMutateFileRename.d.ts +5 -0
  159. package/dist/esm/hooks/useMutateFileSubscribe.d.ts +7 -0
  160. package/dist/esm/hooks/useMutateFileTrash.d.ts +10 -0
  161. package/dist/esm/hooks/useMutateFileVersion.d.ts +7 -0
  162. package/dist/esm/hooks/useMutateFiles.d.ts +2 -0
  163. package/dist/esm/hooks/useMutateLeaveConversation.d.ts +4 -0
  164. package/dist/esm/hooks/useMutateMessage.d.ts +2 -2
  165. package/dist/esm/hooks/useMutatePost.d.ts +10 -0
  166. package/dist/esm/hooks/useMutateReaction.d.ts +3 -1
  167. package/dist/esm/hooks/useMutateRead.d.ts +1 -1
  168. package/dist/esm/hooks/useMutateReplaceReaction.d.ts +6 -0
  169. package/dist/esm/hooks/useMutateRestoreComment.d.ts +5 -0
  170. package/dist/esm/hooks/useMutateRestorePost.d.ts +4 -0
  171. package/dist/esm/hooks/useMutateStarred.d.ts +4 -0
  172. package/dist/esm/hooks/useMutateSubscribe.d.ts +4 -0
  173. package/dist/esm/hooks/useMutateTrashComment.d.ts +5 -0
  174. package/dist/esm/hooks/useMutateTrashPost.d.ts +4 -0
  175. package/dist/esm/hooks/useMutateTyping.d.ts +2 -0
  176. package/dist/esm/hooks/useMutateUnsubscribe.d.ts +4 -0
  177. package/dist/esm/hooks/useMutateVote.d.ts +5 -0
  178. package/dist/esm/hooks/usePost.d.ts +1 -0
  179. package/dist/esm/hooks/usePosts.d.ts +1 -0
  180. package/dist/esm/hooks/usePostsList.d.ts +1 -0
  181. package/dist/esm/hooks/useReactionList.d.ts +1 -0
  182. package/dist/esm/hooks/useSessionState.d.ts +2 -0
  183. package/dist/esm/hooks/useUnload.d.ts +2 -0
  184. package/dist/esm/hooks/useUpdateEffect.d.ts +3 -0
  185. package/dist/esm/hooks/useVotes.d.ts +1 -0
  186. package/dist/esm/index.d.ts +3 -1
  187. package/dist/esm/index.js +28 -6
  188. package/dist/esm/index.js.map +1 -1
  189. package/dist/esm/types/ConversationListItem.d.ts +1 -0
  190. package/dist/esm/types/Files.d.ts +7 -0
  191. package/dist/esm/types/Message.d.ts +2 -2
  192. package/dist/esm/types/Posts.d.ts +4 -0
  193. package/dist/esm/types/interfaces.d.ts +9 -0
  194. package/dist/esm/types/types.d.ts +138 -22
  195. package/dist/esm/ui/Dropdown.d.ts +18 -2
  196. package/dist/esm/ui/Icon.d.ts +10 -2
  197. package/dist/esm/ui/Overlay.d.ts +3 -1
  198. package/dist/esm/ui/Sheet.d.ts +14 -0
  199. package/dist/esm/ui/Spinner.d.ts +2 -1
  200. package/dist/esm/utils/cacheUtils.d.ts +14 -0
  201. package/dist/esm/utils/fileUtilities.d.ts +10 -1
  202. package/dist/esm/utils/mentions.d.ts +6 -0
  203. package/dist/esm/utils/openUrl.d.ts +1 -0
  204. package/dist/index.d.ts +50 -6
  205. package/package.json +8 -2
  206. package/src/client/WeavyClient.ts +35 -1
  207. package/src/components/Attachment.tsx +20 -13
  208. package/src/components/Blob.tsx +28 -0
  209. package/src/components/Comment.tsx +43 -0
  210. package/src/components/CommentCount.tsx +15 -0
  211. package/src/components/CommentEdit.tsx +48 -0
  212. package/src/components/CommentPlaceholder.tsx +34 -0
  213. package/src/components/CommentTrashed.tsx +45 -0
  214. package/src/components/CommentView.tsx +142 -0
  215. package/src/components/Comments.tsx +78 -0
  216. package/src/components/Conversation.tsx +85 -31
  217. package/src/components/ConversationList.tsx +12 -41
  218. package/src/components/ConversationListItem.tsx +125 -74
  219. package/src/components/Dropzone.tsx +26 -0
  220. package/src/components/Editor.tsx +700 -0
  221. package/src/components/Embed.tsx +80 -0
  222. package/src/components/FileItem.tsx +391 -0
  223. package/src/components/FileList.tsx +166 -0
  224. package/src/components/FileVersions.tsx +100 -0
  225. package/src/components/Files.tsx +294 -0
  226. package/src/components/Image.tsx +11 -10
  227. package/src/components/Meeting.tsx +1 -2
  228. package/src/components/MeetingCard.tsx +1 -1
  229. package/src/components/Meetings.tsx +13 -5
  230. package/src/components/Message.tsx +14 -19
  231. package/src/components/Messages.tsx +38 -64
  232. package/src/components/NewConversation.tsx +8 -6
  233. package/src/components/PdfViewer.tsx +2 -2
  234. package/src/components/Poll.tsx +45 -0
  235. package/src/components/PollOption.tsx +65 -0
  236. package/src/components/Post.tsx +45 -0
  237. package/src/components/PostEdit.tsx +49 -0
  238. package/src/components/PostList.tsx +95 -0
  239. package/src/components/PostPlaceholder.tsx +32 -0
  240. package/src/components/PostTrashed.tsx +35 -0
  241. package/src/components/PostView.tsx +194 -0
  242. package/src/components/Posts.tsx +59 -0
  243. package/src/components/Preview.tsx +16 -23
  244. package/src/components/PreviewFiles.tsx +336 -0
  245. package/src/components/Reactions.tsx +142 -38
  246. package/src/components/SearchUsers.tsx +77 -37
  247. package/src/components/Typing.tsx +1 -1
  248. package/src/{components/FileBrowser.tsx → contexts/CloudFilesContext.tsx} +46 -30
  249. package/src/contexts/PreviewContext.tsx +102 -85
  250. package/src/contexts/WeavyContext.tsx +10 -6
  251. package/src/hooks/useApps.ts +23 -0
  252. package/src/hooks/useCloudFiles.ts +12 -0
  253. package/src/hooks/useCommentList.ts +30 -0
  254. package/src/hooks/useEmbeds.ts +126 -0
  255. package/src/hooks/useEvents.ts +3 -1
  256. package/src/hooks/useFileList.ts +84 -0
  257. package/src/hooks/useFileUploader.ts +38 -1
  258. package/src/hooks/useFileVersions.ts +20 -0
  259. package/src/hooks/useInfiniteScroll.ts +45 -0
  260. package/src/hooks/useIsFirstRender.ts +15 -0
  261. package/src/hooks/useMembers.ts +3 -3
  262. package/src/hooks/useMutateApps.ts +48 -0
  263. package/src/hooks/useMutateComment.ts +60 -0
  264. package/src/hooks/useMutateConversationName.ts +1 -1
  265. package/src/hooks/useMutateDeleteReaction.ts +17 -4
  266. package/src/hooks/useMutateEditComment.ts +63 -0
  267. package/src/hooks/useMutateEditPost.ts +64 -0
  268. package/src/hooks/useMutateExternalBlobs.ts +5 -9
  269. package/src/hooks/useMutateFile.ts +311 -0
  270. package/src/hooks/useMutateFileRename.ts +51 -0
  271. package/src/hooks/useMutateFileSubscribe.ts +80 -0
  272. package/src/hooks/useMutateFileTrash.ts +115 -0
  273. package/src/hooks/useMutateFileVersion.ts +85 -0
  274. package/src/hooks/useMutateFiles.ts +23 -0
  275. package/src/hooks/useMutateLeaveConversation.ts +38 -0
  276. package/src/hooks/useMutateMessage.ts +23 -62
  277. package/src/hooks/useMutatePost.ts +60 -0
  278. package/src/hooks/useMutateReaction.ts +21 -6
  279. package/src/hooks/useMutateRead.ts +8 -2
  280. package/src/hooks/useMutateRemoveMembers.ts +2 -9
  281. package/src/hooks/useMutateReplaceReaction.ts +59 -0
  282. package/src/hooks/useMutateRestoreComment.ts +37 -0
  283. package/src/hooks/useMutateRestorePost.ts +36 -0
  284. package/src/hooks/useMutateStarred.ts +35 -0
  285. package/src/hooks/useMutateSubscribe.ts +36 -0
  286. package/src/hooks/useMutateTrashComment.ts +37 -0
  287. package/src/hooks/useMutateTrashPost.ts +36 -0
  288. package/src/hooks/useMutateTyping.ts +5 -3
  289. package/src/hooks/useMutateUnsubscribe.ts +36 -0
  290. package/src/hooks/useMutateVote.ts +59 -0
  291. package/src/hooks/usePost.ts +20 -0
  292. package/src/hooks/usePosts.ts +21 -0
  293. package/src/hooks/usePostsList.ts +31 -0
  294. package/src/hooks/useReactionList.ts +21 -0
  295. package/src/hooks/useSearchUsers.ts +2 -2
  296. package/src/hooks/useSessionState.ts +23 -0
  297. package/src/hooks/useUnload.ts +19 -0
  298. package/src/hooks/useUpdateEffect.ts +16 -0
  299. package/src/hooks/useVotes.ts +21 -0
  300. package/src/index.ts +5 -1
  301. package/src/scss/theme/_appbar.scss +8 -4
  302. package/src/scss/theme/_card.scss +2 -0
  303. package/src/scss/theme/_comment-editor-cm.scss +5 -1
  304. package/src/scss/theme/_comments.scss +9 -8
  305. package/src/scss/theme/_conversations.scss +4 -0
  306. package/src/scss/theme/_files.scss +2 -81
  307. package/src/scss/theme/_icons.scss +21 -3
  308. package/src/scss/theme/_input.scss +13 -7
  309. package/src/scss/theme/_item.scss +23 -1
  310. package/src/scss/theme/_message-editor-cm.scss +5 -1
  311. package/src/scss/theme/_pager.scss +1 -1
  312. package/src/scss/theme/_post-editor-cm.scss +2 -2
  313. package/src/scss/theme/_post.scss +3 -10
  314. package/src/scss/theme/_preview-pdf-viewer.scss +996 -0
  315. package/src/scss/theme/_preview-pdf.scss +57 -783
  316. package/src/scss/theme/_sheet.scss +4 -1
  317. package/src/scss/theme/_spinner.scss +10 -1
  318. package/src/scss/theme/_tables.scss +2 -0
  319. package/src/scss/theme/base/_scroll.scss +3 -0
  320. package/src/scss/weavy-chat.scss +3 -1
  321. package/src/scss/weavy-files.scss +31 -0
  322. package/src/scss/weavy-messenger.scss +3 -1
  323. package/src/scss/weavy-posts.scss +35 -0
  324. package/src/scss/weavy.scss +2 -0
  325. package/src/types/ConversationListItem.ts +1 -0
  326. package/src/types/Files.ts +7 -0
  327. package/src/types/Message.ts +2 -2
  328. package/src/types/Posts.ts +4 -0
  329. package/src/types/interfaces.ts +13 -0
  330. package/src/types/types.ts +157 -28
  331. package/src/ui/Button.tsx +6 -5
  332. package/src/ui/Dropdown.tsx +67 -16
  333. package/src/ui/Icon.tsx +112 -15
  334. package/src/ui/Overlay.tsx +6 -2
  335. package/src/ui/Sheet.tsx +87 -0
  336. package/src/ui/Spinner.tsx +7 -4
  337. package/src/utils/cacheUtils.ts +246 -0
  338. package/src/utils/fileUtilities.ts +208 -24
  339. package/src/utils/infinite-scroll.js +103 -0
  340. package/src/utils/mentions.ts +50 -0
  341. package/src/utils/openUrl.ts +41 -0
  342. package/src/utils/{scrollToBottom.js → scroll-position.js} +50 -9
  343. package/src/utils/{scrollbarDetection.js → scrollbar-detection.js} +0 -0
  344. package/src/utils/utils.js +15 -1
  345. package/tsconfig.json +1 -1
  346. package/dist/cjs/components/ConversationForm.d.ts +0 -7
  347. package/dist/cjs/components/File.d.ts +0 -9
  348. package/dist/cjs/components/FileBrowser.d.ts +0 -6
  349. package/dist/cjs/hooks/usePreview.d.ts +0 -4
  350. package/dist/cjs/hooks/useReactions.d.ts +0 -3
  351. package/dist/esm/components/ConversationForm.d.ts +0 -7
  352. package/dist/esm/components/File.d.ts +0 -9
  353. package/dist/esm/components/FileBrowser.d.ts +0 -6
  354. package/dist/esm/hooks/usePreview.d.ts +0 -4
  355. package/dist/esm/hooks/useReactions.d.ts +0 -3
  356. package/src/components/ConversationForm.tsx +0 -210
  357. package/src/components/File.tsx +0 -21
  358. package/src/hooks/usePreview.ts +0 -21
  359. package/src/hooks/useReactions.ts +0 -51
  360. package/src/utils/infiniteScroll.js +0 -184
@@ -6,44 +6,35 @@ import Button from '../ui/Button';
6
6
  import Icon from '../ui/Icon';
7
7
 
8
8
  type SearchUsersProps = {
9
+ existingMembers?: MemberType[],
9
10
  handleSubmit: any,
10
11
  buttonTitle: string
11
12
  }
12
13
 
13
- const SearchUsers = ({handleSubmit, buttonTitle}: SearchUsersProps) => {
14
+ const SearchUsers = ({ existingMembers, handleSubmit, buttonTitle }: SearchUsersProps) => {
14
15
 
15
16
  const [text, setText] = useState("");
16
17
  const [selected, setSelected] = useState<MemberType[]>([]);
17
18
 
18
- const { isLoading, isError, data, error, isFetching, refetch } = useSearchUsers(text, {
19
+ const { data, refetch } = useSearchUsers(text || "*", {
19
20
  enabled: false
20
21
  });
21
22
 
22
23
  const throttledCb = useDebounce(() => refetch(), 250);
23
24
  useEffect(throttledCb, [text])
24
25
 
25
- const toggleChecked = (e: any) => {
26
- let checkbox = e.currentTarget.querySelector("input[type=checkbox]");
27
- if (checkbox !== e.target && !e.target.matches("label, input[type=checkbox]")) {
28
- checkbox?.click();
29
- }
30
- };
31
-
32
- const isChecked = (id: number): boolean => {
33
- return selected.find((u) => { return u.id === id }) != null;
26
+ const isChecked = (memberId: number): boolean => {
27
+ return selected.find((m) => { return m.id === memberId }) != null;
34
28
  }
35
29
 
36
- const handleSelected = (e: any, member: MemberType) => {
37
- if (e.target.checked) {
30
+ const handleSelected = (member: MemberType, checked: boolean) => {
31
+ if (checked) {
38
32
  setSelected([...selected, member]);
39
33
  } else {
40
- setSelected(selected.filter((u) => { return u.id !== member.id }));
34
+ setSelected(selected.filter((m) => { return m.id !== member.id }));
41
35
  }
42
-
43
36
  }
44
-
45
37
  const clear = () => {
46
- setSelected([]);
47
38
  setText("");
48
39
  }
49
40
 
@@ -58,43 +49,92 @@ const SearchUsers = ({handleSubmit, buttonTitle}: SearchUsersProps) => {
58
49
  </div>
59
50
 
60
51
  <div className="wy-pane-group">
61
- {data && (!data.data || data.data.length === 0) &&
52
+ {data && (!data.data || data.data.filter(m => existingMembers?.find(e => e.id === m.id) === undefined).length === 0) &&
62
53
  <div className="wy-table-no-result">Your search did not match any people.</div>
63
54
  }
64
- <table className="wy-table wy-table-hover wy-search-result-table">
65
- <tbody>
66
- {data && data.data && data.data.length > 0 && data.data.map((user: MemberType) => {
55
+ {selected && selected.length > 0 &&
56
+ <div className="wy-pane-group">
57
+ <label className="wy-input-label">Selected</label>
58
+ {selected.map((member: MemberType) => {
59
+ return (
60
+ <div className='wy-item' key={member.id} >
61
+ <Avatar src={member.avatar_url} size={32} id={member.id} presence={member.presence} name={member.display_name} />
62
+ <div className="wy-item-body">
63
+ {member.display_name}
64
+ </div>
65
+ <Button.UI onClick={() => handleSelected(member, !isChecked(member.id))} title="Remove">
66
+ <Icon.UI name="account-minus" />
67
+ </Button.UI>
68
+ </div>
69
+ )
70
+ })}
71
+
72
+
73
+ <hr />
74
+ {/* <div style={{ display: "flex", columnGap: "1.5rem", flexWrap: "wrap" }}>
75
+
76
+ {selected.map((member: MemberType) => {
77
+ return (
78
+ <div style={{ display: "flex", flexDirection: "column" }} title="Click to remove" onClick={() => handleSelected(member, false)}>
79
+ <div style={{alignSelf: 'center'}}>
80
+ <Avatar src={member.avatar_url} size={32} id={member.id} presence={member.presence} name={member.display_name} />
81
+ </div>
82
+ <div className="">{member.display_name}</div>
83
+ </div>
84
+ )
85
+ })}
86
+ </div> */}
87
+ </div>
88
+ }
89
+
90
+ <div className="wy-pane-group">
91
+ {data && data.data && data.data.filter(m => existingMembers?.find(e => e.id === m.id) === undefined && selected.find(s => s.id === m.id) === undefined).map((member: MemberType) => {
92
+ return (
93
+ <div className='wy-item' key={member.id} >
94
+ <Avatar src={member.avatar_url} size={32} id={member.id} presence={member.presence} name={member.display_name} />
95
+ <div className="wy-item-body">
96
+ {member.display_name}
97
+ </div>
98
+ <Button.UI onClick={() => handleSelected(member, !isChecked(member.id))} title="Add">
99
+ <Icon.UI name="account-plus" />
100
+ </Button.UI>
101
+ </div>
102
+ )
103
+ })}
104
+ </div>
105
+
106
+ {/* <table className="wy-table wy-table-hover wy-search-result-table">
107
+ <tbody>
108
+ {data && data.data && data.data.filter(m => existingMembers?.find(e => e.id === m.id) === undefined && selected.find(s => s.id === m.id) === undefined).map((member: MemberType) => {
67
109
  return (
68
- <tr key={user.id} onClick={toggleChecked}>
110
+ <tr key={member.id} onClick={() => handleSelected(member, !isChecked(member.id))}>
69
111
  <td className="wy-table-cell-icon">
70
- <Avatar src={user.avatar_url} size={24} id={user.id} presence={user.presence} name={user.display_name} />
112
+ <Avatar src={member.avatar_url} size={32} id={member.id} presence={member.presence} name={member.display_name} />
113
+ </td>
114
+ <td className="wy-table-cell-text">{member.display_name}</td>
115
+ <td className="wy-table-cell-icon">
116
+ <input type="checkbox" className="wy-button-check" checked={isChecked(member.id)} onChange={(() => { })} />
117
+ <Button.UI className='wy-button-icon'>
118
+ <Icon.Raw name="checkbox-blank" />
119
+ <Icon.Raw name="checkbox-marked" />
120
+ </Button.UI>
71
121
  </td>
72
- <td className="wy-table-cell-text"><label htmlFor={'chk' + user.id}>{user.display_name}</label></td>
73
- <td className="wy-table-cell-icon"><input type="checkbox" id={'chk' + user.id} checked={isChecked(user.id)} onChange={(e) => handleSelected(e, user)} /></td>
74
122
  </tr>
75
123
  )
76
124
  })}
77
- </tbody>
78
- </table>
125
+ </tbody>
126
+ </table> */}
79
127
  </div>
80
- {/*<div className="wy-search-group">
81
- <h2>Selected people</h2>
82
- <ul>
83
- {selected && selected.length > 0 && selected.map((user: UserType) => {
84
- return <li key={user.id}> {user.title} {user.email && ` - ${user.email}`}</li>
85
- })}
86
- </ul>
87
- </div>*/}
88
128
  <div className="wy-footerbars">
89
129
  <div className="wy-footerbar">
90
130
  <div className="wy-pane-group">
91
131
  <div className="wy-buttons">
92
- <button className="wy-button wy-button-primary" type="button" onClick={() => {handleSubmit(selected); clear();}} disabled={selected.length === 0}>{buttonTitle}</button>
132
+ <button className="wy-button wy-button-primary" type="button" onClick={() => { handleSubmit(selected); clear(); }} disabled={selected.length === 0}>{buttonTitle}</button>
93
133
  </div>
94
134
  </div>
95
135
  </div>
96
136
  </div>
97
- </div>
137
+ </div >
98
138
  )
99
139
  }
100
140
 
@@ -102,7 +102,7 @@ const Typing = ({ children, id, context }: Props) => {
102
102
  }
103
103
 
104
104
  const handleTyping = useCallback((realtimeEvent: RealtimeTyping) => {
105
- if (realtimeEvent.conversation.id === id && realtimeEvent.actor.id !== user.id) {
105
+ if (realtimeEvent.entity.id === id && realtimeEvent.actor.id !== user.id) {
106
106
  setTypers(realtimeEvent.actor);
107
107
  }
108
108
  }, [id, context, activeTypers]);
@@ -1,24 +1,28 @@
1
- import React, { useContext, useEffect, useState, useRef, useCallback } from "react";
2
- import { WeavyContext } from "../contexts/WeavyContext";
3
- import Button from '../ui/Button';
4
- import Spinner from '../ui/Spinner';
5
- import Icon from '../ui/Icon';
6
- import useMutateExternalBlobs from '../hooks/useMutateExternalBlobs';
1
+ import React, { createContext, useCallback, useContext, useEffect, useState } from "react";
2
+ import useMutateExternalBlobs from "../hooks/useMutateExternalBlobs";
7
3
  import Overlay from '../ui/Overlay';
4
+ import Spinner from '../ui/Spinner';
8
5
  import WeavyPostal from "../utils/postal-parent";
9
6
 
7
+ export const CloudFilesContext = createContext<CloudFilesContextProps>({
8
+ open: Function
9
+ });
10
+
10
11
  type Props = {
11
- onFileAdded: Function
12
+ client: any,
13
+ options: WeavyContextOptions, // pass client here to avoid circular references from WeavyContext
14
+ children: React.ReactNode
12
15
  }
13
16
 
14
- const FileBrowser = ({ onFileAdded }: Props) => {
17
+ let addFunc = ([]:any) => {};
15
18
 
16
- const { options } = useContext(WeavyContext);
19
+ const CloudFilesProvider = ({ children, options, client }: Props) => {
17
20
  const [modalOpen, setModalOpen] = useState(false);
18
21
  const [visible, setVisible] = useState(false);
19
22
  const [frameSrc, setFrameSrc] = useState("");
20
- const addExternalBlobs = useMutateExternalBlobs();
23
+
21
24
  const fileBrowserUrl = options?.filebrowserUrl || "";
25
+ const addExternalBlobs = useMutateExternalBlobs(client);
22
26
 
23
27
  const frameRef = useCallback((node: HTMLIFrameElement | null) => {
24
28
  if (node !== null && node.contentWindow != null) {
@@ -26,6 +30,8 @@ const FileBrowser = ({ onFileAdded }: Props) => {
26
30
  }
27
31
  }, []);
28
32
 
33
+
34
+
29
35
  useEffect(() => {
30
36
  var origin = "";
31
37
 
@@ -59,18 +65,27 @@ const FileBrowser = ({ onFileAdded }: Props) => {
59
65
  WeavyPostal.off("add-external-blobs", handleFiles);
60
66
  WeavyPostal.off("request:file-browser-close", handleClose);
61
67
  }
62
- }, [onFileAdded]);
63
-
64
- const toggleModal = (open: boolean) => {
65
- setModalOpen(open);
66
- }
68
+ }, []);
67
69
 
68
70
  const handleFiles = async (e: Event, message: any) => {
69
- var result = await addExternalBlobs.mutateAsync({ blobs: message.blobs });
70
- onFileAdded(result);
71
+ let result:any[] = [];
72
+ for(let i = 0; i < message.blobs.length; i++){
73
+ let uploadResult = await addExternalBlobs.mutateAsync({blob: message.blobs[i]});
74
+ if(uploadResult.errors){
75
+ console.error(uploadResult.errors)
76
+ } else{
77
+ result.push(uploadResult);
78
+ }
79
+ }
80
+ addFunc(result);
71
81
  closeFilebrowser();
72
82
  }
73
83
 
84
+ const handleOpen = (callback: ([]:any) => {}) => {
85
+ addFunc = callback
86
+ setModalOpen(true);
87
+ }
88
+
74
89
  const handleClose = () => {
75
90
  closeFilebrowser();
76
91
  }
@@ -86,22 +101,23 @@ const FileBrowser = ({ onFileAdded }: Props) => {
86
101
 
87
102
  return (
88
103
  <>
89
- {options?.enableCloudFiles &&
90
- <>
91
- <Button.UI onClick={() => toggleModal(true)} title="Add file from cloud"><Icon.UI name="cloud" /></Button.UI>
104
+ <CloudFilesContext.Provider value={{open: handleOpen}}>
105
+ {children}
106
+ </CloudFilesContext.Provider>
92
107
 
93
- <Overlay.UI isOpen={modalOpen} className="wy-modal wy-panel wy-loaded">
94
- {!visible &&
95
- <Spinner.UI overlay={true} />
96
- }
108
+ <Overlay.UI isOpen={modalOpen} className="wy-modal wy-panel wy-loaded">
109
+ {!visible &&
110
+ <Spinner.UI overlay={true} />
111
+ }
97
112
 
98
- <iframe ref={frameRef} onLoad={handleFrameLoad} src={frameSrc} className="wy-panel-frame" id="weavy-filebrowser" name="weavy-filebrowser"></iframe>
113
+ <iframe ref={frameRef} onLoad={handleFrameLoad} src={frameSrc} className="wy-panel-frame" id="weavy-filebrowser" name="weavy-filebrowser"></iframe>
99
114
 
100
- </Overlay.UI>
101
- </>
102
- }
115
+ </Overlay.UI>
103
116
  </>
117
+
118
+
104
119
  )
105
- }
120
+ };
121
+
122
+ export default CloudFilesProvider;
106
123
 
107
- export default FileBrowser;
@@ -4,16 +4,19 @@ import Button from '../ui/Button';
4
4
  import Icon from '../ui/Icon';
5
5
  import Preview from '../components/Preview';
6
6
  import { getIcon, getExtension } from "../utils/fileUtilities";
7
+ import classNames from "classnames";
8
+ import openUrl from "../utils/openUrl";
7
9
 
8
10
  export const PreviewContext = createContext<PreviewContextProps>({
9
11
  openPreview: Function,
10
- closePreview: Function
12
+ closePreview: Function,
13
+ setPreviewFiles: Function
11
14
  });
12
15
 
13
16
  function allowedKeyTarget(e: any) {
14
17
  var notInputField = !e.target.matches("input, textarea, select") && !e.target.closest('[contenteditable="true"]');
15
18
  return notInputField;
16
- }
19
+ }
17
20
 
18
21
  type Props = {
19
22
  client: any,
@@ -22,29 +25,35 @@ type Props = {
22
25
 
23
26
  const PreviewProvider = ({ client, children }: Props) => {
24
27
  const [modalPreviewOpen, setModalPreviewOpen] = useState<boolean>(false);
25
- const [attachments, setAttachments] = useState<AttachmentType[]>([]);
26
- const [activeAttachment, setActiveAttchment] = useState<AttachmentType>();
27
-
28
- const [currentAttachmentId, setCurrentAttachmentId] = useState<number | null>();
29
- const [nextAttachmentId, setNextAttachmentId] = useState<number | null>();
30
- const [previousAttachmentId, setPreviousAttachmentId] = useState<number | null>();
31
-
32
- useEffect(() => {
33
-
34
- if (currentAttachmentId) {
35
- var itemIndex = attachments.map(function (a: AttachmentType) { return a.id; }).indexOf(currentAttachmentId);
28
+
29
+ const [files, setFiles] = useState<FileType[]>();
30
+ const [activeFile, setActiveFile] = useState<FileType>();
31
+
32
+ const [currentFileId, setCurrentFileId] = useState<number>();
33
+ const [nextFileId, setNextFileId] = useState<number>();
34
+ const [previousFileId, setPreviousFileId] = useState<number>();
36
35
 
37
- setPreviousAttachmentId(itemIndex > 0 ? attachments[itemIndex - 1].id : null);
38
- setNextAttachmentId(itemIndex + 1 < attachments.length ? attachments[itemIndex + 1].id : null);
39
- setActiveAttchment(attachments.find((a: AttachmentType) => a.id === currentAttachmentId));
36
+
37
+ useEffect(() => {
38
+ if (currentFileId) {
39
+ if (files) {
40
+ let itemIndex = files.map(function (a: FileType) { return a.id; }).indexOf(currentFileId);
41
+
42
+ setPreviousFileId(itemIndex > 0 ? files[itemIndex - 1].id : undefined);
43
+ setNextFileId(itemIndex + 1 < files.length ? files[itemIndex + 1].id : undefined);
44
+ setActiveFile(files.find((a: FileType) => a.id === currentFileId));
45
+ }
40
46
  }
41
47
 
42
- }, [attachments, currentAttachmentId])
48
+ }, [files, files?.length, currentFileId])
43
49
 
44
- const openPreview = (attachments: AttachmentType[], id: number) => {
45
- setAttachments(attachments);
46
- setCurrentAttachmentId(id);
50
+ const setPreviewFiles = (fileList: FileType[]) => {
51
+ //console.log("setPreviewFiles", fileList, isValidInfiniteQuery(fileList) ? "infinite files": "files")
52
+ setFiles(fileList);
53
+ };
47
54
 
55
+ const openPreview = (id: number) => {
56
+ setCurrentFileId(id);
48
57
  setModalPreviewOpen(true);
49
58
  }
50
59
 
@@ -53,120 +62,128 @@ const PreviewProvider = ({ client, children }: Props) => {
53
62
  }
54
63
 
55
64
  const handlePrevious = () => {
56
- setCurrentAttachmentId(previousAttachmentId);
65
+ setCurrentFileId(previousFileId);
57
66
  }
58
67
 
59
68
  const handleNext = () => {
60
- setCurrentAttachmentId(nextAttachmentId);
69
+ setCurrentFileId(nextFileId);
61
70
  }
62
71
 
63
72
  const handleDownload = () => {
64
- window.open(`${activeAttachment?.download_url}&d=1`, "_top");
73
+ if (activeFile && activeFile.download_url) {
74
+ openUrl(activeFile.download_url, "_top", activeFile.name, true)
75
+ }
65
76
  }
66
77
 
67
78
  const handleExternal = () => {
68
- window.open(`${activeAttachment?.external_url}`, "_blank");
79
+ if (activeFile && activeFile.external_url) {
80
+ openUrl(activeFile.external_url, "_blank", activeFile.name)
81
+ }
69
82
  }
70
83
 
71
84
  const handleApplication = () => {
72
- // TODO: Change to webdav-url
73
- window.open(`${activeAttachment?.application_url}`, "_top");
85
+ if (activeFile && activeFile.application_url) {
86
+ openUrl(activeFile.application_url, "_top", activeFile.name)
87
+ }
74
88
  }
75
89
 
76
90
  // Keyboard handlers
77
91
  useEffect(() => {
78
- if (activeAttachment) {
79
- const handleKey = (e: any) => {
80
- if (e.which === 27) { // ESC
81
- e.stopImmediatePropagation();
82
- closePreview()
83
- } else if (e.which === 37) { // LEFT
84
- if (allowedKeyTarget(e)) {
85
- setCurrentAttachmentId(previousAttachmentId);
86
- }
87
- } else if (e.which === 39) { // RIGHT
88
- if (allowedKeyTarget(e)) {
89
- setCurrentAttachmentId(nextAttachmentId);
92
+ if (activeFile) {
93
+ const handleKey = (e: any) => {
94
+ if (modalPreviewOpen) {
95
+ if (e.which === 27) { // ESC
96
+ e.stopImmediatePropagation();
97
+ closePreview()
98
+ } else if (e.which === 37) { // LEFT
99
+ if (allowedKeyTarget(e)) {
100
+ e.stopPropagation();
101
+ setCurrentFileId(previousFileId);
102
+ }
103
+ } else if (e.which === 39) { // RIGHT
104
+ if (allowedKeyTarget(e)) {
105
+ e.stopPropagation();
106
+ setCurrentFileId(nextFileId);
107
+ }
90
108
  }
91
- }
109
+ }
92
110
  };
93
111
 
94
- document.addEventListener("keyup", handleKey);
112
+ document.addEventListener("keyup", handleKey, true);
95
113
 
96
114
  return () => {
97
115
  // cleanup
98
- document.removeEventListener("keyup", handleKey);
116
+ document.removeEventListener("keyup", handleKey, true);
99
117
  }
100
118
  }
101
119
 
102
- }, [activeAttachment])
103
-
120
+ }, [activeFile, modalPreviewOpen])
121
+
122
+ let activeIcon: string = getIcon(activeFile?.name || '').icon;
104
123
 
105
- let activeExt: string = getExtension(activeAttachment?.name || '');
106
- let activeIcon: string = getIcon(activeAttachment?.name || '').icon;
124
+ let previewExt: string = getExtension(activeFile?.name || '');
125
+ let previewIcon: string = getIcon(activeFile?.name || '').icon;
107
126
 
108
- let activeSrc = activeAttachment?.preview_url || activeAttachment?.download_url || '';
127
+ let previewSrc = activeFile?.preview_url || activeFile?.download_url || '';
109
128
 
110
129
  // Let GIF and SVG display raw content
111
- let animatedImage = activeAttachment?.preview_format === "image" && (activeExt === ".gif" || activeExt === ".svg");
130
+ let animatedImage = activeFile?.preview_format === "image" && (previewExt === ".gif" || previewExt === ".svg");
112
131
  if (animatedImage) {
113
- activeSrc = activeAttachment?.download_url || '';
132
+ previewSrc = activeFile?.download_url || '';
114
133
  }
115
134
 
116
135
  return (
117
136
  <>
118
- <PreviewContext.Provider value={{ openPreview: openPreview, closePreview: closePreview }}>
137
+ <PreviewContext.Provider value={{ openPreview: openPreview, closePreview: closePreview, setPreviewFiles: setPreviewFiles }}>
119
138
  {children}
120
139
  </PreviewContext.Provider>
121
140
 
122
- <Overlay.UI isOpen={modalPreviewOpen} className="wy-dark">
141
+ {files && <Overlay.UI isOpen={modalPreviewOpen} className="wy-dark" closeOnEsc={false} onClose={() => setModalPreviewOpen(false)}>
123
142
  <header className="wy-appbars">
124
143
  <nav className="wy-appbar">
125
144
  <Button.UI onClick={closePreview}><Icon.UI name='close' /></Button.UI>
126
- <div className="wy-appbar-text">
127
- {activeAttachment &&
128
- <span>{activeAttachment.name}</span>
145
+ <div className={classNames("wy-appbar-text", { "wy-appbar-text-trashed": activeFile?.is_trashed })}>
146
+ {activeFile &&
147
+ <span>{activeFile.name}</span>
129
148
  }
130
149
 
131
150
  </div>
132
151
  <div className="wy-appbar-buttons">
133
- {activeAttachment?.application_url ?
134
- <Button.UI onClick={handleApplication} title={`Open in app`}><Icon.UI name={activeIcon} /></Button.UI>
135
- :
136
- activeAttachment?.external_url ?
137
- <Button.UI onClick={handleExternal} title={`Open in ${activeAttachment.provider}`}><Icon.UI name={activeIcon} /></Button.UI>
138
- :
139
- <Button.UI onClick={handleDownload}><Icon.UI name='download' /></Button.UI>
140
- }
152
+ {activeFile && <Button.UI onClick={handleDownload}><Icon.UI name='download' /></Button.UI> }
141
153
  </div>
142
154
 
143
155
  </nav>
144
156
  </header>
145
- <div className="wy-preview wy-scroll-y wy-scroll-x">
146
- {activeAttachment &&
147
- <>
148
- {previousAttachmentId &&
149
- <nav className="wy-nav-prev"><Button.UI onClick={handlePrevious}><Icon.UI name="previous" /></Button.UI></nav>
150
- }
151
- {nextAttachmentId &&
152
- <nav className="wy-nav-next"><Button.UI onClick={handleNext}><Icon.UI name="next" /></Button.UI></nav>
153
- }
154
- <Preview
155
- client={client}
156
- src={activeSrc}
157
- link={activeAttachment.external_url}
158
- format={activeAttachment.preview_format}
159
- name={activeAttachment.name}
160
- icon={activeIcon}
161
- width={activeAttachment.width}
162
- height={activeAttachment.height}
163
- mediaType={activeAttachment.media_type}
164
- provider={activeAttachment.provider}
165
- />
166
- </>
167
- }
157
+
158
+ <div className="wy-main">
159
+ <div className="wy-preview">
160
+ {activeFile &&
161
+ <>
162
+ {previousFileId &&
163
+ <nav className="wy-nav-prev"><Button.UI onClick={handlePrevious}><Icon.UI name="previous" /></Button.UI></nav>
164
+ }
165
+ {nextFileId &&
166
+ <nav className="wy-nav-next"><Button.UI onClick={handleNext}><Icon.UI name="next" /></Button.UI></nav>
167
+ }
168
+ <div className="wy-preview-area wy-scroll-y wy-scroll-x">
169
+ <Preview
170
+ client={client}
171
+ src={previewSrc}
172
+ link={activeFile.external_url}
173
+ format={activeFile.is_trashed ? "none" : activeFile.preview_format}
174
+ name={activeFile.name}
175
+ icon={previewIcon}
176
+ width={activeFile.width}
177
+ height={activeFile.height}
178
+ mediaType={activeFile.media_type}
179
+ provider={activeFile.provider}
180
+ />
181
+ </div>
182
+ </>
183
+ }
184
+ </div>
168
185
  </div>
169
- </Overlay.UI>
186
+ </Overlay.UI>}
170
187
 
171
188
  </>
172
189
 
@@ -1,13 +1,14 @@
1
1
  import React, { createContext } from "react";
2
2
  import { QueryClient, QueryClientProvider } from "react-query";
3
3
  import UserProvider from "./UserContext";
4
- import dayjs from 'dayjs';
4
+ import dayjs from 'dayjs';
5
5
  import relativeTime from 'dayjs/plugin/relativeTime';
6
6
  import utc from 'dayjs/plugin/utc';
7
7
  import timezone from 'dayjs/plugin/timezone';
8
8
  import localizedFormat from 'dayjs/plugin/localizedFormat';
9
9
  import PreviewProvider from "./PreviewContext";
10
- import { detectScrollbars, detectScrollbarAdjustments } from '../utils/scrollbarDetection';
10
+ import { detectScrollbars, detectScrollbarAdjustments } from '../utils/scrollbar-detection';
11
+ import CloudFilesProvider from "./CloudFilesContext";
11
12
 
12
13
  dayjs.extend(relativeTime);
13
14
  dayjs.extend(utc);
@@ -29,6 +30,7 @@ type WeavyProviderProperties = {
29
30
  const queryClient = new QueryClient({
30
31
  defaultOptions: {
31
32
  queries: {
33
+ //refetchOnWindowFocus: false,
32
34
  cacheTime: 1000 * 60 * 60 * 24, // 24 hours
33
35
  },
34
36
  },
@@ -51,7 +53,7 @@ const WeavyProvider = ({ children, client, options }: WeavyProviderProperties) =
51
53
  detectScrollbars().then(() => detectScrollbarAdjustments());
52
54
  }
53
55
 
54
- if(!client){
56
+ if (!client) {
55
57
  queryClient.clear();
56
58
  }
57
59
 
@@ -61,9 +63,11 @@ const WeavyProvider = ({ children, client, options }: WeavyProviderProperties) =
61
63
  <QueryClientProvider client={queryClient}>
62
64
  <WeavyContext.Provider value={{ client, options: opts }}>
63
65
  <UserProvider client={client}>
64
- <PreviewProvider client={client}>
65
- {children}
66
- </PreviewProvider>
66
+ <CloudFilesProvider options={opts} client={client}>
67
+ <PreviewProvider client={client}>
68
+ {children}
69
+ </PreviewProvider>
70
+ </CloudFilesProvider>
67
71
  </UserProvider>
68
72
  </WeavyContext.Provider>
69
73
  </QueryClientProvider>
@@ -0,0 +1,23 @@
1
+ import { useContext } from "react";
2
+ import { useQuery } from "react-query";
3
+ import { WeavyContext } from "../contexts/WeavyContext";
4
+
5
+ /// GET a specific app
6
+ export default function useApp(uid: string, options: any) {
7
+ const { client } = useContext(WeavyContext);
8
+
9
+ if (!client) {
10
+ throw new Error('useApp must be used within an WeavyProvider');
11
+ }
12
+
13
+ const getApp = async () => {
14
+ const response = await client.get("/api/apps/" + uid);
15
+ const data = await response.json();
16
+ return data;
17
+ };
18
+
19
+
20
+ return useQuery<AppType>(["apps", uid], getApp, options);
21
+ }
22
+
23
+
@@ -0,0 +1,12 @@
1
+ import React, { useContext } from "react";
2
+ import { CloudFilesContext } from "../contexts/CloudFilesContext";
3
+
4
+ export default function useCloudFiles(callback: Function) {
5
+ const { open} = useContext(CloudFilesContext);
6
+
7
+ const openCloudFiles = () => {
8
+ open(callback);
9
+ }
10
+
11
+ return { openCloudFiles }
12
+ }