@messenger-box/tailwind-ui-inbox 10.0.3-alpha.100
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.
- package/CHANGELOG.md +104 -0
- package/LICENSE +21 -0
- package/jest.config.js +9 -0
- package/lib/cdm-locales/en/translations.json +31 -0
- package/lib/cdm-locales/es/translations.json +31 -0
- package/lib/components/AIAgent/AIAgent.d.ts +21 -0
- package/lib/components/AIAgent/AIAgent.d.ts.map +1 -0
- package/lib/components/AIAgent/AIAgent.js +904 -0
- package/lib/components/AIAgent/AIAgent.js.map +1 -0
- package/lib/components/AIAgent/index.d.ts +2 -0
- package/lib/components/AIAgent/index.d.ts.map +1 -0
- package/lib/components/InboxMessage/CommonMessage.d.ts +8 -0
- package/lib/components/InboxMessage/CommonMessage.d.ts.map +1 -0
- package/lib/components/InboxMessage/CommonMessage.js +35 -0
- package/lib/components/InboxMessage/CommonMessage.js.map +1 -0
- package/lib/components/InboxMessage/ConversationItem.d.ts +14 -0
- package/lib/components/InboxMessage/ConversationItem.d.ts.map +1 -0
- package/lib/components/InboxMessage/ConversationItem.js +200 -0
- package/lib/components/InboxMessage/ConversationItem.js.map +1 -0
- package/lib/components/InboxMessage/InputComponent.d.ts +12 -0
- package/lib/components/InboxMessage/InputComponent.d.ts.map +1 -0
- package/lib/components/InboxMessage/InputComponent.js +359 -0
- package/lib/components/InboxMessage/InputComponent.js.map +1 -0
- package/lib/components/InboxMessage/LeftSidebar.d.ts +20 -0
- package/lib/components/InboxMessage/LeftSidebar.d.ts.map +1 -0
- package/lib/components/InboxMessage/LeftSidebar.js +102 -0
- package/lib/components/InboxMessage/LeftSidebar.js.map +1 -0
- package/lib/components/InboxMessage/MessageInput.d.ts +9 -0
- package/lib/components/InboxMessage/MessageInput.d.ts.map +1 -0
- package/lib/components/InboxMessage/MessageInput.js +154 -0
- package/lib/components/InboxMessage/MessageInput.js.map +1 -0
- package/lib/components/InboxMessage/MessageInputComponent.d.ts +9 -0
- package/lib/components/InboxMessage/MessageInputComponent.d.ts.map +1 -0
- package/lib/components/InboxMessage/Messages.d.ts +17 -0
- package/lib/components/InboxMessage/Messages.d.ts.map +1 -0
- package/lib/components/InboxMessage/Messages.js +99 -0
- package/lib/components/InboxMessage/Messages.js.map +1 -0
- package/lib/components/InboxMessage/MessagesBuilderUi.d.ts +17 -0
- package/lib/components/InboxMessage/MessagesBuilderUi.d.ts.map +1 -0
- package/lib/components/InboxMessage/Popover.d.ts +3 -0
- package/lib/components/InboxMessage/Popover.d.ts.map +1 -0
- package/lib/components/InboxMessage/Popover.js +31 -0
- package/lib/components/InboxMessage/Popover.js.map +1 -0
- package/lib/components/InboxMessage/RightSidebar.d.ts +9 -0
- package/lib/components/InboxMessage/RightSidebar.d.ts.map +1 -0
- package/lib/components/InboxMessage/RightSidebar.js +9 -0
- package/lib/components/InboxMessage/RightSidebar.js.map +1 -0
- package/lib/components/InboxMessage/RightSidebarAi.d.ts +23 -0
- package/lib/components/InboxMessage/RightSidebarAi.d.ts.map +1 -0
- package/lib/components/InboxMessage/RightSidebarAi.js +9 -0
- package/lib/components/InboxMessage/RightSidebarAi.js.map +1 -0
- package/lib/components/InboxMessage/ServiceConversationItem.d.ts +12 -0
- package/lib/components/InboxMessage/ServiceConversationItem.d.ts.map +1 -0
- package/lib/components/InboxMessage/ServiceConversationItem.js +185 -0
- package/lib/components/InboxMessage/ServiceConversationItem.js.map +1 -0
- package/lib/components/InboxMessage/ServiceInboxItem.d.ts +12 -0
- package/lib/components/InboxMessage/ServiceInboxItem.d.ts.map +1 -0
- package/lib/components/InboxMessage/ServiceInboxItem.js +182 -0
- package/lib/components/InboxMessage/ServiceInboxItem.js.map +1 -0
- package/lib/components/InboxMessage/SubscriptionHandler.d.ts +19 -0
- package/lib/components/InboxMessage/SubscriptionHandler.d.ts.map +1 -0
- package/lib/components/InboxMessage/SubscriptionHandler.js +41 -0
- package/lib/components/InboxMessage/SubscriptionHandler.js.map +1 -0
- package/lib/components/InboxMessage/UploadImageButton.d.ts +7 -0
- package/lib/components/InboxMessage/UploadImageButton.d.ts.map +1 -0
- package/lib/components/InboxMessage/UploadImageButton.js +34 -0
- package/lib/components/InboxMessage/UploadImageButton.js.map +1 -0
- package/lib/components/InboxMessage/UserModalContent.d.ts +3 -0
- package/lib/components/InboxMessage/UserModalContent.d.ts.map +1 -0
- package/lib/components/InboxMessage/UserModalContent.js +60 -0
- package/lib/components/InboxMessage/UserModalContent.js.map +1 -0
- package/lib/components/InboxMessage/index.d.ts +17 -0
- package/lib/components/InboxMessage/index.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/CommonMessage.d.ts +11 -0
- package/lib/components/InboxMessage/message-widgets/CommonMessage.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/CommonMessage.js +44 -0
- package/lib/components/InboxMessage/message-widgets/CommonMessage.js.map +1 -0
- package/lib/components/InboxMessage/message-widgets/ErrorFixCard.d.ts +11 -0
- package/lib/components/InboxMessage/message-widgets/ErrorFixCard.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/ErrorFixCard.js +194 -0
- package/lib/components/InboxMessage/message-widgets/ErrorFixCard.js.map +1 -0
- package/lib/components/InboxMessage/message-widgets/MessageCard.d.ts +8 -0
- package/lib/components/InboxMessage/message-widgets/MessageCard.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/MessageSliceRenderer.d.ts +12 -0
- package/lib/components/InboxMessage/message-widgets/MessageSliceRenderer.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/MessageSliceRenderer.js +37 -0
- package/lib/components/InboxMessage/message-widgets/MessageSliceRenderer.js.map +1 -0
- package/lib/components/InboxMessage/message-widgets/ModernMessageGroup.d.ts +18 -0
- package/lib/components/InboxMessage/message-widgets/ModernMessageGroup.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/ModernMessageGroup.js +1082 -0
- package/lib/components/InboxMessage/message-widgets/ModernMessageGroup.js.map +1 -0
- package/lib/components/InboxMessage/message-widgets/PlainMessage.d.ts +8 -0
- package/lib/components/InboxMessage/message-widgets/PlainMessage.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/PlainMessage.js +14 -0
- package/lib/components/InboxMessage/message-widgets/PlainMessage.js.map +1 -0
- package/lib/components/InboxMessage/message-widgets/PropertyMessageWidget.d.ts +9 -0
- package/lib/components/InboxMessage/message-widgets/PropertyMessageWidget.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/SlackLikeMessageGroup.d.ts +14 -0
- package/lib/components/InboxMessage/message-widgets/SlackLikeMessageGroup.d.ts.map +1 -0
- package/lib/components/InboxMessage/message-widgets/SlackLikeMessageGroup.js +333 -0
- package/lib/components/InboxMessage/message-widgets/SlackLikeMessageGroup.js.map +1 -0
- package/lib/components/InboxMessage/message-widgets/index.d.ts +4 -0
- package/lib/components/InboxMessage/message-widgets/index.d.ts.map +1 -0
- package/lib/components/ModelConfigPanel.d.ts +37 -0
- package/lib/components/ModelConfigPanel.d.ts.map +1 -0
- package/lib/components/ModelConfigPanel.js +317 -0
- package/lib/components/ModelConfigPanel.js.map +1 -0
- package/lib/components/filler-components/RightSiderBar.d.ts +24 -0
- package/lib/components/filler-components/RightSiderBar.d.ts.map +1 -0
- package/lib/components/filler-components/RightSiderBar.js +335 -0
- package/lib/components/filler-components/RightSiderBar.js.map +1 -0
- package/lib/components/inbox/FilesList.d.ts +20 -0
- package/lib/components/inbox/FilesList.d.ts.map +1 -0
- package/lib/components/inbox/FilesList.js +68 -0
- package/lib/components/inbox/FilesList.js.map +1 -0
- package/lib/components/inbox/MessageItem.d.ts +17 -0
- package/lib/components/inbox/MessageItem.d.ts.map +1 -0
- package/lib/components/inbox/MessageItem.js +50 -0
- package/lib/components/inbox/MessageItem.js.map +1 -0
- package/lib/components/inbox/ThreadItem.d.ts +11 -0
- package/lib/components/inbox/ThreadItem.d.ts.map +1 -0
- package/lib/components/inbox/ThreadItem.js +147 -0
- package/lib/components/inbox/ThreadItem.js.map +1 -0
- package/lib/components/inbox/index.d.ts +4 -0
- package/lib/components/inbox/index.d.ts.map +1 -0
- package/lib/components/index.d.ts +7 -0
- package/lib/components/index.d.ts.map +1 -0
- package/lib/components/live-code-editor/hybrid-live-editor.d.ts +20 -0
- package/lib/components/live-code-editor/hybrid-live-editor.d.ts.map +1 -0
- package/lib/components/live-code-editor/hybrid-live-editor.js +68 -0
- package/lib/components/live-code-editor/hybrid-live-editor.js.map +1 -0
- package/lib/components/live-code-editor/index.d.ts +4 -0
- package/lib/components/live-code-editor/index.d.ts.map +1 -0
- package/lib/components/live-code-editor/live-code-editor.d.ts +14 -0
- package/lib/components/live-code-editor/live-code-editor.d.ts.map +1 -0
- package/lib/components/live-code-editor/live-code-editor.js +207 -0
- package/lib/components/live-code-editor/live-code-editor.js.map +1 -0
- package/lib/components/slot-fill/chat-message-filler.d.ts +4 -0
- package/lib/components/slot-fill/chat-message-filler.d.ts.map +1 -0
- package/lib/components/slot-fill/chat-message-filler.js +5 -0
- package/lib/components/slot-fill/chat-message-filler.js.map +1 -0
- package/lib/components/slot-fill/chat-message-slot.d.ts +11 -0
- package/lib/components/slot-fill/chat-message-slot.d.ts.map +1 -0
- package/lib/components/slot-fill/chat-message-slot.js +6 -0
- package/lib/components/slot-fill/chat-message-slot.js.map +1 -0
- package/lib/components/slot-fill/index.d.ts +4 -0
- package/lib/components/slot-fill/index.d.ts.map +1 -0
- package/lib/components/slot-fill/right-sidebar-filler.d.ts +4 -0
- package/lib/components/slot-fill/right-sidebar-filler.d.ts.map +1 -0
- package/lib/components/slot-fill/right-sidebar-filler.js +13 -0
- package/lib/components/slot-fill/right-sidebar-filler.js.map +1 -0
- package/lib/components/ui/button.d.ts +9 -0
- package/lib/components/ui/button.d.ts.map +1 -0
- package/lib/compute.d.ts +8 -0
- package/lib/compute.d.ts.map +1 -0
- package/lib/compute.js +137 -0
- package/lib/compute.js.map +1 -0
- package/lib/config/env-config.d.ts +13 -0
- package/lib/config/env-config.d.ts.map +1 -0
- package/lib/config/env-config.js +34 -0
- package/lib/config/env-config.js.map +1 -0
- package/lib/config/index.d.ts +2 -0
- package/lib/config/index.d.ts.map +1 -0
- package/lib/constants/breakpoints.d.ts +8 -0
- package/lib/constants/breakpoints.d.ts.map +1 -0
- package/lib/constants/index.d.ts +3 -0
- package/lib/constants/index.d.ts.map +1 -0
- package/lib/container/AiInbox.d.ts +15 -0
- package/lib/container/AiInbox.d.ts.map +1 -0
- package/lib/container/AiInboxWithLoader.d.ts +36 -0
- package/lib/container/AiInboxWithLoader.d.ts.map +1 -0
- package/lib/container/AiLandingInput.d.ts +4 -0
- package/lib/container/AiLandingInput.d.ts.map +1 -0
- package/lib/container/AiLandingInput.js +101 -0
- package/lib/container/AiLandingInput.js.map +1 -0
- package/lib/container/Inbox.d.ts +15 -0
- package/lib/container/Inbox.d.ts.map +1 -0
- package/lib/container/Inbox.js +955 -0
- package/lib/container/Inbox.js.map +1 -0
- package/lib/container/InboxAiMessagesLoader.d.ts +15 -0
- package/lib/container/InboxAiMessagesLoader.d.ts.map +1 -0
- package/lib/container/InboxAiMessagesLoader.js +30 -0
- package/lib/container/InboxAiMessagesLoader.js.map +1 -0
- package/lib/container/InboxContainer.d.ts +12 -0
- package/lib/container/InboxContainer.d.ts.map +1 -0
- package/lib/container/InboxContainer.js +31 -0
- package/lib/container/InboxContainer.js.map +1 -0
- package/lib/container/InboxTemplate1.d.ts +15 -0
- package/lib/container/InboxTemplate1.d.ts.map +1 -0
- package/lib/container/InboxTemplate1WithLoader.d.ts +36 -0
- package/lib/container/InboxTemplate1WithLoader.d.ts.map +1 -0
- package/lib/container/InboxTemplate2.d.ts +15 -0
- package/lib/container/InboxTemplate2.d.ts.map +1 -0
- package/lib/container/InboxWithAiLoader.d.ts +15 -0
- package/lib/container/InboxWithAiLoader.d.ts.map +1 -0
- package/lib/container/InboxWithAiLoader.js +56 -0
- package/lib/container/InboxWithAiLoader.js.map +1 -0
- package/lib/container/InboxWithLoader.d.ts +36 -0
- package/lib/container/InboxWithLoader.d.ts.map +1 -0
- package/lib/container/InboxWithLoader.js +277 -0
- package/lib/container/InboxWithLoader.js.map +1 -0
- package/lib/container/ServiceInbox.d.ts +9 -0
- package/lib/container/ServiceInbox.d.ts.map +1 -0
- package/lib/container/ServiceInbox.js +144 -0
- package/lib/container/ServiceInbox.js.map +1 -0
- package/lib/container/ThreadMessages.d.ts +13 -0
- package/lib/container/ThreadMessages.d.ts.map +1 -0
- package/lib/container/ThreadMessages.js +314 -0
- package/lib/container/ThreadMessages.js.map +1 -0
- package/lib/container/ThreadMessagesInbox.d.ts +14 -0
- package/lib/container/ThreadMessagesInbox.d.ts.map +1 -0
- package/lib/container/ThreadMessagesInbox.js +341 -0
- package/lib/container/ThreadMessagesInbox.js.map +1 -0
- package/lib/container/Threads.d.ts +8 -0
- package/lib/container/Threads.d.ts.map +1 -0
- package/lib/container/Threads.js +231 -0
- package/lib/container/Threads.js.map +1 -0
- package/lib/container/ThreadsInbox.d.ts +21 -0
- package/lib/container/ThreadsInbox.d.ts.map +1 -0
- package/lib/container/ThreadsInbox.js +244 -0
- package/lib/container/ThreadsInbox.js.map +1 -0
- package/lib/container/apply-footer-styles.d.ts +2 -0
- package/lib/container/apply-footer-styles.d.ts.map +1 -0
- package/lib/container/apply-footer-styles.js +16 -0
- package/lib/container/apply-footer-styles.js.map +1 -0
- package/lib/container/index.d.ts +13 -0
- package/lib/container/index.d.ts.map +1 -0
- package/lib/enums/index.d.ts +2 -0
- package/lib/enums/index.d.ts.map +1 -0
- package/lib/enums/messenger-slot-fill-name-enum.d.ts +5 -0
- package/lib/enums/messenger-slot-fill-name-enum.d.ts.map +1 -0
- package/lib/enums/messenger-slot-fill-name-enum.js +5 -0
- package/lib/enums/messenger-slot-fill-name-enum.js.map +1 -0
- package/lib/hooks/index.d.ts +3 -0
- package/lib/hooks/index.d.ts.map +1 -0
- package/lib/hooks/use-file-sync.d.ts +16 -0
- package/lib/hooks/use-file-sync.d.ts.map +1 -0
- package/lib/hooks/use-file-sync.js +63 -0
- package/lib/hooks/use-file-sync.js.map +1 -0
- package/lib/hooks/usePersistentModelConfig.d.ts +15 -0
- package/lib/hooks/usePersistentModelConfig.d.ts.map +1 -0
- package/lib/hooks/usePersistentModelConfig.js +46 -0
- package/lib/hooks/usePersistentModelConfig.js.map +1 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -0
- package/lib/interfaces/index.d.ts +2 -0
- package/lib/interfaces/index.d.ts.map +1 -0
- package/lib/interfaces/message-widgets.interface.d.ts +21 -0
- package/lib/interfaces/message-widgets.interface.d.ts.map +1 -0
- package/lib/machines/aiAgentMachine.d.ts +3 -0
- package/lib/machines/aiAgentMachine.d.ts.map +1 -0
- package/lib/machines/aiAgentMachine.js +1083 -0
- package/lib/machines/aiAgentMachine.js.map +1 -0
- package/lib/machines/aiAgentMachine.simple.d.ts +3 -0
- package/lib/machines/aiAgentMachine.simple.d.ts.map +1 -0
- package/lib/machines/aiAgentMachine.simple.js +108 -0
- package/lib/machines/aiAgentMachine.simple.js.map +1 -0
- package/lib/machines/index.d.ts +3 -0
- package/lib/machines/index.d.ts.map +1 -0
- package/lib/machines/types.d.ts +77 -0
- package/lib/machines/types.d.ts.map +1 -0
- package/lib/module.d.ts +7 -0
- package/lib/module.d.ts.map +1 -0
- package/lib/module.js +26 -0
- package/lib/module.js.map +1 -0
- package/lib/routes.json +98 -0
- package/lib/styles/responsive.css +76 -0
- package/lib/templates/InboxWithAi.d.ts +15 -0
- package/lib/templates/InboxWithAi.d.ts.map +1 -0
- package/lib/templates/InboxWithAi.js +440 -0
- package/lib/templates/InboxWithAi.js.map +1 -0
- package/lib/templates/InboxWithAi.tsx +533 -0
- package/lib/templates/index.d.ts +2 -0
- package/lib/templates/index.d.ts.map +1 -0
- package/lib/templates/index.ts +1 -0
- package/lib/utils/utils.d.ts +2 -0
- package/lib/utils/utils.d.ts.map +1 -0
- package/lib/utils/utils.js +3 -0
- package/lib/utils/utils.js.map +1 -0
- package/package.json +62 -0
- package/rollup.config.mjs +35 -0
- package/src/cdm-locales/en/translations.json +31 -0
- package/src/cdm-locales/es/translations.json +31 -0
- package/src/components/AIAgent/AIAgent.tsx +1103 -0
- package/src/components/AIAgent/AIAgent.tsx.bk +1365 -0
- package/src/components/AIAgent/README.md +82 -0
- package/src/components/AIAgent/index.ts +1 -0
- package/src/components/InboxMessage/CommonMessage.tsx +40 -0
- package/src/components/InboxMessage/ConversationItem.tsx +255 -0
- package/src/components/InboxMessage/InputComponent.tsx +462 -0
- package/src/components/InboxMessage/LeftSidebar.tsx +140 -0
- package/src/components/InboxMessage/MessageInput.tsx +209 -0
- package/src/components/InboxMessage/MessageInputComponent.tsx +245 -0
- package/src/components/InboxMessage/Messages.tsx +137 -0
- package/src/components/InboxMessage/MessagesBuilderUi.tsx +205 -0
- package/src/components/InboxMessage/Popover.tsx +42 -0
- package/src/components/InboxMessage/RightSidebar.tsx +22 -0
- package/src/components/InboxMessage/RightSidebarAi.tsx +37 -0
- package/src/components/InboxMessage/ServiceConversationItem.tsx +234 -0
- package/src/components/InboxMessage/ServiceInboxItem.tsx +223 -0
- package/src/components/InboxMessage/SubscriptionHandler.tsx +55 -0
- package/src/components/InboxMessage/UploadImageButton.tsx +46 -0
- package/src/components/InboxMessage/UserModalContent.tsx +60 -0
- package/src/components/InboxMessage/index.ts +16 -0
- package/src/components/InboxMessage/message-widgets/CommonMessage.tsx +69 -0
- package/src/components/InboxMessage/message-widgets/ErrorFixCard.tsx +240 -0
- package/src/components/InboxMessage/message-widgets/MessageCard.tsx +127 -0
- package/src/components/InboxMessage/message-widgets/MessageSliceRenderer.tsx +40 -0
- package/src/components/InboxMessage/message-widgets/ModernMessageGroup.tsx +1295 -0
- package/src/components/InboxMessage/message-widgets/PlainMessage.tsx +18 -0
- package/src/components/InboxMessage/message-widgets/PropertyMessageWidget.tsx +29 -0
- package/src/components/InboxMessage/message-widgets/SlackLikeMessageGroup.tsx +492 -0
- package/src/components/InboxMessage/message-widgets/index.ts +3 -0
- package/src/components/ModelConfigPanel.tsx +345 -0
- package/src/components/filler-components/RightSiderBar.tsx +408 -0
- package/src/components/inbox/FilesList.tsx +89 -0
- package/src/components/inbox/MessageItem.tsx +50 -0
- package/src/components/inbox/ThreadItem.tsx +295 -0
- package/src/components/inbox/index.ts +3 -0
- package/src/components/index.ts +22 -0
- package/src/components/live-code-editor/hybrid-live-editor.tsx +105 -0
- package/src/components/live-code-editor/index.ts +3 -0
- package/src/components/live-code-editor/live-code-editor.tsx +257 -0
- package/src/components/slot-fill/chat-message-filler.tsx +18 -0
- package/src/components/slot-fill/chat-message-slot.tsx +18 -0
- package/src/components/slot-fill/index.ts +3 -0
- package/src/components/slot-fill/right-sidebar-filler.tsx +39 -0
- package/src/components/ui/button.tsx +32 -0
- package/src/compute.ts +134 -0
- package/src/config/env-config.ts +17 -0
- package/src/config/index.ts +1 -0
- package/src/constants/breakpoints.ts +7 -0
- package/src/constants/index.ts +5 -0
- package/src/container/AiInbox.tsx +1819 -0
- package/src/container/AiInboxWithLoader.tsx +356 -0
- package/src/container/AiLandingInput.tsx +221 -0
- package/src/container/Inbox.tsx +1092 -0
- package/src/container/InboxAiMessagesLoader.tsx +44 -0
- package/src/container/InboxContainer.tsx +35 -0
- package/src/container/InboxTemplate1.tsx +1542 -0
- package/src/container/InboxTemplate1WithLoader.tsx +338 -0
- package/src/container/InboxTemplate2.tsx +1606 -0
- package/src/container/InboxWithAiLoader.tsx +76 -0
- package/src/container/InboxWithLoader.tsx +341 -0
- package/src/container/ServiceInbox.tsx +190 -0
- package/src/container/ThreadMessages.tsx +371 -0
- package/src/container/ThreadMessagesInbox.tsx +450 -0
- package/src/container/Threads.tsx +270 -0
- package/src/container/ThreadsInbox.tsx +354 -0
- package/src/container/apply-footer-styles.ts +17 -0
- package/src/container/index.ts +31 -0
- package/src/enums/index.ts +1 -0
- package/src/enums/messenger-slot-fill-name-enum.ts +4 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/use-file-sync.ts +91 -0
- package/src/hooks/usePersistentModelConfig.ts +63 -0
- package/src/index.ts +37 -0
- package/src/interfaces/index.ts +1 -0
- package/src/interfaces/message-widgets.interface.ts +21 -0
- package/src/machines/aiAgentMachine.simple.ts +89 -0
- package/src/machines/aiAgentMachine.ts +1296 -0
- package/src/machines/aiAgentMachine.ts.bk +1296 -0
- package/src/machines/index.ts +2 -0
- package/src/machines/types.ts +59 -0
- package/src/module.tsx +32 -0
- package/src/styles/responsive.css +76 -0
- package/src/templates/InboxWithAi.tsx +533 -0
- package/src/templates/index.ts +1 -0
- package/src/utils/utils.ts +3 -0
- package/tsconfig.json +14 -0
- package/webpack.config.js +92 -0
|
@@ -0,0 +1,955 @@
|
|
|
1
|
+
import React__default,{useReducer,useMemo,useEffect,useCallback,useRef}from'react';import {uniqBy,orderBy}from'lodash-es';import {MessagesDocument,useSendMessagesMutation,OnChatMessageAddedDocument}from'common/graphql';import {useUploadFiles}from'@messenger-box/platform-client';import {RoomType}from'common';import {useSelector,shallowEqual}from'react-redux';import {useParams,useNavigate}from'@remix-run/react';import'../components/inbox/FilesList.js';import'../components/inbox/MessageItem.js';import'../components/inbox/ThreadItem.js';import'date-fns';import'@react-icons/all-files/bs/BsFlag.js';import'../components/InboxMessage/ConversationItem.js';import'../components/InboxMessage/ServiceConversationItem.js';import {LeftSidebar}from'../components/InboxMessage/LeftSidebar.js';import {MessageInput}from'../components/InboxMessage/MessageInput.js';import {Messages}from'../components/InboxMessage/Messages.js';import'react-i18next';import'@react-icons/all-files/bi/BiImage.js';import'@react-icons/all-files/ai/AiOutlineSecurityScan.js';import'@react-icons/all-files/fi/FiCheck.js';import'@react-icons/all-files/bs/BsFillStarFill.js';import'@common-stack/components-pro';import'react-markdown';import'remark-gfm';import {RightSidebar}from'../components/InboxMessage/RightSidebar.js';import'../components/InboxMessage/ServiceInboxItem.js';import {config}from'../config/env-config.js';import'../components/ModelConfigPanel.js';import'../enums/messenger-slot-fill-name-enum.js';import {objectId}from'@messenger-box/core';import'../components/live-code-editor/hybrid-live-editor.js';import'../components/AIAgent/AIAgent.js';import {userSelector}from'@adminide-stack/user-auth0-client';import {applyFooterStyles}from'./apply-footer-styles.js';import {ThreadsInbox}from'./ThreadsInbox.js';import {ThreadMessagesInbox}from'./ThreadMessagesInbox.js';import {useApolloClient}from'@apollo/client/index.js';import {SubscriptionHandler}from'../components/InboxMessage/SubscriptionHandler.js';const {
|
|
2
|
+
MESSAGES_PER_PAGE
|
|
3
|
+
} = config;
|
|
4
|
+
// Static utility hooks and components
|
|
5
|
+
const useMediaQuery = query => {
|
|
6
|
+
const [matches, setMatches] = React__default.useState(false);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
if (typeof window === 'undefined') return;
|
|
9
|
+
const mediaQuery = window.matchMedia(query);
|
|
10
|
+
const updateMatches = () => setMatches(mediaQuery.matches);
|
|
11
|
+
updateMatches();
|
|
12
|
+
mediaQuery.addEventListener('change', updateMatches);
|
|
13
|
+
return () => mediaQuery.removeEventListener('change', updateMatches);
|
|
14
|
+
}, [query]);
|
|
15
|
+
return matches;
|
|
16
|
+
};
|
|
17
|
+
// Hook to get window dimensions
|
|
18
|
+
const useWindowDimensions = () => {
|
|
19
|
+
const [windowDimensions, setWindowDimensions] = React__default.useState({
|
|
20
|
+
width: typeof window !== 'undefined' ? window.innerWidth : 1024,
|
|
21
|
+
height: typeof window !== 'undefined' ? window.innerHeight : 768
|
|
22
|
+
});
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (typeof window === 'undefined') return;
|
|
25
|
+
const handleResize = () => {
|
|
26
|
+
setWindowDimensions({
|
|
27
|
+
width: window.innerWidth,
|
|
28
|
+
height: window.innerHeight
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
window.addEventListener('resize', handleResize);
|
|
32
|
+
handleResize(); // Set initial dimensions
|
|
33
|
+
return () => window.removeEventListener('resize', handleResize);
|
|
34
|
+
}, []);
|
|
35
|
+
return windowDimensions;
|
|
36
|
+
};
|
|
37
|
+
// Static components
|
|
38
|
+
const Spinner = React__default.memo(({
|
|
39
|
+
className = ''
|
|
40
|
+
}) => React__default.createElement("div", {
|
|
41
|
+
className: `animate-spin rounded-full border-4 border-gray-200 border-t-blue-500 ${className}`
|
|
42
|
+
}, React__default.createElement("span", {
|
|
43
|
+
className: "sr-only"
|
|
44
|
+
}, "Loading...")));
|
|
45
|
+
const Drawer = React__default.memo(({
|
|
46
|
+
isOpen,
|
|
47
|
+
onClose,
|
|
48
|
+
children,
|
|
49
|
+
title
|
|
50
|
+
}) => {
|
|
51
|
+
if (!isOpen) return null;
|
|
52
|
+
return React__default.createElement("div", {
|
|
53
|
+
className: "fixed inset-0 z-50 overflow-hidden"
|
|
54
|
+
}, React__default.createElement("div", {
|
|
55
|
+
className: "absolute inset-0 bg-black bg-opacity-50",
|
|
56
|
+
onClick: onClose
|
|
57
|
+
}), React__default.createElement("div", {
|
|
58
|
+
className: "absolute bottom-0 left-0 right-0 bg-white rounded-t-lg shadow-lg max-h-[80vh] flex flex-col overflow-hidden"
|
|
59
|
+
}, React__default.createElement("div", {
|
|
60
|
+
className: "flex items-center justify-between p-4 border-b border-gray-200 flex-shrink-0"
|
|
61
|
+
}, React__default.createElement("h2", {
|
|
62
|
+
className: "text-lg font-semibold truncate"
|
|
63
|
+
}, title), React__default.createElement("button", {
|
|
64
|
+
onClick: onClose,
|
|
65
|
+
className: "p-1 hover:bg-gray-100 rounded-full transition-colors flex-shrink-0 ml-2"
|
|
66
|
+
}, React__default.createElement("svg", {
|
|
67
|
+
className: "w-6 h-6",
|
|
68
|
+
fill: "none",
|
|
69
|
+
stroke: "currentColor",
|
|
70
|
+
viewBox: "0 0 24 24"
|
|
71
|
+
}, React__default.createElement("path", {
|
|
72
|
+
strokeLinecap: "round",
|
|
73
|
+
strokeLinejoin: "round",
|
|
74
|
+
strokeWidth: 2,
|
|
75
|
+
d: "M6 18L18 6M6 6l12 12"
|
|
76
|
+
})))), React__default.createElement("div", {
|
|
77
|
+
className: "flex-1 p-4 overflow-y-auto",
|
|
78
|
+
style: {
|
|
79
|
+
minHeight: 0
|
|
80
|
+
}
|
|
81
|
+
}, children)));
|
|
82
|
+
});
|
|
83
|
+
const EmptyState = React__default.memo(() => React__default.createElement("div", {
|
|
84
|
+
className: "h-full flex items-center justify-center bg-gray-100 p-4 sm:p-6 overflow-hidden"
|
|
85
|
+
}, React__default.createElement("div", {
|
|
86
|
+
className: "text-center max-w-sm mx-auto"
|
|
87
|
+
}, React__default.createElement("div", {
|
|
88
|
+
className: "text-3xl sm:text-4xl text-gray-400 mb-4"
|
|
89
|
+
}, "\uD83D\uDCAC"), React__default.createElement("h3", {
|
|
90
|
+
className: "text-lg sm:text-xl font-semibold text-gray-600 mb-2"
|
|
91
|
+
}, "Welcome to Messenger"), React__default.createElement("p", {
|
|
92
|
+
className: "text-sm sm:text-base text-gray-500 leading-relaxed"
|
|
93
|
+
}, "Select a conversation from the sidebar to start messaging"))));
|
|
94
|
+
// Mobile preview reducer
|
|
95
|
+
const mobilePreviewReducer = (state, action) => {
|
|
96
|
+
if (action.type === 'update') {
|
|
97
|
+
return {
|
|
98
|
+
...state,
|
|
99
|
+
...action.payload
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
return state;
|
|
103
|
+
};
|
|
104
|
+
const Inbox = props => {
|
|
105
|
+
const {
|
|
106
|
+
channelFilters: channelFilterProp,
|
|
107
|
+
channelRole,
|
|
108
|
+
supportServices,
|
|
109
|
+
data,
|
|
110
|
+
orgName,
|
|
111
|
+
pathPrefix = null
|
|
112
|
+
} = props;
|
|
113
|
+
const {
|
|
114
|
+
id: pathChannelId,
|
|
115
|
+
postId: pathPostId
|
|
116
|
+
} = useParams();
|
|
117
|
+
const navigate = useNavigate();
|
|
118
|
+
const apolloClient = useApolloClient();
|
|
119
|
+
// Reduced state - only UI state remains, data comes from Apollo cache
|
|
120
|
+
const [isBottomDrawerOpen, setBottomDrawer] = React__default.useState(false);
|
|
121
|
+
const [mobilePreviewState, localDispatch] = useReducer(mobilePreviewReducer, {
|
|
122
|
+
mobilePreviewVisibility: false,
|
|
123
|
+
mobilePreviewText: false,
|
|
124
|
+
mobilePreviewCTAText: false
|
|
125
|
+
});
|
|
126
|
+
// Hooks - improved responsive breakpoints with better granularity
|
|
127
|
+
const {
|
|
128
|
+
width: windowWidth,
|
|
129
|
+
height: windowHeight
|
|
130
|
+
} = useWindowDimensions();
|
|
131
|
+
const isMobileView = useMediaQuery('(max-width: 640px)');
|
|
132
|
+
const isSmallTabletView = useMediaQuery('(min-width: 641px) and (max-width: 900px)');
|
|
133
|
+
const isTabletView = useMediaQuery('(min-width: 901px) and (max-width: 1024px)');
|
|
134
|
+
const isDesktopView = useMediaQuery('(min-width: 1025px)');
|
|
135
|
+
const isLargeDesktopView = useMediaQuery('(min-width: 1440px)');
|
|
136
|
+
const isSmallScreen = useMediaQuery('(max-width: 900px)');
|
|
137
|
+
// const auth = useSelector(userSelector);
|
|
138
|
+
const auth = useSelector(userSelector, shallowEqual);
|
|
139
|
+
// const user = useSelector((state: any) => state.user, shallowEqual);
|
|
140
|
+
// Data destructuring from Apollo queries
|
|
141
|
+
const GetChannelsByUserQuery = data?.[0];
|
|
142
|
+
const {
|
|
143
|
+
data: userChannels,
|
|
144
|
+
loading: userChannelsLoading,
|
|
145
|
+
refetch: getChannelsRefetch
|
|
146
|
+
} = GetChannelsByUserQuery || {};
|
|
147
|
+
// Get data directly from Apollo cache instead of local state
|
|
148
|
+
const channels = useMemo(() => {
|
|
149
|
+
if (!userChannels?.channelsByUser && !userChannels?.supportServiceChannels) return [];
|
|
150
|
+
return uniqBy([...(userChannels?.supportServiceChannels ?? []), ...(userChannels?.channelsByUser ?? [])], 'id');
|
|
151
|
+
}, [userChannels]);
|
|
152
|
+
// Memoize stable channel array to prevent unnecessary re-renders
|
|
153
|
+
const stableChannels = useMemo(() => {
|
|
154
|
+
return channels || [];
|
|
155
|
+
}, [channels]);
|
|
156
|
+
// Memoized values derived from Apollo cache data
|
|
157
|
+
const channelFilters = useMemo(() => {
|
|
158
|
+
const filters = {
|
|
159
|
+
...channelFilterProp
|
|
160
|
+
};
|
|
161
|
+
const channelType = filters?.type ?? RoomType.Direct;
|
|
162
|
+
filters.type = supportServices ? [channelType, RoomType.Service] : channelType;
|
|
163
|
+
return filters;
|
|
164
|
+
}, [channelFilterProp, supportServices]);
|
|
165
|
+
const users = useMemo(() => {
|
|
166
|
+
return channels?.reduce((acc, curr) => {
|
|
167
|
+
const newMembers = curr.members?.filter(({
|
|
168
|
+
user
|
|
169
|
+
}) => !acc.find(({
|
|
170
|
+
id
|
|
171
|
+
}) => id === user.id)) || [];
|
|
172
|
+
return [...acc, ...newMembers.map(({
|
|
173
|
+
user
|
|
174
|
+
}) => user)];
|
|
175
|
+
}, []) || [];
|
|
176
|
+
}, [channels]);
|
|
177
|
+
// const currentUser = useMemo(
|
|
178
|
+
// () => users?.find((user) => user && user.alias?.includes(auth?.authUserId)),
|
|
179
|
+
// [users, auth?.authUserId],
|
|
180
|
+
// );
|
|
181
|
+
const currentUser = auth;
|
|
182
|
+
const channelName = useMemo(() => {
|
|
183
|
+
if (!channels || !pathChannelId) return '';
|
|
184
|
+
const currChannel = channels?.find(ch => ch.id === pathChannelId);
|
|
185
|
+
if (!currChannel) return '';
|
|
186
|
+
const {
|
|
187
|
+
members,
|
|
188
|
+
title,
|
|
189
|
+
type
|
|
190
|
+
} = currChannel;
|
|
191
|
+
if (type === RoomType.Direct && members?.length >= 2) {
|
|
192
|
+
const otherUser = members.find(member => member.user.id !== currentUser?.id);
|
|
193
|
+
if (otherUser?.user) {
|
|
194
|
+
const {
|
|
195
|
+
givenName,
|
|
196
|
+
familyName
|
|
197
|
+
} = otherUser.user;
|
|
198
|
+
if (givenName && familyName) return `${givenName} ${familyName}`;
|
|
199
|
+
return givenName || familyName || title || 'Direct Message';
|
|
200
|
+
}
|
|
201
|
+
return title || 'Direct Message';
|
|
202
|
+
}
|
|
203
|
+
if (type === RoomType.Direct && members?.length === 1) {
|
|
204
|
+
if (members[0].user?.givenName && members[0]?.user?.familyName) {
|
|
205
|
+
return `${members[0].user?.givenName} ${members[0].user?.familyName}`;
|
|
206
|
+
}
|
|
207
|
+
return members[0].user?.givenName || members[0].user?.familyName || 'Direct Message';
|
|
208
|
+
}
|
|
209
|
+
return title || 'Channel';
|
|
210
|
+
}, [channels, pathChannelId, currentUser]);
|
|
211
|
+
// Effects
|
|
212
|
+
useEffect(() => {
|
|
213
|
+
applyFooterStyles();
|
|
214
|
+
// Optimistic refetch with cache update
|
|
215
|
+
const timeout = setTimeout(() => {
|
|
216
|
+
getChannelsRefetch?.({
|
|
217
|
+
role: channelRole,
|
|
218
|
+
criteria: orgName ? {
|
|
219
|
+
...channelFilters,
|
|
220
|
+
orgName: channelFilters?.orgName || orgName || ''
|
|
221
|
+
} : channelFilters,
|
|
222
|
+
supportServices: !!supportServices,
|
|
223
|
+
supportServiceCriteria: {
|
|
224
|
+
type: RoomType.Service
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
}, 0);
|
|
228
|
+
return () => clearTimeout(timeout);
|
|
229
|
+
}, [channelRole, channelFilters, supportServices, getChannelsRefetch]);
|
|
230
|
+
// Optimistic navigation with cache updates
|
|
231
|
+
const handleSelectChannel = useCallback(async (channelId, pId = null) => {
|
|
232
|
+
// Optimistic UI update
|
|
233
|
+
const mainPath = orgName ? pId ? `/o/${orgName}/direct-message/${channelId}/${pId}` : `/o/${orgName}/direct-message/${channelId}` : pId ? `/inbox/${channelId}/${pId}` : `/inbox/${channelId}`;
|
|
234
|
+
const basePath = pathPrefix ? `${pathPrefix}${mainPath}` : mainPath;
|
|
235
|
+
const searchParams = new URLSearchParams();
|
|
236
|
+
// if (channelRole) searchParams.set('channelRole', channelRole);
|
|
237
|
+
// if (orgName) searchParams.set('orgName', orgName);
|
|
238
|
+
const newPath = searchParams.toString() ? `${basePath}?${searchParams.toString()}` : basePath;
|
|
239
|
+
navigate(newPath, {
|
|
240
|
+
replace: true
|
|
241
|
+
});
|
|
242
|
+
// Optimistically update Apollo cache for immediate UI feedback
|
|
243
|
+
try {
|
|
244
|
+
apolloClient.writeQuery({
|
|
245
|
+
query: MessagesDocument,
|
|
246
|
+
variables: {
|
|
247
|
+
channelId: channelId.toString(),
|
|
248
|
+
parentId: null,
|
|
249
|
+
limit: MESSAGES_PER_PAGE
|
|
250
|
+
},
|
|
251
|
+
data: {
|
|
252
|
+
messages: {
|
|
253
|
+
__typename: 'Messages',
|
|
254
|
+
data: [],
|
|
255
|
+
totalCount: 0,
|
|
256
|
+
messagesRefId: channelId
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
} catch (error) {
|
|
261
|
+
// Cache write might fail if query hasn't been executed yet, that's OK
|
|
262
|
+
console.debug('Cache write failed (expected on first load):', error);
|
|
263
|
+
}
|
|
264
|
+
}, [navigate, apolloClient, orgName, channelRole, pathPrefix]);
|
|
265
|
+
const detailSidebarOptions = useMemo(() => ({
|
|
266
|
+
isMobileView,
|
|
267
|
+
isSmallTabletView,
|
|
268
|
+
isTabletView,
|
|
269
|
+
isDesktopView,
|
|
270
|
+
isLargeDesktopView,
|
|
271
|
+
isSmallScreen,
|
|
272
|
+
setMobilePreviewCTAText: v => localDispatch({
|
|
273
|
+
payload: {
|
|
274
|
+
mobilePreviewCTAText: v
|
|
275
|
+
},
|
|
276
|
+
type: 'update'
|
|
277
|
+
}),
|
|
278
|
+
setMobilePreviewText: v => localDispatch({
|
|
279
|
+
payload: {
|
|
280
|
+
mobilePreviewText: v
|
|
281
|
+
},
|
|
282
|
+
type: 'update'
|
|
283
|
+
}),
|
|
284
|
+
setMobilePreviewVisibility: v => localDispatch({
|
|
285
|
+
payload: {
|
|
286
|
+
mobilePreviewVisibility: v
|
|
287
|
+
},
|
|
288
|
+
type: 'update'
|
|
289
|
+
})
|
|
290
|
+
}), [isMobileView, isSmallTabletView, isTabletView, isDesktopView, isLargeDesktopView, isSmallScreen]);
|
|
291
|
+
return React__default.createElement("div", {
|
|
292
|
+
className: "border-t border-gray-300 flex overflow-hidden",
|
|
293
|
+
style: {
|
|
294
|
+
height: `${windowHeight}px`,
|
|
295
|
+
maxHeight: '100vh'
|
|
296
|
+
}
|
|
297
|
+
}, React__default.createElement("div", {
|
|
298
|
+
className: `
|
|
299
|
+
flex-shrink-0 bg-gray-50 border-r border-gray-300 overflow-hidden transition-all duration-300 ease-in-out
|
|
300
|
+
${isMobileView && pathChannelId ? 'hidden' : ''}
|
|
301
|
+
`,
|
|
302
|
+
style: {
|
|
303
|
+
width: isMobileView && !pathChannelId ? '100%' : isMobileView && pathChannelId ? '0px' : isSmallTabletView ? `${Math.min(288, windowWidth * 0.35)}px` // w-72 or 35% of window
|
|
304
|
+
: isTabletView ? `${Math.min(320, windowWidth * 0.3)}px` // w-80 or 30% of window
|
|
305
|
+
: isLargeDesktopView ? `${Math.min(384, windowWidth * 0.25)}px` // w-96 or 25% of window
|
|
306
|
+
: `${Math.min(320, windowWidth * 0.28)}px`,
|
|
307
|
+
// w-80 or 28% of window
|
|
308
|
+
height: `${windowHeight}px`,
|
|
309
|
+
maxHeight: '100vh'
|
|
310
|
+
}
|
|
311
|
+
}, React__default.createElement(LeftSidebar, {
|
|
312
|
+
currentUser: currentUser,
|
|
313
|
+
userChannels: stableChannels,
|
|
314
|
+
userChannelsLoading: userChannelsLoading,
|
|
315
|
+
users: users,
|
|
316
|
+
handleSelectChannel: handleSelectChannel,
|
|
317
|
+
selectedChannelId: pathChannelId,
|
|
318
|
+
channelToTop: 0,
|
|
319
|
+
getChannelsRefetch: getChannelsRefetch,
|
|
320
|
+
role: channelRole,
|
|
321
|
+
messagesQuery: data?.[1],
|
|
322
|
+
windowHeight: windowHeight,
|
|
323
|
+
windowWidth: windowWidth
|
|
324
|
+
})), React__default.createElement("div", {
|
|
325
|
+
className: `
|
|
326
|
+
flex-1 min-w-0 flex flex-col overflow-hidden transition-all duration-300 ease-in-out
|
|
327
|
+
${isMobileView && !pathChannelId ? 'hidden' : 'flex'}
|
|
328
|
+
`,
|
|
329
|
+
style: {
|
|
330
|
+
minWidth: isSmallScreen ? '300px' : isDesktopView ? '500px' : '400px',
|
|
331
|
+
width: 'auto',
|
|
332
|
+
height: `${windowHeight}px`,
|
|
333
|
+
maxHeight: '100vh'
|
|
334
|
+
}
|
|
335
|
+
}, pathChannelId ? React__default.createElement(ContentComponent, {
|
|
336
|
+
channelId: pathChannelId,
|
|
337
|
+
postId: pathPostId,
|
|
338
|
+
channelRole: channelRole,
|
|
339
|
+
pathPrefix: props.pathPrefix,
|
|
340
|
+
isMobileView: isMobileView,
|
|
341
|
+
isSmallTabletView: isSmallTabletView,
|
|
342
|
+
isTabletView: isTabletView,
|
|
343
|
+
isDesktopView: isDesktopView,
|
|
344
|
+
isLargeDesktopView: isLargeDesktopView,
|
|
345
|
+
isSmallScreen: isSmallScreen,
|
|
346
|
+
windowWidth: windowWidth,
|
|
347
|
+
windowHeight: windowHeight,
|
|
348
|
+
mobilePreviewState: mobilePreviewState,
|
|
349
|
+
detailSidebarOptions: detailSidebarOptions,
|
|
350
|
+
isBottomDrawerOpen: isBottomDrawerOpen,
|
|
351
|
+
setBottomDrawer: setBottomDrawer,
|
|
352
|
+
channelName: channelName,
|
|
353
|
+
loaderdata: data
|
|
354
|
+
}) : React__default.createElement(EmptyState, null)), pathChannelId && data?.[1] && isDesktopView &&
|
|
355
|
+
// <div
|
|
356
|
+
// className="border-l border-gray-200 bg-white flex-shrink-0 overflow-hidden"
|
|
357
|
+
// style={{
|
|
358
|
+
// width: isLargeDesktopView
|
|
359
|
+
// ? `${Math.min(384, windowWidth * 0.25)}px` // w-96 or 25% of window
|
|
360
|
+
// : `${Math.min(320, windowWidth * 0.22)}px`, // w-80 or 22% of window
|
|
361
|
+
// height: `${windowHeight}px`,
|
|
362
|
+
// maxHeight: '100vh'
|
|
363
|
+
// }}
|
|
364
|
+
// >
|
|
365
|
+
React__default.createElement(RightSidebarWrapper, {
|
|
366
|
+
MessagesLoaderQuery: data?.[1],
|
|
367
|
+
selectedPost: null,
|
|
368
|
+
detailSidebarOptions: detailSidebarOptions
|
|
369
|
+
})
|
|
370
|
+
// </div>
|
|
371
|
+
);
|
|
372
|
+
};
|
|
373
|
+
const ContentComponent = React__default.memo(props => {
|
|
374
|
+
const {
|
|
375
|
+
channelId,
|
|
376
|
+
channelRole,
|
|
377
|
+
pathPrefix,
|
|
378
|
+
postId,
|
|
379
|
+
isMobileView,
|
|
380
|
+
isSmallTabletView,
|
|
381
|
+
isTabletView,
|
|
382
|
+
isDesktopView,
|
|
383
|
+
isLargeDesktopView,
|
|
384
|
+
isSmallScreen,
|
|
385
|
+
windowWidth,
|
|
386
|
+
windowHeight,
|
|
387
|
+
mobilePreviewState,
|
|
388
|
+
detailSidebarOptions,
|
|
389
|
+
isBottomDrawerOpen,
|
|
390
|
+
setBottomDrawer,
|
|
391
|
+
channelName,
|
|
392
|
+
loaderdata
|
|
393
|
+
} = props;
|
|
394
|
+
const ViewChannelDetailLoaderQuery = loaderdata?.[2];
|
|
395
|
+
const MessagesLoaderQuery = loaderdata?.[1];
|
|
396
|
+
const [selectedPost, setSelectedPost] = React__default.useState(null);
|
|
397
|
+
const {
|
|
398
|
+
data: channelData,
|
|
399
|
+
loading: channelLoading
|
|
400
|
+
} = ViewChannelDetailLoaderQuery || {};
|
|
401
|
+
const onMessageClick = useCallback(msg => {
|
|
402
|
+
setSelectedPost(msg);
|
|
403
|
+
}, []);
|
|
404
|
+
const channelsDetail = useMemo(() => {
|
|
405
|
+
return channelData?.viewChannelDetail || null;
|
|
406
|
+
}, [channelData]);
|
|
407
|
+
return React__default.createElement("div", {
|
|
408
|
+
className: "flex overflow-hidden",
|
|
409
|
+
style: {
|
|
410
|
+
height: `${windowHeight}px`,
|
|
411
|
+
maxHeight: '100vh'
|
|
412
|
+
}
|
|
413
|
+
}, React__default.createElement("div", {
|
|
414
|
+
className: "flex-1 flex flex-col min-w-0 overflow-hidden"
|
|
415
|
+
}, channelId && React__default.createElement("div", {
|
|
416
|
+
className: `border-b border-gray-200 bg-white flex-shrink-0 z-10 ${isSmallScreen ? 'px-3 py-3' : 'px-4 sm:px-6 py-4'}`
|
|
417
|
+
}, React__default.createElement("div", {
|
|
418
|
+
className: "flex items-center justify-between"
|
|
419
|
+
}, React__default.createElement("div", {
|
|
420
|
+
className: "flex items-center space-x-2 min-w-0 flex-1"
|
|
421
|
+
}, (isMobileView || isSmallTabletView) && React__default.createElement("button", {
|
|
422
|
+
className: "p-2 hover:bg-gray-100 rounded-full transition-colors flex-shrink-0",
|
|
423
|
+
onClick: () => window.history.back(),
|
|
424
|
+
"aria-label": "Go back"
|
|
425
|
+
}, React__default.createElement("svg", {
|
|
426
|
+
className: "w-5 h-5 text-gray-600",
|
|
427
|
+
fill: "none",
|
|
428
|
+
stroke: "currentColor",
|
|
429
|
+
viewBox: "0 0 24 24"
|
|
430
|
+
}, React__default.createElement("path", {
|
|
431
|
+
strokeLinecap: "round",
|
|
432
|
+
strokeLinejoin: "round",
|
|
433
|
+
strokeWidth: 2,
|
|
434
|
+
d: "M15 19l-7-7 7-7"
|
|
435
|
+
}))), React__default.createElement("h2", {
|
|
436
|
+
className: `font-semibold text-gray-800 truncate ${isSmallScreen ? 'text-base' : 'text-lg'}`
|
|
437
|
+
}, channelName)), (isMobileView || isSmallTabletView) && mobilePreviewState?.mobilePreviewVisibility && React__default.createElement("button", {
|
|
438
|
+
className: "text-sm px-3 py-1 bg-teal-500 hover:bg-teal-600 text-white rounded-md transition-colors flex-shrink-0",
|
|
439
|
+
onClick: () => setBottomDrawer(true)
|
|
440
|
+
}, mobilePreviewState?.mobilePreviewCTAText))), (isMobileView || isSmallTabletView) && channelId && mobilePreviewState?.mobilePreviewVisibility && React__default.createElement("div", {
|
|
441
|
+
className: `mt-4 ${isSmallScreen ? 'mx-3' : 'mx-4'}`
|
|
442
|
+
}, React__default.createElement("div", {
|
|
443
|
+
className: "mb-2"
|
|
444
|
+
}, React__default.createElement("div", {
|
|
445
|
+
className: "w-full flex justify-between items-center gap-2 mb-[5px]"
|
|
446
|
+
}, React__default.createElement("span", {
|
|
447
|
+
className: "truncate flex-1 text-sm"
|
|
448
|
+
}, mobilePreviewState?.mobilePreviewText), React__default.createElement("button", {
|
|
449
|
+
className: "text-sm px-3 py-2 bg-teal-500 hover:bg-teal-600 text-white rounded-md transition-colors flex-shrink-0",
|
|
450
|
+
onClick: () => setBottomDrawer(true)
|
|
451
|
+
}, mobilePreviewState?.mobilePreviewCTAText))), React__default.createElement("hr", {
|
|
452
|
+
className: "border-gray-200"
|
|
453
|
+
})), React__default.createElement("div", {
|
|
454
|
+
className: "flex-1 flex flex-col min-h-0 overflow-hidden"
|
|
455
|
+
}, channelId && React__default.createElement(React__default.Fragment, null, postId ? postId === '1' ? React__default.createElement(ThreadsInbox, {
|
|
456
|
+
channelId: channelId,
|
|
457
|
+
role: channelRole,
|
|
458
|
+
pathPrefix: pathPrefix,
|
|
459
|
+
setChannelId: () => {},
|
|
460
|
+
setPostId: () => {},
|
|
461
|
+
setGoBack: () => {}
|
|
462
|
+
}) : React__default.createElement(ThreadMessagesInbox, {
|
|
463
|
+
channelId: channelId,
|
|
464
|
+
postId: postId,
|
|
465
|
+
role: channelRole,
|
|
466
|
+
goBack: false,
|
|
467
|
+
pathPrefix: pathPrefix,
|
|
468
|
+
setPostId: () => {},
|
|
469
|
+
setChannelId: () => {},
|
|
470
|
+
onMessageClick: onMessageClick
|
|
471
|
+
}) : React__default.createElement(MessagesComponent, {
|
|
472
|
+
channelId: channelId,
|
|
473
|
+
MessagesLoaderQuery: MessagesLoaderQuery,
|
|
474
|
+
channelsDetail: channelsDetail,
|
|
475
|
+
channelLoading: channelLoading,
|
|
476
|
+
onMessageClick: onMessageClick,
|
|
477
|
+
isSmallScreen: isSmallScreen,
|
|
478
|
+
isDesktopView: isDesktopView,
|
|
479
|
+
windowHeight: windowHeight,
|
|
480
|
+
windowWidth: windowWidth
|
|
481
|
+
})))), (isMobileView || isSmallTabletView) && React__default.createElement(Drawer, {
|
|
482
|
+
isOpen: isBottomDrawerOpen,
|
|
483
|
+
onClose: () => setBottomDrawer(false),
|
|
484
|
+
title: mobilePreviewState.mobilePreviewText
|
|
485
|
+
}, React__default.createElement(RightSidebarWrapper, {
|
|
486
|
+
MessagesLoaderQuery: MessagesLoaderQuery,
|
|
487
|
+
selectedPost: selectedPost,
|
|
488
|
+
detailSidebarOptions: detailSidebarOptions
|
|
489
|
+
})));
|
|
490
|
+
});
|
|
491
|
+
const RightSidebarWrapper = React__default.memo(({
|
|
492
|
+
MessagesLoaderQuery,
|
|
493
|
+
selectedPost,
|
|
494
|
+
detailSidebarOptions
|
|
495
|
+
}) => {
|
|
496
|
+
const {
|
|
497
|
+
data
|
|
498
|
+
} = MessagesLoaderQuery || {};
|
|
499
|
+
const sortedMessages = useMemo(() => {
|
|
500
|
+
const messages = data?.messages?.data || [];
|
|
501
|
+
return orderBy(uniqBy(messages, 'id'), ['createdAt'], ['asc']);
|
|
502
|
+
}, [data?.messages?.data]);
|
|
503
|
+
if (!sortedMessages.length) return null;
|
|
504
|
+
return React__default.createElement("div", {
|
|
505
|
+
className: "h-full flex flex-col overflow-hidden"
|
|
506
|
+
}, React__default.createElement(RightSidebar, {
|
|
507
|
+
channelMessages: sortedMessages,
|
|
508
|
+
visibility: "visible",
|
|
509
|
+
selectedPost: selectedPost,
|
|
510
|
+
...detailSidebarOptions
|
|
511
|
+
}));
|
|
512
|
+
});
|
|
513
|
+
const MessagesComponent = React__default.memo(props => {
|
|
514
|
+
const {
|
|
515
|
+
channelId,
|
|
516
|
+
MessagesLoaderQuery,
|
|
517
|
+
channelsDetail,
|
|
518
|
+
channelLoading,
|
|
519
|
+
onMessageClick,
|
|
520
|
+
isSmallScreen,
|
|
521
|
+
isDesktopView,
|
|
522
|
+
windowHeight = 768,
|
|
523
|
+
windowWidth = 1024
|
|
524
|
+
} = props;
|
|
525
|
+
const messageRootListRef = useRef(null);
|
|
526
|
+
const messageListRef = useRef(null);
|
|
527
|
+
useApolloClient();
|
|
528
|
+
const [isLoadingOlder, setIsLoadingOlder] = React__default.useState(false);
|
|
529
|
+
const isLoadingOlderRef = useRef(false);
|
|
530
|
+
const scrollTimeoutRef = useRef(null);
|
|
531
|
+
const auth = useSelector(userSelector);
|
|
532
|
+
const {
|
|
533
|
+
startUpload
|
|
534
|
+
} = useUploadFiles();
|
|
535
|
+
const [sendMsg] = useSendMessagesMutation();
|
|
536
|
+
const {
|
|
537
|
+
data,
|
|
538
|
+
loading: messageLoading,
|
|
539
|
+
fetchMore: fetchMoreMessages,
|
|
540
|
+
subscribeToMore
|
|
541
|
+
} = MessagesLoaderQuery || {};
|
|
542
|
+
// Get messages directly from Apollo cache
|
|
543
|
+
const messages = useMemo(() => {
|
|
544
|
+
const messagesData = data?.messages?.data || [];
|
|
545
|
+
return orderBy(uniqBy(messagesData, 'id'), ['createdAt'], ['asc']);
|
|
546
|
+
}, [data?.messages?.data]);
|
|
547
|
+
const totalCount = data?.messages?.totalCount || 0;
|
|
548
|
+
const scrollToBottom = useCallback(() => {
|
|
549
|
+
if (messageRootListRef?.current) {
|
|
550
|
+
messageRootListRef.current.scrollTop = messageRootListRef.current.scrollHeight;
|
|
551
|
+
}
|
|
552
|
+
}, []);
|
|
553
|
+
// Auto-scroll on new messages (but not when loading older messages)
|
|
554
|
+
useEffect(() => {
|
|
555
|
+
if (!isLoadingOlderRef.current) {
|
|
556
|
+
const timer = setTimeout(() => scrollToBottom(), 100);
|
|
557
|
+
return () => clearTimeout(timer);
|
|
558
|
+
}
|
|
559
|
+
}, [messages.length, scrollToBottom]);
|
|
560
|
+
const onFetchOld = useCallback(async skip => {
|
|
561
|
+
if (channelId && fetchMoreMessages && !isLoadingOlder) {
|
|
562
|
+
try {
|
|
563
|
+
setIsLoadingOlder(true);
|
|
564
|
+
isLoadingOlderRef.current = true;
|
|
565
|
+
// Capture current scroll height before fetching
|
|
566
|
+
const oldScrollHeight = messageRootListRef?.current?.scrollHeight || 0;
|
|
567
|
+
await fetchMoreMessages({
|
|
568
|
+
variables: {
|
|
569
|
+
channelId: channelId.toString(),
|
|
570
|
+
parentId: null,
|
|
571
|
+
skip
|
|
572
|
+
},
|
|
573
|
+
updateQuery: (prev, {
|
|
574
|
+
fetchMoreResult
|
|
575
|
+
}) => {
|
|
576
|
+
if (!fetchMoreResult) return prev;
|
|
577
|
+
const newMessages = fetchMoreResult.messages.data;
|
|
578
|
+
const existingMessages = prev.messages?.data || [];
|
|
579
|
+
return {
|
|
580
|
+
...prev,
|
|
581
|
+
messages: {
|
|
582
|
+
...fetchMoreResult.messages,
|
|
583
|
+
data: uniqBy([...newMessages, ...existingMessages], 'id')
|
|
584
|
+
}
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
});
|
|
588
|
+
// Maintain scroll position after loading older messages
|
|
589
|
+
setTimeout(() => {
|
|
590
|
+
if (messageRootListRef?.current) {
|
|
591
|
+
const newScrollHeight = messageRootListRef.current.scrollHeight;
|
|
592
|
+
const scrollDiff = newScrollHeight - oldScrollHeight;
|
|
593
|
+
// For normal flex layout, maintain position by adjusting scroll offset
|
|
594
|
+
messageRootListRef.current.scrollTop = scrollDiff;
|
|
595
|
+
}
|
|
596
|
+
// Reset the loading flag after position is maintained
|
|
597
|
+
setTimeout(() => {
|
|
598
|
+
isLoadingOlderRef.current = false;
|
|
599
|
+
}, 50);
|
|
600
|
+
}, 100);
|
|
601
|
+
} catch (error) {
|
|
602
|
+
console.error('Error fetching older messages:', error);
|
|
603
|
+
isLoadingOlderRef.current = false;
|
|
604
|
+
} finally {
|
|
605
|
+
setIsLoadingOlder(false);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
}, [channelId, fetchMoreMessages, isLoadingOlder]);
|
|
609
|
+
// Scroll to bottom when channel changes
|
|
610
|
+
useEffect(() => {
|
|
611
|
+
if (channelId && messages.length > 0) {
|
|
612
|
+
isLoadingOlderRef.current = false; // Reset flag on channel change
|
|
613
|
+
const timer = setTimeout(() => scrollToBottom(), 200);
|
|
614
|
+
return () => clearTimeout(timer);
|
|
615
|
+
}
|
|
616
|
+
}, [channelId, scrollToBottom]);
|
|
617
|
+
// Alternative scroll detection for Firefox
|
|
618
|
+
useEffect(() => {
|
|
619
|
+
const element = messageRootListRef.current;
|
|
620
|
+
if (!element) return;
|
|
621
|
+
// Firefox-specific scroll detection using passive listeners
|
|
622
|
+
const handleScrollEnd = () => {
|
|
623
|
+
if (!isLoadingOlder && element) {
|
|
624
|
+
const {
|
|
625
|
+
scrollTop
|
|
626
|
+
} = element;
|
|
627
|
+
const isAtTop = Math.round(scrollTop) <= 30;
|
|
628
|
+
const hasMoreMessages = totalCount > messages.length;
|
|
629
|
+
if (isAtTop && hasMoreMessages) {
|
|
630
|
+
console.log('ScrollEnd triggered load more (Firefox):', {
|
|
631
|
+
scrollTop: Math.round(scrollTop),
|
|
632
|
+
totalCount,
|
|
633
|
+
messagesLength: messages.length
|
|
634
|
+
});
|
|
635
|
+
onFetchOld(messages.length);
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
};
|
|
639
|
+
// Use scrollend event if available (modern Firefox/Chrome)
|
|
640
|
+
if ('onscrollend' in element) {
|
|
641
|
+
element.addEventListener('scrollend', handleScrollEnd, {
|
|
642
|
+
passive: true
|
|
643
|
+
});
|
|
644
|
+
return () => {
|
|
645
|
+
element.removeEventListener('scrollend', handleScrollEnd);
|
|
646
|
+
};
|
|
647
|
+
}
|
|
648
|
+
}, [totalCount, messages.length, onFetchOld, isLoadingOlder]);
|
|
649
|
+
// Cleanup scroll timeout on unmount
|
|
650
|
+
useEffect(() => {
|
|
651
|
+
return () => {
|
|
652
|
+
if (scrollTimeoutRef.current) {
|
|
653
|
+
clearTimeout(scrollTimeoutRef.current);
|
|
654
|
+
}
|
|
655
|
+
};
|
|
656
|
+
}, []);
|
|
657
|
+
const onMessagesScroll = useCallback(async e => {
|
|
658
|
+
// Throttle scroll events for better performance, especially in Firefox
|
|
659
|
+
if (scrollTimeoutRef.current) {
|
|
660
|
+
clearTimeout(scrollTimeoutRef.current);
|
|
661
|
+
}
|
|
662
|
+
scrollTimeoutRef.current = setTimeout(async () => {
|
|
663
|
+
if (messageRootListRef.current && !isLoadingOlder) {
|
|
664
|
+
const element = messageRootListRef.current;
|
|
665
|
+
const {
|
|
666
|
+
clientHeight,
|
|
667
|
+
scrollHeight,
|
|
668
|
+
scrollTop
|
|
669
|
+
} = element;
|
|
670
|
+
// Firefox-compatible scroll detection
|
|
671
|
+
// Use Math.ceil to handle Firefox's fractional scrollTop values
|
|
672
|
+
const isAtTop = Math.ceil(scrollTop) <= 25;
|
|
673
|
+
const hasMoreMessages = totalCount > messages.length;
|
|
674
|
+
// Additional Firefox-specific check
|
|
675
|
+
const isFirefox = navigator.userAgent.includes('Firefox');
|
|
676
|
+
const firefoxAdjustedTop = isFirefox ? Math.round(scrollTop) <= 30 : isAtTop;
|
|
677
|
+
if ((isAtTop || firefoxAdjustedTop) && hasMoreMessages) {
|
|
678
|
+
console.log('Triggering load more:', {
|
|
679
|
+
scrollTop: Math.ceil(scrollTop),
|
|
680
|
+
originalScrollTop: scrollTop,
|
|
681
|
+
totalCount,
|
|
682
|
+
messagesLength: messages.length,
|
|
683
|
+
scrollHeight,
|
|
684
|
+
clientHeight,
|
|
685
|
+
browser: isFirefox ? 'Firefox' : 'Other',
|
|
686
|
+
isAtTop,
|
|
687
|
+
firefoxAdjustedTop
|
|
688
|
+
});
|
|
689
|
+
await onFetchOld(messages.length);
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
}, 100);
|
|
693
|
+
}, [totalCount, messages.length, onFetchOld, isLoadingOlder]);
|
|
694
|
+
// Optimistic message sending with Apollo cache updates
|
|
695
|
+
const handleSend = useCallback(async (message, files = []) => {
|
|
696
|
+
// Allow sending if there's either a message or files
|
|
697
|
+
if ((!message || !message.trim()) && (!files || files.length === 0)) return;
|
|
698
|
+
if (!channelId) return;
|
|
699
|
+
try {
|
|
700
|
+
const postId = objectId();
|
|
701
|
+
const currentDate = new Date();
|
|
702
|
+
const createOptimisticMessage = files => ({
|
|
703
|
+
__typename: 'Post',
|
|
704
|
+
id: postId,
|
|
705
|
+
message,
|
|
706
|
+
createdAt: currentDate.toISOString(),
|
|
707
|
+
updatedAt: currentDate.toISOString(),
|
|
708
|
+
author: {
|
|
709
|
+
__typename: 'UserAccount',
|
|
710
|
+
id: auth?.id,
|
|
711
|
+
givenName: auth?.profile?.given_name || '',
|
|
712
|
+
familyName: auth?.profile?.family_name || '',
|
|
713
|
+
email: auth?.profile?.email || '',
|
|
714
|
+
username: auth?.profile?.nickname || '',
|
|
715
|
+
fullName: auth?.profile?.name || '',
|
|
716
|
+
picture: auth?.profile?.picture || '',
|
|
717
|
+
alias: [auth?.authUserId ?? ''],
|
|
718
|
+
tokens: []
|
|
719
|
+
},
|
|
720
|
+
isDelivered: false,
|
|
721
|
+
// Will be true once confirmed by server
|
|
722
|
+
isRead: false,
|
|
723
|
+
type: 'TEXT',
|
|
724
|
+
parentId: null,
|
|
725
|
+
fromServer: false,
|
|
726
|
+
channel: {
|
|
727
|
+
__typename: 'Channel',
|
|
728
|
+
id: channelId
|
|
729
|
+
},
|
|
730
|
+
propsConfiguration: {
|
|
731
|
+
__typename: 'MachineConfiguration',
|
|
732
|
+
id: null,
|
|
733
|
+
resource: '',
|
|
734
|
+
contents: null,
|
|
735
|
+
keys: null,
|
|
736
|
+
target: null,
|
|
737
|
+
overrides: null
|
|
738
|
+
},
|
|
739
|
+
props: {},
|
|
740
|
+
files: {
|
|
741
|
+
__typename: 'FilesInfo',
|
|
742
|
+
data: files || [],
|
|
743
|
+
totalCount: files?.length || 0
|
|
744
|
+
},
|
|
745
|
+
replies: {
|
|
746
|
+
__typename: 'Messages',
|
|
747
|
+
data: [],
|
|
748
|
+
totalCount: 0
|
|
749
|
+
}
|
|
750
|
+
});
|
|
751
|
+
const optimisticMessage = createOptimisticMessage(files);
|
|
752
|
+
if (files?.length > 0) {
|
|
753
|
+
const uploadResponse = await startUpload({
|
|
754
|
+
file: files,
|
|
755
|
+
saveUploadedFile: {
|
|
756
|
+
variables: {
|
|
757
|
+
postId
|
|
758
|
+
}
|
|
759
|
+
},
|
|
760
|
+
createUploadLink: {
|
|
761
|
+
variables: {
|
|
762
|
+
postId
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
});
|
|
766
|
+
const uploadedFiles = uploadResponse.data;
|
|
767
|
+
if (uploadedFiles) {
|
|
768
|
+
const fileIds = uploadedFiles.map(f => f.id);
|
|
769
|
+
await sendMsg({
|
|
770
|
+
variables: {
|
|
771
|
+
postId,
|
|
772
|
+
channelId,
|
|
773
|
+
content: message,
|
|
774
|
+
files: fileIds
|
|
775
|
+
},
|
|
776
|
+
optimisticResponse: {
|
|
777
|
+
__typename: 'Mutation',
|
|
778
|
+
sendMessage: createOptimisticMessage(uploadedFiles)
|
|
779
|
+
},
|
|
780
|
+
update: (cache, {
|
|
781
|
+
data: mutationData
|
|
782
|
+
}) => {
|
|
783
|
+
if (!mutationData?.sendMessage) return;
|
|
784
|
+
// Update messages cache optimistically
|
|
785
|
+
const messagesQuery = {
|
|
786
|
+
query: MessagesDocument,
|
|
787
|
+
variables: {
|
|
788
|
+
channelId: channelId.toString(),
|
|
789
|
+
parentId: null,
|
|
790
|
+
limit: MESSAGES_PER_PAGE
|
|
791
|
+
}
|
|
792
|
+
};
|
|
793
|
+
try {
|
|
794
|
+
const existingData = cache.readQuery(messagesQuery);
|
|
795
|
+
if (existingData?.messages) {
|
|
796
|
+
cache.writeQuery({
|
|
797
|
+
...messagesQuery,
|
|
798
|
+
data: {
|
|
799
|
+
messages: {
|
|
800
|
+
...existingData.messages,
|
|
801
|
+
data: [...(existingData.messages.data || []), mutationData.sendMessage],
|
|
802
|
+
totalCount: (existingData.messages.totalCount || 0) + 1
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
});
|
|
806
|
+
}
|
|
807
|
+
} catch (error) {
|
|
808
|
+
console.debug('Cache update failed (expected on first message):', error);
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
});
|
|
812
|
+
}
|
|
813
|
+
} else {
|
|
814
|
+
await sendMsg({
|
|
815
|
+
variables: {
|
|
816
|
+
channelId,
|
|
817
|
+
content: message
|
|
818
|
+
},
|
|
819
|
+
optimisticResponse: {
|
|
820
|
+
__typename: 'Mutation',
|
|
821
|
+
sendMessage: optimisticMessage
|
|
822
|
+
},
|
|
823
|
+
update: (cache, {
|
|
824
|
+
data: mutationData
|
|
825
|
+
}) => {
|
|
826
|
+
if (!mutationData?.sendMessage) return;
|
|
827
|
+
// Update messages cache optimistically
|
|
828
|
+
const messagesQuery = {
|
|
829
|
+
query: MessagesDocument,
|
|
830
|
+
variables: {
|
|
831
|
+
channelId: channelId.toString(),
|
|
832
|
+
parentId: null,
|
|
833
|
+
limit: MESSAGES_PER_PAGE
|
|
834
|
+
}
|
|
835
|
+
};
|
|
836
|
+
try {
|
|
837
|
+
const existingData = cache.readQuery(messagesQuery);
|
|
838
|
+
if (existingData?.messages) {
|
|
839
|
+
cache.writeQuery({
|
|
840
|
+
...messagesQuery,
|
|
841
|
+
data: {
|
|
842
|
+
messages: {
|
|
843
|
+
...existingData.messages,
|
|
844
|
+
data: [...(existingData.messages.data || []), mutationData.sendMessage],
|
|
845
|
+
totalCount: (existingData.messages.totalCount || 0) + 1
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
});
|
|
849
|
+
}
|
|
850
|
+
} catch (error) {
|
|
851
|
+
console.debug('Cache update failed (expected on first message):', error);
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
});
|
|
855
|
+
}
|
|
856
|
+
} catch (error) {
|
|
857
|
+
console.error('Error sending message:', error);
|
|
858
|
+
}
|
|
859
|
+
}, [channelId, auth, startUpload, sendMsg]);
|
|
860
|
+
// Show loading spinner for initial load
|
|
861
|
+
if ((messageLoading || channelLoading) && messages.length === 0) {
|
|
862
|
+
return React__default.createElement("div", {
|
|
863
|
+
className: "flex-1 flex justify-center items-center"
|
|
864
|
+
}, React__default.createElement(Spinner, {
|
|
865
|
+
className: "w-12 h-12"
|
|
866
|
+
}));
|
|
867
|
+
}
|
|
868
|
+
return React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
|
|
869
|
+
ref: messageRootListRef,
|
|
870
|
+
className: `overflow-y-scroll bg-gray-50 ${isSmallScreen ? 'p-2 px-3' : isDesktopView ? 'p-6 px-8' : 'p-4 px-6'}`,
|
|
871
|
+
onScroll: onMessagesScroll,
|
|
872
|
+
style: {
|
|
873
|
+
height: `${windowHeight - 140}px`,
|
|
874
|
+
// Subtract header + input height
|
|
875
|
+
maxHeight: '100vh',
|
|
876
|
+
scrollbarWidth: 'thin',
|
|
877
|
+
scrollbarColor: '#cbd5e0 #f7fafc',
|
|
878
|
+
overflowY: 'scroll',
|
|
879
|
+
WebkitOverflowScrolling: 'touch'
|
|
880
|
+
}
|
|
881
|
+
}, React__default.createElement("div", {
|
|
882
|
+
className: "min-h-full"
|
|
883
|
+
}, messages.length > 0 ? React__default.createElement(React__default.Fragment, null, isLoadingOlder && React__default.createElement("div", {
|
|
884
|
+
className: "flex justify-center py-4"
|
|
885
|
+
}, React__default.createElement("div", {
|
|
886
|
+
className: "flex items-center space-x-2 text-gray-500"
|
|
887
|
+
}, React__default.createElement(Spinner, {
|
|
888
|
+
className: "w-4 h-4"
|
|
889
|
+
}), React__default.createElement("span", {
|
|
890
|
+
className: "text-sm"
|
|
891
|
+
}, "Loading older messages..."))), React__default.createElement(Messages, {
|
|
892
|
+
innerRef: messageListRef,
|
|
893
|
+
channelId: channelId,
|
|
894
|
+
currentUser: auth,
|
|
895
|
+
channelMessages: messages,
|
|
896
|
+
totalCount: totalCount,
|
|
897
|
+
onMessageClick: onMessageClick,
|
|
898
|
+
isDesktopView: isDesktopView || false,
|
|
899
|
+
isSmallScreen: isSmallScreen || false
|
|
900
|
+
}), React__default.createElement(SubscriptionHandler, {
|
|
901
|
+
subscribeToMore: subscribeToMore,
|
|
902
|
+
document: OnChatMessageAddedDocument,
|
|
903
|
+
variables: {
|
|
904
|
+
channelId: channelId.toString()
|
|
905
|
+
},
|
|
906
|
+
enabled: !!channelId && !!subscribeToMore,
|
|
907
|
+
updateQuery: (prev, {
|
|
908
|
+
subscriptionData
|
|
909
|
+
}) => {
|
|
910
|
+
console.log('Subscription updateQuery called:', {
|
|
911
|
+
prev,
|
|
912
|
+
subscriptionData
|
|
913
|
+
});
|
|
914
|
+
if (!subscriptionData.data) {
|
|
915
|
+
console.log('No subscription data, returning prev');
|
|
916
|
+
return prev;
|
|
917
|
+
}
|
|
918
|
+
const newMessage = subscriptionData.data.chatMessageAdded;
|
|
919
|
+
console.log('New message received via subscription:', newMessage);
|
|
920
|
+
return {
|
|
921
|
+
...prev,
|
|
922
|
+
messages: {
|
|
923
|
+
...prev?.messages,
|
|
924
|
+
data: uniqBy([...(prev?.messages?.data || []), newMessage], 'id'),
|
|
925
|
+
totalCount: (prev?.messages?.totalCount || 0) + 1
|
|
926
|
+
}
|
|
927
|
+
};
|
|
928
|
+
},
|
|
929
|
+
onError: error => {
|
|
930
|
+
console.error('Subscription error:', error);
|
|
931
|
+
}
|
|
932
|
+
})) : React__default.createElement("div", {
|
|
933
|
+
className: "flex items-center justify-center text-gray-500 min-h-96"
|
|
934
|
+
}, React__default.createElement("div", {
|
|
935
|
+
className: "text-center max-w-sm mx-auto px-4"
|
|
936
|
+
}, React__default.createElement("div", {
|
|
937
|
+
className: "text-6xl mb-4 opacity-50"
|
|
938
|
+
}, "\uD83D\uDCAC"), React__default.createElement("h3", {
|
|
939
|
+
className: "text-lg font-semibold text-gray-600 mb-2"
|
|
940
|
+
}, "No messages yet"), React__default.createElement("p", {
|
|
941
|
+
className: "text-sm text-gray-500"
|
|
942
|
+
}, "Start the conversation by sending a message below!"))))), React__default.createElement("div", {
|
|
943
|
+
className: "flex-shrink-0 border-t border-gray-200 bg-white"
|
|
944
|
+
}, React__default.createElement(MessageInput, {
|
|
945
|
+
channelId: channelId,
|
|
946
|
+
handleSend: handleSend,
|
|
947
|
+
placeholder: "Message"
|
|
948
|
+
})));
|
|
949
|
+
});
|
|
950
|
+
// Display names for debugging
|
|
951
|
+
Inbox.displayName = 'Inbox';
|
|
952
|
+
ContentComponent.displayName = 'ContentComponent';
|
|
953
|
+
MessagesComponent.displayName = 'MessagesComponent';
|
|
954
|
+
RightSidebarWrapper.displayName = 'RightSidebarWrapper';
|
|
955
|
+
var Inbox$1 = React__default.memo(Inbox);export{Inbox$1 as default};//# sourceMappingURL=Inbox.js.map
|