@peers-app/peers-ui 0.14.0 → 0.15.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.
- package/.github/workflows/publish.yml +8 -5
- package/babel.config.js +4 -4
- package/biome.json +191 -0
- package/dist/command-palette/command-palette-ui.d.ts +1 -2
- package/dist/command-palette/command-palette-ui.js +175 -244
- package/dist/command-palette/command-palette.js +65 -64
- package/dist/components/chat-overlay.d.ts +2 -2
- package/dist/components/chat-overlay.js +160 -217
- package/dist/components/checkbox.d.ts +5 -4
- package/dist/components/checkbox.js +4 -7
- package/dist/components/group-switcher.d.ts +1 -2
- package/dist/components/group-switcher.js +119 -159
- package/dist/components/input-date.d.ts +3 -3
- package/dist/components/input-date.js +6 -6
- package/dist/components/input-number.d.ts +7 -6
- package/dist/components/input-number.js +25 -20
- package/dist/components/input.d.ts +5 -4
- package/dist/components/input.js +4 -7
- package/dist/components/inverse-lazy-list.d.ts +3 -3
- package/dist/components/inverse-lazy-list.js +13 -47
- package/dist/components/io-schema-values.d.ts +5 -6
- package/dist/components/io-schema-values.js +28 -65
- package/dist/components/io-schema.d.ts +4 -5
- package/dist/components/io-schema.js +42 -79
- package/dist/components/lazy-list.d.ts +3 -3
- package/dist/components/lazy-list.js +38 -58
- package/dist/components/list-screen.d.ts +3 -8
- package/dist/components/list-screen.js +28 -23
- package/dist/components/loading-indicator.d.ts +1 -2
- package/dist/components/loading-indicator.js +2 -6
- package/dist/components/markdown-editor/autolink-plugin.js +5 -8
- package/dist/components/markdown-editor/editor-inline.d.ts +2 -3
- package/dist/components/markdown-editor/editor-inline.js +2 -6
- package/dist/components/markdown-editor/editor.d.ts +6 -6
- package/dist/components/markdown-editor/editor.js +9 -19
- package/dist/components/markdown-editor/markdown-plugin.d.ts +1 -1
- package/dist/components/markdown-editor/markdown-plugin.js +20 -21
- package/dist/components/markdown-editor/mention-node.d.ts +2 -2
- package/dist/components/markdown-editor/mention-node.js +24 -24
- package/dist/components/markdown-editor/mentions-plugin.d.ts +2 -2
- package/dist/components/markdown-editor/mentions-plugin.js +61 -62
- package/dist/components/markdown-editor/theme.js +28 -28
- package/dist/components/markdown-editor/toolbar.d.ts +2 -3
- package/dist/components/markdown-editor/toolbar.js +32 -49
- package/dist/components/markdown-with-mentions.d.ts +1 -1
- package/dist/components/markdown-with-mentions.js +43 -43
- package/dist/components/message-logs/message-logs.d.ts +1 -2
- package/dist/components/message-logs/message-logs.js +91 -116
- package/dist/components/messages/avatar.d.ts +3 -4
- package/dist/components/messages/avatar.js +37 -46
- package/dist/components/messages/channel-message-list.d.ts +5 -6
- package/dist/components/messages/channel-message-list.js +34 -34
- package/dist/components/messages/channel-view.d.ts +1 -2
- package/dist/components/messages/channel-view.js +23 -57
- package/dist/components/messages/message-compose.d.ts +3 -4
- package/dist/components/messages/message-compose.js +27 -38
- package/dist/components/messages/message-display.d.ts +2 -3
- package/dist/components/messages/message-display.js +42 -95
- package/dist/components/messages/thread-message-list.d.ts +4 -5
- package/dist/components/messages/thread-message-list.js +29 -29
- package/dist/components/router.d.ts +1 -2
- package/dist/components/router.js +58 -66
- package/dist/components/save-button.d.ts +3 -3
- package/dist/components/save-button.js +23 -33
- package/dist/components/sortable-list.d.ts +11 -12
- package/dist/components/sortable-list.js +42 -22
- package/dist/components/tabs.d.ts +3 -3
- package/dist/components/tabs.js +16 -47
- package/dist/components/tooltip.d.ts +4 -4
- package/dist/components/tooltip.js +4 -9
- package/dist/components/trust-level-badge.d.ts +2 -3
- package/dist/components/trust-level-badge.js +16 -16
- package/dist/components/trust-level-dropdown.d.ts +3 -4
- package/dist/components/trust-level-dropdown.js +32 -55
- package/dist/components/typeahead.d.ts +3 -3
- package/dist/components/typeahead.js +48 -89
- package/dist/components/voice-indicator.d.ts +2 -2
- package/dist/components/voice-indicator.js +93 -106
- package/dist/components/voice-subscribe-events.d.ts +32 -0
- package/dist/components/voice-subscribe-events.js +2 -0
- package/dist/globals.d.ts +3 -5
- package/dist/globals.js +22 -33
- package/dist/hooks.d.ts +5 -5
- package/dist/hooks.js +22 -12
- package/dist/hooks.test.js +129 -145
- package/dist/index.d.ts +9 -8
- package/dist/index.js +13 -12
- package/dist/mention-configs.d.ts +2 -2
- package/dist/mention-configs.js +55 -42
- package/dist/screens/assistants/assistant-config.d.ts +2 -3
- package/dist/screens/assistants/assistant-config.js +9 -22
- package/dist/screens/assistants/assistant-details.d.ts +1 -2
- package/dist/screens/assistants/assistant-details.js +13 -28
- package/dist/screens/assistants/assistant-info.d.ts +2 -3
- package/dist/screens/assistants/assistant-info.js +3 -17
- package/dist/screens/assistants/assistant-list.d.ts +1 -2
- package/dist/screens/assistants/assistant-list.js +15 -56
- package/dist/screens/assistants/assistant-tools.d.ts +2 -3
- package/dist/screens/assistants/assistant-tools.js +10 -24
- package/dist/screens/console-logs/console-logs-list.d.ts +1 -2
- package/dist/screens/console-logs/console-logs-list.js +130 -134
- package/dist/screens/console-logs/log-display.d.ts +2 -3
- package/dist/screens/console-logs/log-display.js +40 -42
- package/dist/screens/console-logs/log-filters.d.ts +1 -2
- package/dist/screens/console-logs/log-filters.js +2 -24
- package/dist/screens/console-logs/mobile-log-card.d.ts +2 -3
- package/dist/screens/console-logs/mobile-log-card.js +64 -67
- package/dist/screens/console-logs/resizable-table-header.d.ts +1 -2
- package/dist/screens/console-logs/resizable-table-header.js +31 -67
- package/dist/screens/contacts/contact-details.d.ts +1 -2
- package/dist/screens/contacts/contact-details.js +16 -46
- package/dist/screens/contacts/contact-list.d.ts +1 -2
- package/dist/screens/contacts/contact-list.js +44 -103
- package/dist/screens/contacts/index.d.ts +4 -4
- package/dist/screens/contacts/index.js +1 -1
- package/dist/screens/contacts/user-connect.d.ts +1 -2
- package/dist/screens/contacts/user-connect.js +85 -186
- package/dist/screens/data-explorer/data-explorer.d.ts +1 -2
- package/dist/screens/data-explorer/data-explorer.js +61 -181
- package/dist/screens/data-explorer/index.d.ts +2 -2
- package/dist/screens/data-explorer/query-executor.d.ts +1 -2
- package/dist/screens/data-explorer/query-executor.js +56 -166
- package/dist/screens/groups/group-details.d.ts +1 -2
- package/dist/screens/groups/group-details.js +27 -122
- package/dist/screens/groups/group-invite-listener.d.ts +2 -3
- package/dist/screens/groups/group-invite-listener.js +8 -104
- package/dist/screens/groups/group-list.d.ts +1 -2
- package/dist/screens/groups/group-list.js +56 -133
- package/dist/screens/groups/group-members.d.ts +2 -3
- package/dist/screens/groups/group-members.js +62 -132
- package/dist/screens/groups/index.d.ts +4 -4
- package/dist/screens/groups/index.js +1 -1
- package/dist/screens/join-group/index.d.ts +2 -2
- package/dist/screens/join-group/join-group.d.ts +1 -2
- package/dist/screens/join-group/join-group.js +9 -109
- package/dist/screens/network-viewer/connection-troubleshooter.d.ts +2 -3
- package/dist/screens/network-viewer/connection-troubleshooter.js +89 -193
- package/dist/screens/network-viewer/cpu-usage-graph.d.ts +1 -2
- package/dist/screens/network-viewer/cpu-usage-graph.js +60 -99
- package/dist/screens/network-viewer/device-details-modal.d.ts +1 -2
- package/dist/screens/network-viewer/device-details-modal.js +25 -177
- package/dist/screens/network-viewer/group-details-modal.d.ts +1 -2
- package/dist/screens/network-viewer/group-details-modal.js +31 -142
- package/dist/screens/network-viewer/index.d.ts +4 -4
- package/dist/screens/network-viewer/index.js +3 -3
- package/dist/screens/network-viewer/network-viewer-ipc.d.ts +22 -0
- package/dist/screens/network-viewer/network-viewer-ipc.js +6 -0
- package/dist/screens/network-viewer/network-viewer.d.ts +1 -2
- package/dist/screens/network-viewer/network-viewer.js +91 -296
- package/dist/screens/network-viewer/usage-graph.d.ts +1 -2
- package/dist/screens/network-viewer/usage-graph.js +78 -110
- package/dist/screens/packages/package-details.d.ts +1 -2
- package/dist/screens/packages/package-details.js +35 -41
- package/dist/screens/packages/package-info.d.ts +2 -2
- package/dist/screens/packages/package-info.js +33 -86
- package/dist/screens/packages/package-list.d.ts +1 -2
- package/dist/screens/packages/package-list.js +42 -106
- package/dist/screens/packages/package-new-local.d.ts +1 -2
- package/dist/screens/packages/package-new-local.js +13 -19
- package/dist/screens/packages/package-versions.d.ts +2 -3
- package/dist/screens/packages/package-versions.js +29 -96
- package/dist/screens/peer-types/peer-type-details.d.ts +3 -4
- package/dist/screens/peer-types/peer-type-details.js +26 -78
- package/dist/screens/peer-types/peer-type-list.d.ts +1 -2
- package/dist/screens/peer-types/peer-type-list.js +13 -24
- package/dist/screens/search/global-search.d.ts +1 -2
- package/dist/screens/search/global-search.js +104 -182
- package/dist/screens/settings/color-mode-dropdown.d.ts +3 -4
- package/dist/screens/settings/color-mode-dropdown.js +18 -37
- package/dist/screens/settings/settings-page.d.ts +1 -1
- package/dist/screens/settings/settings-page.js +86 -213
- package/dist/screens/settings/voice-settings-agent.d.ts +1 -1
- package/dist/screens/settings/voice-settings-agent.js +7 -44
- package/dist/screens/settings/voice-settings-api-keys.d.ts +2 -2
- package/dist/screens/settings/voice-settings-api-keys.js +2 -29
- package/dist/screens/settings/voice-settings-output.d.ts +2 -2
- package/dist/screens/settings/voice-settings-output.js +2 -40
- package/dist/screens/settings/voice-settings-providers.d.ts +2 -2
- package/dist/screens/settings/voice-settings-providers.js +2 -19
- package/dist/screens/settings/voice-settings-types.d.ts +4 -4
- package/dist/screens/settings/voice-settings-types.js +31 -31
- package/dist/screens/settings/voice-settings-wake-word.d.ts +2 -2
- package/dist/screens/settings/voice-settings-wake-word.js +2 -33
- package/dist/screens/settings/voice-settings.d.ts +1 -1
- package/dist/screens/settings/voice-settings.js +35 -112
- package/dist/screens/setup-user.d.ts +1 -2
- package/dist/screens/setup-user.js +38 -116
- package/dist/screens/tools/tool-code.d.ts +2 -3
- package/dist/screens/tools/tool-code.js +9 -13
- package/dist/screens/tools/tool-details.d.ts +1 -2
- package/dist/screens/tools/tool-details.js +26 -39
- package/dist/screens/tools/tool-info.d.ts +2 -3
- package/dist/screens/tools/tool-info.js +9 -48
- package/dist/screens/tools/tool-list.d.ts +1 -2
- package/dist/screens/tools/tool-list.js +33 -65
- package/dist/screens/tools/tool-schema.d.ts +2 -3
- package/dist/screens/tools/tool-schema.js +2 -13
- package/dist/screens/tools/tool-test-details.d.ts +1 -2
- package/dist/screens/tools/tool-test-details.js +12 -28
- package/dist/screens/tools/tool-test-list.d.ts +1 -2
- package/dist/screens/tools/tool-test-list.js +17 -56
- package/dist/screens/variables/variable-details.d.ts +1 -2
- package/dist/screens/variables/variable-details.js +19 -86
- package/dist/screens/variables/variable-list.d.ts +1 -2
- package/dist/screens/variables/variable-list.js +16 -27
- package/dist/screens/welcome-modal.d.ts +1 -2
- package/dist/screens/welcome-modal.js +44 -111
- package/dist/screens/workflows/workflow-details.d.ts +1 -2
- package/dist/screens/workflows/workflow-details.js +17 -31
- package/dist/screens/workflows/workflow-info.d.ts +2 -3
- package/dist/screens/workflows/workflow-info.js +2 -9
- package/dist/screens/workflows/workflow-instructions.d.ts +2 -3
- package/dist/screens/workflows/workflow-instructions.js +23 -55
- package/dist/screens/workflows/workflow-list.d.ts +1 -2
- package/dist/screens/workflows/workflow-list.js +23 -62
- package/dist/setupTests.d.ts +1 -1
- package/dist/setupTests.js +10 -11
- package/dist/system-apps/assistants.app.d.ts +1 -1
- package/dist/system-apps/assistants.app.js +3 -3
- package/dist/system-apps/console-logs.app.d.ts +1 -1
- package/dist/system-apps/console-logs.app.js +3 -3
- package/dist/system-apps/contacts.app.d.ts +1 -1
- package/dist/system-apps/contacts.app.js +4 -4
- package/dist/system-apps/data-explorer.app.d.ts +1 -1
- package/dist/system-apps/data-explorer.app.js +4 -4
- package/dist/system-apps/groups.app.d.ts +1 -1
- package/dist/system-apps/groups.app.js +4 -4
- package/dist/system-apps/index.d.ts +17 -17
- package/dist/system-apps/index.js +52 -52
- package/dist/system-apps/join-group.app.d.ts +1 -1
- package/dist/system-apps/join-group.app.js +4 -4
- package/dist/system-apps/mobile-settings.app.d.ts +1 -1
- package/dist/system-apps/mobile-settings.app.js +3 -3
- package/dist/system-apps/network-viewer.app.d.ts +1 -1
- package/dist/system-apps/network-viewer.app.js +4 -4
- package/dist/system-apps/packages.app.d.ts +1 -1
- package/dist/system-apps/packages.app.js +3 -3
- package/dist/system-apps/search.app.d.ts +1 -1
- package/dist/system-apps/search.app.js +4 -4
- package/dist/system-apps/settings.app.d.ts +1 -1
- package/dist/system-apps/settings.app.js +3 -3
- package/dist/system-apps/threads.app.d.ts +1 -1
- package/dist/system-apps/threads.app.js +3 -3
- package/dist/system-apps/tools.app.d.ts +1 -1
- package/dist/system-apps/tools.app.js +3 -3
- package/dist/system-apps/types.app.d.ts +1 -1
- package/dist/system-apps/types.app.js +3 -3
- package/dist/system-apps/variables.app.d.ts +1 -1
- package/dist/system-apps/variables.app.js +3 -3
- package/dist/system-apps/workflows.app.d.ts +1 -1
- package/dist/system-apps/workflows.app.js +3 -3
- package/dist/tabs-layout/tabs-layout.d.ts +2 -3
- package/dist/tabs-layout/tabs-layout.js +215 -246
- package/dist/tabs-layout/tabs-state.d.ts +2 -2
- package/dist/tabs-layout/tabs-state.js +73 -61
- package/dist/ui-defaults/index.d.ts +2 -2
- package/dist/ui-defaults/list-screen.d.ts +2 -3
- package/dist/ui-defaults/list-screen.js +33 -37
- package/dist/ui-defaults/markdown-field.js +24 -56
- package/dist/ui-router/routes-loader.d.ts +1 -1
- package/dist/ui-router/routes-loader.js +17 -13
- package/dist/ui-router/ui-loader.d.ts +6 -6
- package/dist/ui-router/ui-loader.js +172 -268
- package/dist/utils.js +49 -39
- package/jest.config.js +16 -16
- package/package.json +16 -14
- package/src/command-palette/command-palette-ui.tsx +261 -237
- package/src/command-palette/command-palette.ts +81 -78
- package/src/components/chat-overlay.tsx +366 -261
- package/src/components/checkbox.tsx +15 -12
- package/src/components/group-switcher.tsx +150 -105
- package/src/components/input-date.tsx +17 -16
- package/src/components/input-number.tsx +47 -31
- package/src/components/input.tsx +15 -12
- package/src/components/inverse-lazy-list.tsx +14 -13
- package/src/components/io-schema-values.tsx +51 -69
- package/src/components/io-schema.tsx +94 -69
- package/src/components/lazy-list.tsx +51 -34
- package/src/components/list-screen.tsx +51 -35
- package/src/components/loading-indicator.tsx +2 -4
- package/src/components/markdown-editor/autolink-plugin.tsx +4 -11
- package/src/components/markdown-editor/editor-inline.tsx +3 -4
- package/src/components/markdown-editor/editor.tsx +53 -51
- package/src/components/markdown-editor/markdown-plugin.tsx +48 -40
- package/src/components/markdown-editor/mention-node.ts +39 -38
- package/src/components/markdown-editor/mentions-plugin.tsx +99 -101
- package/src/components/markdown-editor/theme.ts +28 -29
- package/src/components/markdown-editor/toolbar.tsx +53 -47
- package/src/components/markdown-with-mentions.tsx +56 -46
- package/src/components/message-logs/message-logs.tsx +225 -165
- package/src/components/messages/avatar.tsx +70 -52
- package/src/components/messages/channel-message-list.tsx +80 -68
- package/src/components/messages/channel-view.tsx +34 -33
- package/src/components/messages/message-compose.tsx +84 -67
- package/src/components/messages/message-display.tsx +103 -89
- package/src/components/messages/thread-message-list.tsx +53 -44
- package/src/components/router.tsx +42 -43
- package/src/components/save-button.tsx +43 -39
- package/src/components/sortable-list.tsx +77 -49
- package/src/components/tabs.tsx +31 -31
- package/src/components/tooltip.tsx +21 -28
- package/src/components/trust-level-badge.tsx +15 -11
- package/src/components/trust-level-dropdown.tsx +49 -19
- package/src/components/typeahead.tsx +57 -59
- package/src/components/voice-indicator.tsx +158 -141
- package/src/components/voice-subscribe-events.ts +20 -0
- package/src/globals.tsx +42 -40
- package/src/hooks.test.tsx +141 -134
- package/src/hooks.ts +80 -48
- package/src/index.tsx +17 -10
- package/src/mention-configs.ts +122 -68
- package/src/screens/assistants/assistant-config.tsx +28 -18
- package/src/screens/assistants/assistant-details.tsx +35 -36
- package/src/screens/assistants/assistant-info.tsx +16 -11
- package/src/screens/assistants/assistant-list.tsx +37 -34
- package/src/screens/assistants/assistant-tools.tsx +41 -20
- package/src/screens/console-logs/console-logs-list.tsx +173 -140
- package/src/screens/console-logs/log-display.tsx +65 -38
- package/src/screens/console-logs/log-filters.tsx +4 -3
- package/src/screens/console-logs/mobile-log-card.tsx +78 -71
- package/src/screens/console-logs/resizable-table-header.tsx +29 -21
- package/src/screens/contacts/contact-details.tsx +29 -30
- package/src/screens/contacts/contact-list.tsx +71 -60
- package/src/screens/contacts/index.ts +5 -5
- package/src/screens/contacts/user-connect.tsx +177 -171
- package/src/screens/data-explorer/data-explorer.tsx +134 -98
- package/src/screens/data-explorer/index.ts +2 -3
- package/src/screens/data-explorer/query-executor.tsx +90 -80
- package/src/screens/groups/group-details.tsx +120 -101
- package/src/screens/groups/group-invite-listener.tsx +34 -37
- package/src/screens/groups/group-list.tsx +119 -103
- package/src/screens/groups/group-members.tsx +225 -164
- package/src/screens/groups/index.ts +5 -6
- package/src/screens/join-group/index.ts +2 -2
- package/src/screens/join-group/join-group.tsx +41 -39
- package/src/screens/network-viewer/connection-troubleshooter.tsx +145 -104
- package/src/screens/network-viewer/cpu-usage-graph.tsx +39 -43
- package/src/screens/network-viewer/device-details-modal.tsx +46 -59
- package/src/screens/network-viewer/group-details-modal.tsx +68 -49
- package/src/screens/network-viewer/index.ts +4 -5
- package/src/screens/network-viewer/network-viewer-ipc.ts +23 -0
- package/src/screens/network-viewer/network-viewer.tsx +261 -236
- package/src/screens/network-viewer/usage-graph.tsx +57 -49
- package/src/screens/packages/package-details.tsx +43 -35
- package/src/screens/packages/package-info.tsx +107 -66
- package/src/screens/packages/package-list.tsx +175 -98
- package/src/screens/packages/package-new-local.tsx +28 -26
- package/src/screens/packages/package-versions.tsx +102 -77
- package/src/screens/peer-types/peer-type-details.tsx +60 -50
- package/src/screens/peer-types/peer-type-list.tsx +20 -30
- package/src/screens/search/global-search.tsx +153 -137
- package/src/screens/settings/color-mode-dropdown.tsx +52 -35
- package/src/screens/settings/settings-page.tsx +215 -141
- package/src/screens/settings/voice-settings-agent.tsx +13 -12
- package/src/screens/settings/voice-settings-api-keys.tsx +14 -12
- package/src/screens/settings/voice-settings-output.tsx +12 -11
- package/src/screens/settings/voice-settings-providers.tsx +7 -3
- package/src/screens/settings/voice-settings-types.ts +52 -49
- package/src/screens/settings/voice-settings-wake-word.tsx +25 -9
- package/src/screens/settings/voice-settings.tsx +66 -43
- package/src/screens/setup-user.tsx +88 -41
- package/src/screens/tools/tool-code.tsx +12 -17
- package/src/screens/tools/tool-details.tsx +28 -28
- package/src/screens/tools/tool-info.tsx +14 -19
- package/src/screens/tools/tool-list.tsx +58 -40
- package/src/screens/tools/tool-schema.tsx +16 -9
- package/src/screens/tools/tool-test-details.tsx +11 -22
- package/src/screens/tools/tool-test-list.tsx +29 -30
- package/src/screens/variables/variable-details.tsx +63 -51
- package/src/screens/variables/variable-list.tsx +29 -30
- package/src/screens/welcome-modal.tsx +68 -48
- package/src/screens/workflows/workflow-details.tsx +40 -30
- package/src/screens/workflows/workflow-info.tsx +4 -11
- package/src/screens/workflows/workflow-instructions.tsx +35 -28
- package/src/screens/workflows/workflow-list.tsx +50 -40
- package/src/setupTests.ts +14 -13
- package/src/system-apps/assistants.app.ts +5 -5
- package/src/system-apps/console-logs.app.ts +4 -4
- package/src/system-apps/contacts.app.ts +6 -6
- package/src/system-apps/data-explorer.app.ts +5 -5
- package/src/system-apps/groups.app.ts +6 -6
- package/src/system-apps/index.ts +49 -49
- package/src/system-apps/join-group.app.ts +5 -5
- package/src/system-apps/mobile-settings.app.ts +4 -5
- package/src/system-apps/network-viewer.app.ts +5 -5
- package/src/system-apps/packages.app.ts +5 -5
- package/src/system-apps/search.app.ts +6 -6
- package/src/system-apps/settings.app.ts +5 -5
- package/src/system-apps/threads.app.ts +5 -5
- package/src/system-apps/tools.app.ts +5 -5
- package/src/system-apps/types.app.ts +5 -5
- package/src/system-apps/variables.app.ts +5 -5
- package/src/system-apps/workflows.app.ts +5 -5
- package/src/tabs-layout/tabs-layout.tsx +345 -254
- package/src/tabs-layout/tabs-state.ts +100 -81
- package/src/ui-defaults/index.ts +2 -3
- package/src/ui-defaults/list-screen.tsx +45 -40
- package/src/ui-defaults/markdown-field.tsx +22 -26
- package/src/ui-router/routes-loader.ts +40 -24
- package/src/ui-router/ui-loader.tsx +312 -214
- package/src/utils.ts +68 -81
- package/tsconfig.json +5 -10
- package/dist/components/input-datetime.d.ts +0 -7
- package/dist/components/input-datetime.js +0 -35
- package/dist/components/lazy-sortable-list.d.ts +0 -29
- package/dist/components/lazy-sortable-list.js +0 -12
- package/dist/components/left-bar.d.ts +0 -5
- package/dist/components/left-bar.js +0 -207
- package/dist/components/main-content-container.d.ts +0 -2
- package/dist/components/main-content-container.js +0 -92
- package/dist/components/messages/thread-view.d.ts +0 -6
- package/dist/components/messages/thread-view.js +0 -174
- package/dist/components/off-canvas.d.ts +0 -13
- package/dist/components/off-canvas.js +0 -89
- package/dist/components/text-list-editor.tsx/text-list-editor.d.ts +0 -6
- package/dist/components/text-list-editor.tsx/text-list-editor.js +0 -13
- package/dist/components/top-bar.d.ts +0 -2
- package/dist/components/top-bar.js +0 -51
- package/dist/components/typeahead/mentions-plugin.d.ts +0 -7
- package/dist/components/typeahead/mentions-plugin.js +0 -203
- package/dist/components/typeahead/typeahead-editor.d.ts +0 -15
- package/dist/components/typeahead/typeahead-editor.js +0 -134
- package/dist/components/typeahead/typeahead.d.ts +0 -12
- package/dist/components/typeahead/typeahead.js +0 -94
- package/dist/screens/profile.d.ts +0 -2
- package/dist/screens/profile.js +0 -76
- package/src/components/input-datetime.tsx +0 -41
- package/src/components/lazy-sortable-list.tsx +0 -51
- package/src/components/left-bar.tsx +0 -322
- package/src/components/main-content-container.tsx +0 -79
- package/src/components/messages/thread-view.tsx +0 -214
- package/src/components/off-canvas.tsx +0 -83
- package/src/components/text-list-editor.tsx/text-list-editor.tsx +0 -13
- package/src/components/top-bar.tsx +0 -119
- package/src/components/typeahead/mentions-plugin.tsx +0 -265
- package/src/components/typeahead/typeahead-editor.tsx +0 -140
- package/src/components/typeahead/typeahead.tsx +0 -77
- package/src/screens/profile.tsx +0 -75
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
Assistants,
|
|
3
|
+
getUserContext,
|
|
4
|
+
getUserTrustLevel,
|
|
5
|
+
type IUser,
|
|
6
|
+
TrustLevel,
|
|
7
|
+
Users,
|
|
8
|
+
} from "@peers-app/peers-sdk";
|
|
9
|
+
import { usePromise } from "../../hooks";
|
|
4
10
|
|
|
5
11
|
interface IProps {
|
|
6
|
-
userId: string
|
|
7
|
-
assistantId?: string
|
|
8
|
-
setUser?: (user: IUser) =>
|
|
12
|
+
userId: string;
|
|
13
|
+
assistantId?: string;
|
|
14
|
+
setUser?: (user: IUser) => void;
|
|
9
15
|
}
|
|
10
16
|
|
|
11
17
|
export const Avatar = (props: IProps) => {
|
|
@@ -18,57 +24,65 @@ export const Avatar = (props: IProps) => {
|
|
|
18
24
|
}
|
|
19
25
|
return user;
|
|
20
26
|
});
|
|
21
|
-
const assistant = usePromise(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
const assistant = usePromise(
|
|
28
|
+
async () => {
|
|
29
|
+
if (assistantId) {
|
|
30
|
+
return Assistants().get(assistantId, { useCache: true });
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
undefined,
|
|
34
|
+
[assistantId],
|
|
35
|
+
);
|
|
26
36
|
|
|
27
|
-
const trustLevel = usePromise(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
37
|
+
const trustLevel = usePromise(
|
|
38
|
+
async () => {
|
|
39
|
+
if (userId) {
|
|
40
|
+
const userContext = await getUserContext();
|
|
41
|
+
return await getUserTrustLevel(userContext.userDataContext, userId);
|
|
42
|
+
}
|
|
43
|
+
return TrustLevel.Unknown;
|
|
44
|
+
},
|
|
45
|
+
TrustLevel.Unknown,
|
|
46
|
+
[userId],
|
|
47
|
+
);
|
|
34
48
|
|
|
35
|
-
let initials = "?"
|
|
49
|
+
let initials = "?";
|
|
36
50
|
|
|
37
|
-
|
|
51
|
+
const name = assistant?.name || user?.name;
|
|
38
52
|
if (user) {
|
|
39
53
|
if (!name) {
|
|
40
|
-
initials = "!"
|
|
54
|
+
initials = "!";
|
|
41
55
|
} else {
|
|
42
|
-
const words = name.split(
|
|
56
|
+
const words = name.split(" ");
|
|
43
57
|
const first = words[0];
|
|
44
|
-
const last = words.length > 1 ? words[words.length-1] : words[0][1];
|
|
45
|
-
initials = first[0] + last[0];
|
|
58
|
+
const last = words.length > 1 ? words[words.length - 1] : words[0][1];
|
|
59
|
+
initials = first[0] + last[0];
|
|
46
60
|
}
|
|
47
61
|
}
|
|
48
62
|
|
|
49
63
|
// TODO if user.avatarImage then get and show that
|
|
50
64
|
|
|
51
|
-
let backgroundColor = name ? stringToHslColor(name) : stringToHslColor(
|
|
65
|
+
let backgroundColor = name ? stringToHslColor(name) : stringToHslColor("", 100, 100);
|
|
52
66
|
if (assistant) {
|
|
53
67
|
// backgroundColor = stringToHslColor(name || '', 100, 100);
|
|
54
|
-
backgroundColor = stringToHslColor(
|
|
68
|
+
backgroundColor = stringToHslColor("", 0, 70);
|
|
55
69
|
}
|
|
56
70
|
|
|
57
71
|
// Get trust level config
|
|
58
72
|
const getTrustLevelConfig = (level: TrustLevel) => {
|
|
59
73
|
const configs = [
|
|
60
|
-
{ value: TrustLevel.Self, color:
|
|
61
|
-
{ value: TrustLevel.Trusted, color:
|
|
62
|
-
{ value: TrustLevel.Known, color:
|
|
63
|
-
{ value: TrustLevel.NewDevice, color:
|
|
64
|
-
{ value: TrustLevel.NewUser, color:
|
|
65
|
-
{ value: TrustLevel.Unknown, color:
|
|
66
|
-
{ value: TrustLevel.Untrusted, color:
|
|
67
|
-
{ value: TrustLevel.Malicious, color:
|
|
74
|
+
{ value: TrustLevel.Self, color: "#198754", icon: "bi-shield-fill-check" },
|
|
75
|
+
{ value: TrustLevel.Trusted, color: "#198754", icon: "bi-shield-fill-check" },
|
|
76
|
+
{ value: TrustLevel.Known, color: "#0d6efd", icon: "bi-shield-fill-check" },
|
|
77
|
+
{ value: TrustLevel.NewDevice, color: "#0dcaf0", icon: "bi-shield-fill-plus" },
|
|
78
|
+
{ value: TrustLevel.NewUser, color: "#0dcaf0", icon: "bi-shield-fill-plus" },
|
|
79
|
+
{ value: TrustLevel.Unknown, color: "#ffc107", icon: "bi-shield-fill-exclamation" },
|
|
80
|
+
{ value: TrustLevel.Untrusted, color: "#dc3545", icon: "bi-shield-fill-exclamation" },
|
|
81
|
+
{ value: TrustLevel.Malicious, color: "#dc3545", icon: "bi-shield-fill-x" },
|
|
68
82
|
];
|
|
69
83
|
|
|
70
84
|
const sortedConfigs = configs.sort((a, b) => a.value - b.value);
|
|
71
|
-
let config = { color:
|
|
85
|
+
let config = { color: "#6c757d", icon: "bi-shield" };
|
|
72
86
|
for (const c of sortedConfigs) {
|
|
73
87
|
if (level >= c.value) {
|
|
74
88
|
config = c;
|
|
@@ -86,13 +100,13 @@ export const Avatar = (props: IProps) => {
|
|
|
86
100
|
<div
|
|
87
101
|
className="rounded-circle d-flex justify-content-center align-items-center fs-4 border"
|
|
88
102
|
style={{
|
|
89
|
-
width:
|
|
90
|
-
height:
|
|
91
|
-
color:
|
|
103
|
+
width: "40px",
|
|
104
|
+
height: "40px",
|
|
105
|
+
color: "white",
|
|
92
106
|
backgroundColor,
|
|
93
107
|
}}
|
|
94
108
|
>
|
|
95
|
-
<span style={{ fontSize:
|
|
109
|
+
<span style={{ fontSize: "15pt" }}>
|
|
96
110
|
{assistant && <i className="bi bi-person-fill-gear"></i>}
|
|
97
111
|
{!assistant && initials.toUpperCase()}
|
|
98
112
|
{/* {assistant ? "ai" : initials.toUpperCase()} */}
|
|
@@ -103,19 +117,19 @@ export const Avatar = (props: IProps) => {
|
|
|
103
117
|
<div
|
|
104
118
|
className="position-absolute d-flex justify-content-center align-items-center"
|
|
105
119
|
style={{
|
|
106
|
-
bottom:
|
|
107
|
-
right:
|
|
108
|
-
width:
|
|
109
|
-
height:
|
|
120
|
+
bottom: "-4px",
|
|
121
|
+
right: "0px",
|
|
122
|
+
width: "18px",
|
|
123
|
+
height: "18px",
|
|
110
124
|
// backgroundColor: 'white',
|
|
111
|
-
borderRadius:
|
|
125
|
+
borderRadius: "50%",
|
|
112
126
|
// border: '1px solid #dee2e6',
|
|
113
127
|
}}
|
|
114
128
|
>
|
|
115
129
|
<i
|
|
116
130
|
className={trustConfig.icon}
|
|
117
131
|
style={{
|
|
118
|
-
fontSize:
|
|
132
|
+
fontSize: "12px",
|
|
119
133
|
color: trustConfig.color,
|
|
120
134
|
}}
|
|
121
135
|
></i>
|
|
@@ -138,16 +152,20 @@ export const Avatar = (props: IProps) => {
|
|
|
138
152
|
)} */}
|
|
139
153
|
</div>
|
|
140
154
|
);
|
|
141
|
-
}
|
|
155
|
+
};
|
|
142
156
|
|
|
143
|
-
export function stringToHslColor(
|
|
157
|
+
export function stringToHslColor(
|
|
158
|
+
str: string = "",
|
|
159
|
+
saturation: number = 50,
|
|
160
|
+
lightness: number = 40,
|
|
161
|
+
) {
|
|
144
162
|
saturation = saturation % 100;
|
|
145
163
|
lightness = lightness % 100;
|
|
146
|
-
|
|
147
|
-
for (
|
|
164
|
+
let hash = 0;
|
|
165
|
+
for (let i = 0; i < str.length; i++) {
|
|
148
166
|
hash = str.charCodeAt(i) + ((hash << 5) - hash);
|
|
149
167
|
}
|
|
150
168
|
|
|
151
|
-
|
|
152
|
-
return
|
|
153
|
-
}
|
|
169
|
+
const h = hash % 360;
|
|
170
|
+
return `hsl(${h}, ${saturation}%, ${lightness}%)`;
|
|
171
|
+
}
|
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import { DataFilter, IMessage, Messages } from "@peers-app/peers-sdk";
|
|
2
|
-
import { min, sortBy, uniqBy } from
|
|
3
|
-
import React, { Fragment, useEffect, useState } from
|
|
4
|
-
import InfiniteScroll from
|
|
5
|
-
import { me } from
|
|
6
|
-
import { LoadingIndicator } from
|
|
7
|
-
import { } from
|
|
8
|
-
import { MessageDisplay } from './message-display';
|
|
1
|
+
import { type DataFilter, type IMessage, Messages } from "@peers-app/peers-sdk";
|
|
2
|
+
import { min, sortBy, uniqBy } from "lodash";
|
|
3
|
+
import React, { Fragment, useCallback, useEffect, useState } from "react";
|
|
4
|
+
import InfiniteScroll from "react-infinite-scroll-component";
|
|
5
|
+
import { me } from "../../globals";
|
|
6
|
+
import { LoadingIndicator } from "../loading-indicator";
|
|
7
|
+
import { MessageDisplay } from "./message-display";
|
|
9
8
|
|
|
10
|
-
const windowHeight = () => window.innerHeight
|
|
9
|
+
const windowHeight = () => window.innerHeight;
|
|
11
10
|
|
|
12
11
|
interface IProps {
|
|
13
|
-
height:
|
|
14
|
-
channelId: string
|
|
15
|
-
batchSize: number
|
|
12
|
+
height: number | string;
|
|
13
|
+
channelId: string;
|
|
14
|
+
batchSize: number;
|
|
16
15
|
effects?: {
|
|
17
|
-
pushMessage: (message: IMessage) =>
|
|
18
|
-
}
|
|
19
|
-
scrollChanged?: (isBottomInView: boolean) =>
|
|
16
|
+
pushMessage: (message: IMessage) => void;
|
|
17
|
+
};
|
|
18
|
+
scrollChanged?: (isBottomInView: boolean) => void;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
export const ChannelMessageList = (props: IProps) => {
|
|
@@ -25,19 +24,19 @@ export const ChannelMessageList = (props: IProps) => {
|
|
|
25
24
|
const [messages, setMessages] = useState<IMessage[]>([]);
|
|
26
25
|
const [allMessagesLoaded, setAllMessagesLoaded] = useState(false);
|
|
27
26
|
const messagesEndRef = React.useRef<HTMLDivElement>(null);
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
|
|
28
|
+
const scrollToBottom = useCallback((behavior: "instant" | "smooth", delay = 100) => {
|
|
30
29
|
setTimeout(() => {
|
|
31
30
|
messagesEndRef.current?.scrollIntoView({ behavior });
|
|
32
|
-
}, delay);
|
|
33
|
-
}
|
|
31
|
+
}, delay);
|
|
32
|
+
}, []);
|
|
34
33
|
|
|
35
34
|
useEffect(() => {
|
|
36
35
|
const observer = new IntersectionObserver(
|
|
37
36
|
([entry]) => {
|
|
38
37
|
props?.scrollChanged?.(entry.isIntersecting);
|
|
39
38
|
},
|
|
40
|
-
{ threshold: 1.0 }
|
|
39
|
+
{ threshold: 1.0 },
|
|
41
40
|
);
|
|
42
41
|
|
|
43
42
|
if (messagesEndRef.current) {
|
|
@@ -49,78 +48,84 @@ export const ChannelMessageList = (props: IProps) => {
|
|
|
49
48
|
observer.unobserve(messagesEndRef.current);
|
|
50
49
|
}
|
|
51
50
|
};
|
|
52
|
-
}, []);
|
|
51
|
+
}, [props?.scrollChanged]);
|
|
53
52
|
|
|
54
|
-
|
|
53
|
+
const prependItems = useCallback(() => {
|
|
55
54
|
const lastMessage = messages[messages.length - 1];
|
|
56
|
-
getMessages(batchSize, channelId, lastMessage)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
})
|
|
55
|
+
getMessages(batchSize, channelId, lastMessage).then((fetchedMessages) => {
|
|
56
|
+
if (fetchedMessages.length === 0) {
|
|
57
|
+
setAllMessagesLoaded(true);
|
|
58
|
+
} else {
|
|
59
|
+
const _messages = sortBy([...messages, ...fetchedMessages], "createdAt").reverse();
|
|
60
|
+
setMessages(uniqBy(_messages, "messageId"));
|
|
61
|
+
}
|
|
62
|
+
});
|
|
65
63
|
return false;
|
|
66
|
-
}
|
|
64
|
+
}, [messages, batchSize, channelId]);
|
|
67
65
|
|
|
68
66
|
const minHeightOfMessage = 20;
|
|
69
67
|
useEffect(() => {
|
|
70
|
-
if (
|
|
68
|
+
if (
|
|
69
|
+
!allMessagesLoaded &&
|
|
70
|
+
(!messages.length || messages.length * minHeightOfMessage < windowHeight())
|
|
71
|
+
) {
|
|
71
72
|
prependItems();
|
|
72
73
|
}
|
|
73
|
-
}, [
|
|
74
|
+
}, [messages, allMessagesLoaded, prependItems]);
|
|
74
75
|
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
// Shared-ref pattern: parent (ChannelMessages) passes its own `effects` object; we mutate
|
|
77
|
+
// `pushMessage` on that SAME reference so the parent's sendMessage can invoke it. Do NOT
|
|
78
|
+
// spread/clone (`{...props.effects}`) — it breaks the shared reference.
|
|
79
|
+
// biome-ignore lint/style/noNonNullAssertion: initial `{}` is populated on this same render; the `!` placates TS for the optional `IProps["effects"]` shape.
|
|
80
|
+
const [effects] = useState(() => props.effects || ({} as IProps["effects"])!);
|
|
77
81
|
effects.pushMessage = (newMessage: IMessage) => {
|
|
78
82
|
if (
|
|
79
|
-
(messages.length > batchSize &&
|
|
80
|
-
|
|
83
|
+
(messages.length > batchSize &&
|
|
84
|
+
// biome-ignore lint/style/noNonNullAssertion: guarded by `messages.length > batchSize` — messages is non-empty so `min(...)` is defined.
|
|
85
|
+
min(messages.map((m) => m.createdAt))! > newMessage.createdAt) ||
|
|
86
|
+
messages.find((m) => m.messageId === newMessage.messageId)
|
|
81
87
|
) {
|
|
82
88
|
return;
|
|
83
89
|
}
|
|
84
|
-
|
|
90
|
+
const _messages = sortBy([newMessage, ...messages], "createdAt").reverse();
|
|
85
91
|
setMessages(_messages);
|
|
86
92
|
if (newMessage.userId === me.userId && !newMessage.assistantId) {
|
|
87
|
-
scrollToBottom(
|
|
93
|
+
scrollToBottom("instant", 1);
|
|
88
94
|
} else {
|
|
89
|
-
scrollToBottom(
|
|
90
|
-
}
|
|
91
|
-
}
|
|
95
|
+
scrollToBottom("smooth");
|
|
96
|
+
}
|
|
97
|
+
};
|
|
92
98
|
|
|
93
99
|
useEffect(() => {
|
|
94
|
-
const sub = Messages().dataChanged.subscribe(evt => {
|
|
100
|
+
const sub = Messages().dataChanged.subscribe((evt) => {
|
|
95
101
|
const message: IMessage = evt.dataObject;
|
|
96
102
|
if (message.channelId !== channelId || message.messageParentId) {
|
|
97
103
|
return;
|
|
98
104
|
}
|
|
99
|
-
if (evt.op ===
|
|
105
|
+
if (evt.op === "insert") {
|
|
100
106
|
effects.pushMessage(message);
|
|
101
|
-
}
|
|
107
|
+
}
|
|
102
108
|
});
|
|
103
109
|
return () => {
|
|
104
110
|
sub.unsubscribe();
|
|
105
|
-
}
|
|
106
|
-
}, [channelId]);
|
|
107
|
-
|
|
111
|
+
};
|
|
112
|
+
}, [channelId, effects.pushMessage]);
|
|
108
113
|
|
|
109
114
|
return (
|
|
110
115
|
<div
|
|
111
116
|
id="scrollableDiv"
|
|
112
117
|
style={{
|
|
113
118
|
height,
|
|
114
|
-
overflow:
|
|
115
|
-
display:
|
|
116
|
-
flexDirection:
|
|
119
|
+
overflow: "auto",
|
|
120
|
+
display: "flex",
|
|
121
|
+
flexDirection: "column-reverse",
|
|
117
122
|
// marginBottom: '70px',
|
|
118
123
|
}}
|
|
119
124
|
>
|
|
120
125
|
<InfiniteScroll
|
|
121
126
|
dataLength={messages.length}
|
|
122
127
|
next={prependItems}
|
|
123
|
-
style={{ display:
|
|
128
|
+
style={{ display: "flex", flexDirection: "column-reverse", overflow: "hidden" }}
|
|
124
129
|
inverse={true}
|
|
125
130
|
hasMore={!allMessagesLoaded}
|
|
126
131
|
loader={<LoadingIndicator />}
|
|
@@ -129,9 +134,7 @@ export const ChannelMessageList = (props: IProps) => {
|
|
|
129
134
|
<Fragment>
|
|
130
135
|
<div className="d-flex justify-content-center">
|
|
131
136
|
{messages[0] && (
|
|
132
|
-
<div>
|
|
133
|
-
{(new Date(messages[messages.length - 1].createdAt).toLocaleDateString())}
|
|
134
|
-
</div>
|
|
137
|
+
<div>{new Date(messages[messages.length - 1].createdAt).toLocaleDateString()}</div>
|
|
135
138
|
)}
|
|
136
139
|
</div>
|
|
137
140
|
<div className="d-flex justify-content-center">
|
|
@@ -145,26 +148,35 @@ export const ChannelMessageList = (props: IProps) => {
|
|
|
145
148
|
{/* <div style={{ marginBottom: '10px' }}></div> */}
|
|
146
149
|
<div ref={messagesEndRef} />
|
|
147
150
|
{messages.map((message, index) => {
|
|
148
|
-
return
|
|
151
|
+
return (
|
|
152
|
+
<MessageDisplay
|
|
153
|
+
key={message.messageId}
|
|
154
|
+
message={message}
|
|
155
|
+
messageAbove={messages[index + 1]}
|
|
156
|
+
index={index}
|
|
157
|
+
/>
|
|
158
|
+
);
|
|
149
159
|
})}
|
|
150
160
|
</InfiniteScroll>
|
|
151
161
|
</div>
|
|
152
|
-
)
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export async function getMessages(
|
|
156
|
-
|
|
162
|
+
);
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export async function getMessages(
|
|
166
|
+
batchSize: number,
|
|
167
|
+
channelId: string,
|
|
168
|
+
lastMessage: IMessage | undefined,
|
|
169
|
+
): Promise<IMessage[]> {
|
|
170
|
+
const query: DataFilter<IMessage> = {
|
|
157
171
|
channelId,
|
|
158
172
|
messageParentId: null,
|
|
159
173
|
};
|
|
160
174
|
if (lastMessage) {
|
|
161
175
|
query.messageId = { $lt: lastMessage.messageId };
|
|
162
176
|
}
|
|
163
|
-
const cursor = await Messages().cursor(
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
sortBy: ['-createdAt', '-messageId'],
|
|
167
|
-
});
|
|
177
|
+
const cursor = await Messages().cursor(query, {
|
|
178
|
+
sortBy: ["-createdAt", "-messageId"],
|
|
179
|
+
});
|
|
168
180
|
|
|
169
181
|
const messages: IMessage[] = [];
|
|
170
182
|
for await (const message of cursor) {
|
|
@@ -174,4 +186,4 @@ export async function getMessages(batchSize: number, channelId: string, lastMess
|
|
|
174
186
|
}
|
|
175
187
|
}
|
|
176
188
|
return messages;
|
|
177
|
-
}
|
|
189
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { openThread } from
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
1
|
+
import { getUserContext, type IMessage, Messages } from "@peers-app/peers-sdk";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { openThread } from "../../globals";
|
|
4
|
+
import { useObservableState, usePromise } from "../../hooks";
|
|
5
|
+
import { registerInternalPeersUI } from "../../ui-router/ui-loader";
|
|
6
|
+
import { ChannelMessageList } from "./channel-message-list";
|
|
7
|
+
import { MessageCompose } from "./message-compose";
|
|
8
8
|
|
|
9
9
|
interface IProps {
|
|
10
10
|
channelId?: string;
|
|
@@ -12,26 +12,28 @@ interface IProps {
|
|
|
12
12
|
|
|
13
13
|
export const ChannelMessages = (props: IProps) => {
|
|
14
14
|
const messagesEndRef = useRef<HTMLDivElement>(null);
|
|
15
|
-
const [effects] = useState<{ pushMessage: (message: IMessage) =>
|
|
15
|
+
const [effects] = useState<{ pushMessage: (message: IMessage) => void }>(
|
|
16
|
+
() => ({}) as { pushMessage: (message: IMessage) => void },
|
|
17
|
+
);
|
|
16
18
|
const [scrolledToBottom, setScrolledToBottom] = useState(true);
|
|
17
19
|
const currentlyActiveGroupId = useObservableState("");
|
|
18
20
|
const userContext = usePromise(() => getUserContext());
|
|
19
21
|
|
|
20
22
|
useEffect(() => {
|
|
21
23
|
if (userContext) {
|
|
22
|
-
currentlyActiveGroupId(userContext.currentlyActiveGroupId() ||
|
|
24
|
+
currentlyActiveGroupId(userContext.currentlyActiveGroupId() || "");
|
|
23
25
|
const sub = userContext.currentlyActiveGroupId.subscribe(() => {
|
|
24
|
-
currentlyActiveGroupId(userContext?.currentlyActiveGroupId() ||
|
|
26
|
+
currentlyActiveGroupId(userContext?.currentlyActiveGroupId() || "");
|
|
25
27
|
});
|
|
26
28
|
return () => sub.dispose();
|
|
27
29
|
}
|
|
28
|
-
}, [userContext]);
|
|
30
|
+
}, [userContext, currentlyActiveGroupId]);
|
|
29
31
|
|
|
30
32
|
if (!userContext) {
|
|
31
33
|
return <div>Loading...</div>;
|
|
32
34
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
|
|
36
|
+
const channelId = props.channelId || currentlyActiveGroupId();
|
|
35
37
|
|
|
36
38
|
// const scrollToBottom = (behavior: 'instant' | 'smooth' = 'instant') => {
|
|
37
39
|
// setTimeout(() => messagesEndRef.current?.scrollIntoView({ behavior }), 500);
|
|
@@ -39,10 +41,12 @@ export const ChannelMessages = (props: IProps) => {
|
|
|
39
41
|
|
|
40
42
|
const sendMessage = (userMessage: IMessage) => {
|
|
41
43
|
effects.pushMessage(userMessage);
|
|
42
|
-
Messages()
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
Messages()
|
|
45
|
+
.save(userMessage)
|
|
46
|
+
.then((message) => {
|
|
47
|
+
openThread(message.messageId);
|
|
48
|
+
});
|
|
49
|
+
};
|
|
46
50
|
|
|
47
51
|
return (
|
|
48
52
|
<div
|
|
@@ -50,7 +54,7 @@ export const ChannelMessages = (props: IProps) => {
|
|
|
50
54
|
className="d-flex flex-column flex-col-reverse"
|
|
51
55
|
style={{
|
|
52
56
|
// height: '100vh',
|
|
53
|
-
height:
|
|
57
|
+
height: "calc(100vh - 50px)",
|
|
54
58
|
// marginTop: '50px',
|
|
55
59
|
}}
|
|
56
60
|
>
|
|
@@ -58,34 +62,31 @@ export const ChannelMessages = (props: IProps) => {
|
|
|
58
62
|
batchSize={30}
|
|
59
63
|
channelId={channelId}
|
|
60
64
|
// height="calc(100vh - 50px)"
|
|
61
|
-
height=
|
|
65
|
+
height="100vh"
|
|
62
66
|
effects={effects}
|
|
63
67
|
scrollChanged={setScrolledToBottom}
|
|
64
68
|
/>
|
|
65
69
|
<div ref={messagesEndRef} />
|
|
66
70
|
|
|
67
|
-
<div
|
|
71
|
+
<div
|
|
72
|
+
className="p-2 pt-1"
|
|
68
73
|
style={{
|
|
69
|
-
boxShadow: scrolledToBottom ?
|
|
74
|
+
boxShadow: scrolledToBottom ? "" : `0 -10px 11px -10px rgba(0, 0, 0, 0.9)`,
|
|
70
75
|
}}
|
|
71
76
|
>
|
|
72
|
-
<MessageCompose
|
|
73
|
-
channelId={channelId}
|
|
74
|
-
onMessageSubmit={sendMessage}
|
|
75
|
-
/>
|
|
77
|
+
<MessageCompose channelId={channelId} onMessageSubmit={sendMessage} />
|
|
76
78
|
</div>
|
|
77
|
-
|
|
78
79
|
</div>
|
|
79
80
|
);
|
|
80
|
-
}
|
|
81
|
+
};
|
|
81
82
|
|
|
82
83
|
registerInternalPeersUI({
|
|
83
|
-
peersUIId:
|
|
84
|
+
peersUIId: "00m5fsd8d4jma58fgvyr1riny",
|
|
84
85
|
component: ChannelMessages,
|
|
85
86
|
routes: [
|
|
86
|
-
{
|
|
87
|
-
isMatch: (
|
|
88
|
-
uiCategory:
|
|
87
|
+
{
|
|
88
|
+
isMatch: (_props, context) => context.path === "threads" || context.path === "",
|
|
89
|
+
uiCategory: "screen",
|
|
89
90
|
},
|
|
90
|
-
]
|
|
91
|
-
})
|
|
91
|
+
],
|
|
92
|
+
});
|