stream-chat 10.0.0-rc.21 → 10.0.0-rc.23
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/dist/cjs/index.browser.js +2196 -3902
- package/dist/cjs/index.browser.js.map +3 -3
- package/dist/cjs/index.node.js +2197 -3902
- package/dist/cjs/index.node.js.map +3 -3
- package/dist/esm/index.mjs +2199 -3905
- package/dist/esm/index.mjs.map +4 -4
- package/dist/types/ChannelManager.d.ts +120 -233
- package/dist/types/CooldownTimer.d.ts +8 -23
- package/dist/types/EventHandlerPipeline.d.ts +17 -37
- package/dist/types/LiveLocationManager.d.ts +22 -50
- package/dist/types/api-client.d.ts +9 -14
- package/dist/types/channel.d.ts +253 -448
- package/dist/types/channel_state.d.ts +48 -95
- package/dist/types/client.d.ts +245 -370
- package/dist/types/client_state.d.ts +1 -3
- package/dist/types/configuration/ConfigController.d.ts +30 -124
- package/dist/types/configuration/InstanceConfigurationRegistry.d.ts +31 -123
- package/dist/types/configuration/keys.d.ts +5 -19
- package/dist/types/configuration/shape.d.ts +12 -29
- package/dist/types/configuration/types.d.ts +59 -87
- package/dist/types/configuration/utils/applyInstanceConfiguration.d.ts +13 -35
- package/dist/types/configuration/utils/copyConfigPatch.d.ts +8 -0
- package/dist/types/configuration/utils/declarativeSlices.d.ts +5 -16
- package/dist/types/configuration/utils/deepFreezeConfig.d.ts +3 -17
- package/dist/types/configuration/utils/serverAuthority.d.ts +9 -29
- package/dist/types/connection/ConnectionIdManager.d.ts +18 -40
- package/dist/types/connection/ConnectionRecoveryManager.d.ts +29 -120
- package/dist/types/connection/networkConnection/NetworkConnectionObserver.d.ts +32 -103
- package/dist/types/connection/networkConnection/reporters.d.ts +9 -32
- package/dist/types/connection/networkConnection/types.d.ts +12 -27
- package/dist/types/connection/wsConnection/StableWSConnection.d.ts +37 -116
- package/dist/types/connection/wsConnection/WSConnection.d.ts +41 -104
- package/dist/types/connection/wsConnection/WSConnectionFallback.d.ts +8 -16
- package/dist/types/connection/wsConnection/config.d.ts +8 -28
- package/dist/types/connection/wsConnection/types.d.ts +17 -70
- package/dist/types/entityStore/EntityStore.d.ts +153 -113
- package/dist/types/entityStore/StoreBackedItemIndex.d.ts +13 -46
- package/dist/types/errors.d.ts +7 -19
- package/dist/types/gen/chat/ChannelApi.d.ts +2 -1
- package/dist/types/gen/chat/ChatApi.d.ts +28 -14
- package/dist/types/gen/models/index.d.ts +769 -86
- package/dist/types/gen/moderation/ModerationApi.d.ts +4 -4
- package/dist/types/index.d.ts +2 -4
- package/dist/types/languageNames.d.ts +9 -24
- package/dist/types/logger.d.ts +1 -3
- package/dist/types/messageComposer/LocationComposer.d.ts +1 -1
- package/dist/types/messageComposer/attachmentIdentity.d.ts +1 -6
- package/dist/types/messageComposer/attachmentManager.d.ts +10 -32
- package/dist/types/messageComposer/attachmentUtils.d.ts +3 -14
- package/dist/types/messageComposer/configuration/configuration.d.ts +2 -5
- package/dist/types/messageComposer/configuration/types.d.ts +29 -56
- package/dist/types/messageComposer/linkPreviewsManager.d.ts +6 -9
- package/dist/types/messageComposer/messageComposer.d.ts +30 -164
- package/dist/types/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.d.ts +4 -14
- package/dist/types/messageComposer/middleware/messageComposer/attachments.d.ts +2 -9
- package/dist/types/messageComposer/middleware/pollComposer/types.d.ts +2 -4
- package/dist/types/messageComposer/middleware/pollComposer/validation.d.ts +7 -19
- package/dist/types/messageComposer/middleware/textComposer/commands.d.ts +9 -0
- package/dist/types/messageComposer/middleware/textComposer/mentions.d.ts +11 -18
- package/dist/types/messageComposer/middleware/textComposer/textMiddlewareUtils.d.ts +9 -3
- package/dist/types/messageComposer/middleware/textComposer/types.d.ts +1 -6
- package/dist/types/messageComposer/pollComposer.d.ts +8 -4
- package/dist/types/messageComposer/textComposer.d.ts +3 -9
- package/dist/types/messageComposer/types.d.ts +5 -8
- package/dist/types/messageDelivery/MessageDeliveryReporter.d.ts +25 -79
- package/dist/types/messageDelivery/MessageReceiptsTracker.d.ts +15 -82
- package/dist/types/messageOperations/FailedSendCache.d.ts +4 -9
- package/dist/types/messageOperations/MessageOperationStatePolicy.d.ts +10 -20
- package/dist/types/messageOperations/MessageOperations.d.ts +20 -40
- package/dist/types/messageOperations/applyReactionLocally.d.ts +5 -22
- package/dist/types/messageOperations/createMessageOperations.d.ts +3 -5
- package/dist/types/messageOperations/reflectReactionEvent.d.ts +5 -13
- package/dist/types/messageOperations/sendOrdering.d.ts +4 -7
- package/dist/types/messageOperations/settlePendingAttachmentUploads.d.ts +7 -15
- package/dist/types/messageOperations/types.d.ts +15 -30
- package/dist/types/middleware.d.ts +7 -5
- package/dist/types/moderation.d.ts +21 -14
- package/dist/types/notifications/NotificationManager.d.ts +8 -31
- package/dist/types/notifications/types.d.ts +19 -59
- package/dist/types/offline-support/offline_support_api.d.ts +145 -539
- package/dist/types/offline-support/offline_sync_manager.d.ts +18 -42
- package/dist/types/offline-support/queueableOperations.d.ts +24 -52
- package/dist/types/offline-support/types.d.ts +24 -187
- package/dist/types/pagination/ItemIndex.d.ts +4 -12
- package/dist/types/pagination/cursorDerivation/aroundPaginationFlags.d.ts +13 -0
- package/dist/types/pagination/cursorDerivation/createdAtAroundPaginationFlags.d.ts +2 -4
- package/dist/types/pagination/cursorDerivation/linearPaginationFlags.d.ts +2 -3
- package/dist/types/pagination/paginators/BasePaginator.d.ts +235 -622
- package/dist/types/pagination/paginators/ChannelPaginator.d.ts +67 -125
- package/dist/types/pagination/paginators/MessageIntervalPaginator.d.ts +133 -292
- package/dist/types/pagination/paginators/MessagePaginator.d.ts +69 -118
- package/dist/types/pagination/paginators/PinnedMessagePaginator.d.ts +7 -26
- package/dist/types/pagination/paginators/ReminderPaginator.d.ts +2 -2
- package/dist/types/pagination/paginators/ThreadPaginator.d.ts +15 -23
- package/dist/types/pagination/paginators/UserGroupPaginator.d.ts +2 -6
- package/dist/types/pagination/sortCompiler.d.ts +11 -22
- package/dist/types/pagination/utility.normalization.d.ts +5 -23
- package/dist/types/pagination/utility.search.d.ts +3 -8
- package/dist/types/poll.d.ts +14 -14
- package/dist/types/poll_manager.d.ts +11 -2
- package/dist/types/poll_optimistic_votes.d.ts +10 -14
- package/dist/types/reminders/Reminder.d.ts +4 -4
- package/dist/types/reminders/ReminderManager.d.ts +7 -20
- package/dist/types/search/BaseSearchSource.d.ts +7 -12
- package/dist/types/search/ChannelSearchSource.d.ts +7 -7
- package/dist/types/search/MessageSearchSource.d.ts +7 -9
- package/dist/types/search/SearchController.d.ts +17 -22
- package/dist/types/search/types.d.ts +6 -10
- package/dist/types/signing.d.ts +12 -3
- package/dist/types/thread.d.ts +23 -71
- package/dist/types/thread_manager.d.ts +45 -70
- package/dist/types/token_manager.d.ts +8 -13
- package/dist/types/types.d.ts +64 -125
- package/dist/types/types.utility.d.ts +3 -3
- package/dist/types/upload-utils.d.ts +5 -10
- package/dist/types/uploadManager.d.ts +17 -45
- package/dist/types/utils/FixedSizeQueueCache.d.ts +6 -11
- package/dist/types/utils/WithSubscriptions.d.ts +5 -15
- package/dist/types/utils/concurrency.d.ts +11 -19
- package/dist/types/utils/mergeWith/mergeWith.d.ts +8 -11
- package/dist/types/utils/mergeWith/mergeWithCore.d.ts +5 -13
- package/dist/types/utils/mergeWith/mergeWithDiff.d.ts +22 -0
- package/dist/types/utils/objectPath.d.ts +6 -41
- package/dist/types/utils/retryable.d.ts +8 -12
- package/dist/types/utils/throttling/throttle.d.ts +8 -23
- package/dist/types/utils/time.d.ts +24 -64
- package/dist/types/utils.d.ts +40 -86
- package/package.json +7 -2
- package/src/ChannelManager.ts +159 -300
- package/src/CooldownTimer.ts +11 -29
- package/src/EventHandlerPipeline.ts +21 -44
- package/src/LiveLocationManager.ts +35 -74
- package/src/api-client.ts +43 -61
- package/src/campaign.ts +1 -1
- package/src/channel.ts +396 -749
- package/src/channel_batch_updater.ts +1 -1
- package/src/channel_state.ts +50 -105
- package/src/client.ts +360 -588
- package/src/client_state.ts +1 -6
- package/src/configuration/ConfigController.ts +41 -157
- package/src/configuration/InstanceConfigurationRegistry.ts +42 -171
- package/src/configuration/index.ts +1 -1
- package/src/configuration/keys.ts +13 -32
- package/src/configuration/shape.ts +67 -70
- package/src/configuration/types.ts +60 -100
- package/src/configuration/utils/applyInstanceConfiguration.ts +21 -53
- package/src/configuration/utils/copyConfigPatch.ts +11 -32
- package/src/configuration/utils/declarativeSlices.ts +9 -39
- package/src/configuration/utils/deepFreezeConfig.ts +3 -17
- package/src/configuration/utils/index.ts +2 -4
- package/src/configuration/utils/serverAuthority.ts +20 -68
- package/src/connection/ConnectionIdManager.ts +20 -49
- package/src/connection/ConnectionRecoveryManager.ts +51 -178
- package/src/connection/networkConnection/NetworkConnectionObserver.ts +37 -114
- package/src/connection/networkConnection/reporters.ts +9 -36
- package/src/connection/networkConnection/types.ts +12 -27
- package/src/connection/wsConnection/StableWSConnection.ts +73 -193
- package/src/connection/wsConnection/WSConnection.ts +56 -131
- package/src/connection/wsConnection/WSConnectionFallback.ts +22 -31
- package/src/connection/wsConnection/config.ts +13 -48
- package/src/connection/wsConnection/types.ts +17 -70
- package/src/constants.ts +4 -4
- package/src/entityStore/EntityStore.ts +162 -167
- package/src/entityStore/StoreBackedItemIndex.ts +14 -47
- package/src/errors.ts +7 -19
- package/src/formatMessageMemo.ts +3 -9
- package/src/gen/chat/ChannelApi.ts +19 -0
- package/src/gen/chat/ChatApi.ts +87 -13
- package/src/gen/models/index.ts +793 -71
- package/src/gen/moderation/ModerationApi.ts +0 -4
- package/src/index.ts +10 -14
- package/src/languageNames.ts +9 -24
- package/src/logger.ts +1 -3
- package/src/messageComposer/LocationComposer.ts +7 -23
- package/src/messageComposer/MessageComposerEffectHandlers.ts +1 -2
- package/src/messageComposer/attachmentIdentity.ts +2 -13
- package/src/messageComposer/attachmentManager.ts +17 -63
- package/src/messageComposer/attachmentUtils.ts +3 -17
- package/src/messageComposer/configuration/configuration.ts +5 -8
- package/src/messageComposer/configuration/types.ts +29 -56
- package/src/messageComposer/fileUtils.ts +1 -1
- package/src/messageComposer/linkPreviewsManager.ts +8 -20
- package/src/messageComposer/messageComposer.ts +54 -222
- package/src/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.ts +4 -16
- package/src/messageComposer/middleware/attachmentManager/postUpload/uploadErrorHandler.ts +1 -2
- package/src/messageComposer/middleware/messageComposer/attachments.ts +14 -40
- package/src/messageComposer/middleware/messageComposer/linkPreviews.ts +3 -4
- package/src/messageComposer/middleware/messageComposer/textComposer.ts +1 -1
- package/src/messageComposer/middleware/messageComposer/userDataInjection.ts +4 -11
- package/src/messageComposer/middleware/pollComposer/state.ts +2 -2
- package/src/messageComposer/middleware/pollComposer/types.ts +2 -4
- package/src/messageComposer/middleware/pollComposer/validation.ts +8 -26
- package/src/messageComposer/middleware/textComposer/TextComposerMiddlewareExecutor.ts +1 -6
- package/src/messageComposer/middleware/textComposer/commandUtils.ts +1 -2
- package/src/messageComposer/middleware/textComposer/commands.ts +11 -16
- package/src/messageComposer/middleware/textComposer/mentions.ts +32 -70
- package/src/messageComposer/middleware/textComposer/textMiddlewareUtils.ts +10 -4
- package/src/messageComposer/middleware/textComposer/types.ts +1 -6
- package/src/messageComposer/pollComposer.ts +11 -8
- package/src/messageComposer/textComposer.ts +9 -59
- package/src/messageComposer/types.ts +9 -12
- package/src/messageDelivery/MessageDeliveryReporter.ts +60 -113
- package/src/messageDelivery/MessageReceiptsTracker.ts +21 -105
- package/src/messageOperations/FailedSendCache.ts +4 -9
- package/src/messageOperations/MessageOperationStatePolicy.ts +40 -67
- package/src/messageOperations/MessageOperations.ts +33 -62
- package/src/messageOperations/applyReactionLocally.ts +9 -28
- package/src/messageOperations/createMessageOperations.ts +17 -33
- package/src/messageOperations/reflectReactionEvent.ts +5 -13
- package/src/messageOperations/sendOrdering.ts +4 -7
- package/src/messageOperations/settlePendingAttachmentUploads.ts +10 -21
- package/src/messageOperations/types.ts +15 -30
- package/src/middleware.ts +7 -10
- package/src/moderation.ts +25 -21
- package/src/notifications/NotificationManager.ts +11 -35
- package/src/notifications/types.ts +19 -59
- package/src/offline-support/offline_support_api.ts +178 -608
- package/src/offline-support/offline_sync_manager.ts +25 -69
- package/src/offline-support/queueableOperations.ts +31 -84
- package/src/offline-support/types.ts +25 -188
- package/src/pagination/ItemIndex.ts +4 -12
- package/src/pagination/cursorDerivation/aroundPaginationFlags.ts +29 -0
- package/src/pagination/cursorDerivation/createdAtAroundPaginationFlags.ts +13 -62
- package/src/pagination/cursorDerivation/idAroundPaginationFlags.ts +11 -39
- package/src/pagination/cursorDerivation/linearPaginationFlags.ts +4 -6
- package/src/pagination/filterCompiler.ts +11 -25
- package/src/pagination/paginators/BasePaginator.ts +422 -976
- package/src/pagination/paginators/ChannelPaginator.ts +130 -190
- package/src/pagination/paginators/MessageIntervalPaginator.ts +226 -457
- package/src/pagination/paginators/MessagePaginator.ts +135 -175
- package/src/pagination/paginators/PinnedMessagePaginator.ts +13 -38
- package/src/pagination/paginators/ReminderPaginator.ts +12 -15
- package/src/pagination/paginators/ThreadPaginator.ts +16 -26
- package/src/pagination/paginators/UserGroupPaginator.ts +6 -17
- package/src/pagination/paginators/stateThrottling.ts +5 -10
- package/src/pagination/sortCompiler.ts +23 -50
- package/src/pagination/utility.normalization.ts +8 -30
- package/src/pagination/utility.search.ts +4 -11
- package/src/poll.ts +19 -19
- package/src/poll_manager.ts +16 -20
- package/src/poll_optimistic_votes.ts +17 -22
- package/src/reminders/Reminder.ts +5 -6
- package/src/reminders/ReminderManager.ts +9 -34
- package/src/reminders/ReminderTimer.ts +1 -2
- package/src/search/BaseSearchSource.ts +14 -29
- package/src/search/ChannelSearchSource.ts +8 -8
- package/src/search/MessageSearchSource.ts +19 -25
- package/src/search/SearchController.ts +18 -24
- package/src/search/types.ts +6 -10
- package/src/segment.ts +1 -1
- package/src/signing.ts +23 -3
- package/src/thread.ts +72 -173
- package/src/thread_manager.ts +59 -76
- package/src/token_manager.ts +11 -21
- package/src/types.ts +78 -126
- package/src/types.utility.ts +3 -3
- package/src/upload-utils.ts +5 -10
- package/src/uploadManager.ts +22 -54
- package/src/utils/FixedSizeQueueCache.ts +13 -21
- package/src/utils/WithSubscriptions.ts +5 -15
- package/src/utils/concurrency.ts +16 -55
- package/src/utils/mergeWith/mergeWith.ts +10 -13
- package/src/utils/mergeWith/mergeWithCore.ts +24 -81
- package/src/utils/mergeWith/mergeWithDiff.ts +15 -33
- package/src/utils/objectPath.ts +6 -41
- package/src/utils/retryable.ts +10 -14
- package/src/utils/throttling/throttle.ts +9 -25
- package/src/utils/time.ts +26 -66
- package/src/utils.ts +72 -128
|
@@ -10,8 +10,8 @@ export type MinimumUploadRequestResult = { file: string; thumb_url?: string } &
|
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Optional second argument to `UploadRequestFn`.
|
|
13
|
-
* - Call `onProgress` to report 0
|
|
14
|
-
* - Forward `abortSignal` to your upload
|
|
13
|
+
* - Call `onProgress` to report 0 to 100, or `undefined` when indeterminate.
|
|
14
|
+
* - Forward `abortSignal` to your upload to cancel it when the attachment is deleted mid-upload.
|
|
15
15
|
*/
|
|
16
16
|
export type UploadRequestOptions = {
|
|
17
17
|
onProgress?: (percent: number | undefined) => void;
|
|
@@ -30,7 +30,7 @@ export type DraftsConfiguration = {
|
|
|
30
30
|
export type TextComposerConfig = {
|
|
31
31
|
/** If false, the text input, change and selection events are disabled */
|
|
32
32
|
enabled: boolean;
|
|
33
|
-
/** If true, triggers typing events on text input keystroke.
|
|
33
|
+
/** If true, triggers typing events on text input keystroke. Defaults to `true`. */
|
|
34
34
|
publishTypingEvents: boolean;
|
|
35
35
|
/** Default value for the message input */
|
|
36
36
|
defaultValue?: string;
|
|
@@ -65,66 +65,53 @@ export type CommandsConfig = {
|
|
|
65
65
|
|
|
66
66
|
export type AttachmentManagerConfig = {
|
|
67
67
|
/**
|
|
68
|
-
*
|
|
69
|
-
*
|
|
68
|
+
* Toggles file attachments. ANDed with the channel config's `uploads` unless `customCdn` is set.
|
|
69
|
+
* Defaults to `true`.
|
|
70
70
|
*/
|
|
71
71
|
enabled: boolean;
|
|
72
72
|
// todo: document removal of noFiles prop showing how to achieve the same with custom fileUploadFilter function
|
|
73
|
-
/**
|
|
74
|
-
* Function that allows to prevent uploading files based on the functions output.
|
|
75
|
-
* Use this option to simulate deprecated prop noFiles which was actually a filter to upload only image files.
|
|
76
|
-
*/
|
|
73
|
+
/** Prevents uploading a file when it returns `false`. */
|
|
77
74
|
fileUploadFilter: FileUploadFilter;
|
|
78
75
|
/** Maximum number of attachments allowed per message */
|
|
79
76
|
maxNumberOfFilesPerMessage: number;
|
|
80
77
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
78
|
+
* File types or unique file type specifiers
|
|
79
|
+
* (https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/accept#unique_file_type_specifiers)
|
|
80
|
+
* allowed for selection. Empty means all files.
|
|
83
81
|
*/
|
|
84
82
|
acceptedFiles: string[];
|
|
85
83
|
/** Function that allows to customize the upload request. */
|
|
86
84
|
doUploadRequest?: UploadRequestFn;
|
|
87
85
|
/**
|
|
88
|
-
* Whether a custom {@link AttachmentManagerConfig.doUploadRequest} stores files
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* custom one that still posts to Stream, such as a wrapper adding retries or headers, or a proxy
|
|
93
|
-
* through your own backend. Stream's rules then govern attachments: the `upload-file` capability and
|
|
94
|
-
* the channel type's `uploads` flag.
|
|
95
|
-
*
|
|
96
|
-
* Set it to `true` when the bytes never reach Stream. Stream has no say over storage it does not host,
|
|
97
|
-
* so neither rule applies and the feature is governed by {@link AttachmentManagerConfig.enabled} alone.
|
|
98
|
-
*
|
|
99
|
-
* Declared rather than inferred from the presence of `doUploadRequest`, because supplying an upload
|
|
100
|
-
* function says *how* files are sent, not *where* — and treating it as a destination waived Stream's
|
|
101
|
-
* constraints for integrators who were still uploading to Stream.
|
|
86
|
+
* Whether a custom {@link AttachmentManagerConfig.doUploadRequest} stores files outside Stream.
|
|
87
|
+
* When `false`, Stream's rules apply (the `upload-file` capability and the channel type's
|
|
88
|
+
* `uploads` flag). When `true`, only {@link AttachmentManagerConfig.enabled} governs uploads.
|
|
89
|
+
* Defaults to `false`.
|
|
102
90
|
*/
|
|
103
91
|
customCdn: boolean;
|
|
104
92
|
/**
|
|
105
|
-
* When `true`, a message may be sent while its attachments are still uploading
|
|
106
|
-
*
|
|
107
|
-
*
|
|
93
|
+
* When `true`, a message may be sent while its attachments are still uploading. The message is
|
|
94
|
+
* composed and shown right away, and the send request waits for those uploads to settle before
|
|
95
|
+
* it goes out; if one of them fails, the whole message fails. Defaults to `false`.
|
|
108
96
|
*/
|
|
109
97
|
pendingUploadsEnabled: boolean;
|
|
110
98
|
/**
|
|
111
99
|
* When `true`, the attachment manager sets `localMetadata.uploadProgress` and passes
|
|
112
100
|
* `options.onProgress` to `doUploadRequest` (built-in and custom). Set to `false` to disable
|
|
113
|
-
* progress tracking
|
|
101
|
+
* progress tracking. Defaults to `true`.
|
|
114
102
|
*/
|
|
115
103
|
trackUploadProgress: boolean;
|
|
116
104
|
};
|
|
117
105
|
|
|
118
106
|
export type LinkPreviewsManagerConfig = {
|
|
119
|
-
/**
|
|
107
|
+
/**
|
|
108
|
+
* Number of milliseconds to debounce firing the URL enrichment queries when typing. Defaults to
|
|
109
|
+
* `1500`.
|
|
110
|
+
*/
|
|
120
111
|
debounceURLEnrichmentMs: number;
|
|
121
112
|
/**
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
* ANDed with the channel type's `url_enrichment`, so previews appear only where the server will
|
|
125
|
-
* actually enrich the message. `true` is the default for the same reason every other server-gated
|
|
126
|
-
* feature uses it: it means "no opinion — let the server decide". A `false` default double-gated the
|
|
127
|
-
* feature, leaving it off even where the server had enabled it.
|
|
113
|
+
* Toggles URL enrichment and link previews. ANDed with the channel type's `url_enrichment`.
|
|
114
|
+
* Defaults to `true`.
|
|
128
115
|
*/
|
|
129
116
|
enabled: boolean;
|
|
130
117
|
/** Custom function to identify URLs in a string and request OG data */
|
|
@@ -135,47 +122,33 @@ export type LinkPreviewsManagerConfig = {
|
|
|
135
122
|
|
|
136
123
|
export type LocationComposerConfig = {
|
|
137
124
|
/**
|
|
138
|
-
*
|
|
139
|
-
*
|
|
125
|
+
* Toggles location sharing. ANDed with the channel config's `shared_locations`. Defaults to
|
|
126
|
+
* `true`.
|
|
140
127
|
*/
|
|
141
128
|
enabled: boolean;
|
|
142
129
|
/** Function that provides a stable ID for the device from which the location is shared. */
|
|
143
130
|
getDeviceId: () => string;
|
|
144
|
-
/**
|
|
145
|
-
* Shortest live-location duration accepted as valid (defaults to 60s). A shorter `durationMs` makes
|
|
146
|
-
* the composed location invalid rather than clamping it, so this is a product decision about the
|
|
147
|
-
* minimum useful sharing window — not a protocol limit.
|
|
148
|
-
*/
|
|
131
|
+
/** Shortest live-location duration in ms. A shorter `durationMs` is invalid. Defaults to 60s. */
|
|
149
132
|
minShareDurationMs: number;
|
|
150
133
|
};
|
|
151
134
|
|
|
152
135
|
export type PollComposerConfig = {
|
|
153
|
-
/**
|
|
154
|
-
* Allows for toggling poll composition (defaults to `true`). The feature also has to be enabled at the
|
|
155
|
-
* channel-level config via `polls`; the two are ANDed, so either side can switch it off.
|
|
156
|
-
*/
|
|
136
|
+
/** Toggles poll composition. ANDed with the channel config's `polls`. Defaults to `true`. */
|
|
157
137
|
enabled: boolean;
|
|
158
138
|
};
|
|
159
139
|
|
|
160
140
|
export type MessageComposerConfig = {
|
|
161
141
|
/** If true, enables creating drafts on the server */
|
|
162
142
|
drafts: DraftsConfiguration;
|
|
163
|
-
/** Configuration for command sendability validation */
|
|
164
143
|
commands: CommandsConfig;
|
|
165
|
-
/** Configuration for the attachment manager */
|
|
166
144
|
attachments: AttachmentManagerConfig;
|
|
167
|
-
/** Configuration for the link previews manager */
|
|
168
145
|
linkPreviews: LinkPreviewsManagerConfig;
|
|
169
|
-
/** Configuration for the location composer */
|
|
170
146
|
location: LocationComposerConfig;
|
|
171
|
-
/** Configuration for the poll composer */
|
|
172
147
|
polls: PollComposerConfig;
|
|
173
148
|
/**
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
* retaining for a poll message, which carries no text or attachments of its own.
|
|
149
|
+
* Whether submitting keeps the composer's contents instead of clearing them (also leaving unresolved
|
|
150
|
+
* uploads in place). Defaults to retaining for a poll message.
|
|
177
151
|
*/
|
|
178
152
|
retainCompositionOnSubmit: (composer: MessageComposer) => boolean;
|
|
179
|
-
/** Maximum number of characters in a message */
|
|
180
153
|
text: TextComposerConfig;
|
|
181
154
|
};
|
|
@@ -90,7 +90,7 @@ export const ensureIsLocalAttachment = (
|
|
|
90
90
|
if (isLocalAttachment(attachment)) {
|
|
91
91
|
return attachment;
|
|
92
92
|
}
|
|
93
|
-
// local
|
|
93
|
+
// Not local yet: a local attachment is one whose `localMetadata` has an `id`.
|
|
94
94
|
const { localMetadata, ...rest } = attachment as LocalAttachment;
|
|
95
95
|
return {
|
|
96
96
|
localMetadata: {
|
|
@@ -11,14 +11,14 @@ export type LinkPreview = OGAttachment & {
|
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
export interface ILinkPreviewsManager {
|
|
14
|
-
/**
|
|
14
|
+
/** Cancels all scheduled or in-progress URL enrichment queries. */
|
|
15
15
|
cancelURLEnrichment: () => void;
|
|
16
|
-
/**
|
|
16
|
+
/** Searches the text for URLs and enriches them. */
|
|
17
17
|
findAndEnrichUrls?: DebouncedFunc<(text: string) => void>;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export enum LinkPreviewStatus {
|
|
21
|
-
/** Link preview has been dismissed
|
|
21
|
+
/** Link preview has been dismissed (`dismissPreview`). */
|
|
22
22
|
DISMISSED = 'dismissed',
|
|
23
23
|
/** Link preview could not be loaded, the enrichment request has failed. */
|
|
24
24
|
FAILED = 'failed',
|
|
@@ -69,11 +69,6 @@ const initState = ({
|
|
|
69
69
|
previews: new Map<LinkURL, LinkPreview>(),
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
-
/*
|
|
73
|
-
docs:
|
|
74
|
-
You can customize function to identify URLs in a string and request OG data by overriding findURLFn?: (text: string) => string[];
|
|
75
|
-
*/
|
|
76
|
-
|
|
77
72
|
export class LinkPreviewsManager implements ILinkPreviewsManager {
|
|
78
73
|
findAndEnrichUrls: DebouncedFunc<(text: string) => void>;
|
|
79
74
|
readonly state: StateStore<LinkPreviewsManagerState>;
|
|
@@ -160,11 +155,8 @@ export class LinkPreviewsManager implements ILinkPreviewsManager {
|
|
|
160
155
|
}
|
|
161
156
|
|
|
162
157
|
set enabled(enabled: LinkPreviewsManagerConfig['enabled']) {
|
|
163
|
-
// No early return
|
|
164
|
-
//
|
|
165
|
-
// was currently masking recorded nothing, and the earlier request stayed in the patch layer to be
|
|
166
|
-
// honoured the moment the server relented. `ConfigController.write` already skips a publish when the
|
|
167
|
-
// resolved value does not move, which is the same guard applied to the right value.
|
|
158
|
+
// No same-value early return: the getter reads the effective value, and a request the server
|
|
159
|
+
// masks must still be recorded.
|
|
168
160
|
this.composer.updateConfig({ linkPreviews: { enabled } });
|
|
169
161
|
}
|
|
170
162
|
|
|
@@ -222,7 +214,7 @@ export class LinkPreviewsManager implements ILinkPreviewsManager {
|
|
|
222
214
|
const newLinkPreviews = urls
|
|
223
215
|
.filter((url) => {
|
|
224
216
|
const existingPreviews = this.previews;
|
|
225
|
-
//
|
|
217
|
+
// The back-end may add a trailing slash.
|
|
226
218
|
const existingPreviewLink =
|
|
227
219
|
existingPreviews.get(url) || existingPreviews.get(url + '/');
|
|
228
220
|
return !existingPreviewLink;
|
|
@@ -248,7 +240,7 @@ export class LinkPreviewsManager implements ILinkPreviewsManager {
|
|
|
248
240
|
url: linkPreview.og_scrape_url,
|
|
249
241
|
});
|
|
250
242
|
if (this.shouldDiscardEnrichQueries) return;
|
|
251
|
-
//
|
|
243
|
+
// The URL may have left the store while typing.
|
|
252
244
|
if (this.previews.has(linkPreview.og_scrape_url)) {
|
|
253
245
|
this.updatePreview(linkPreview.og_scrape_url, {
|
|
254
246
|
status: LinkPreviewStatus.LOADED,
|
|
@@ -272,15 +264,11 @@ export class LinkPreviewsManager implements ILinkPreviewsManager {
|
|
|
272
264
|
this.findAndEnrichUrls.flush?.();
|
|
273
265
|
};
|
|
274
266
|
|
|
275
|
-
/**
|
|
276
|
-
* Clears all non-dismissed previews when the text composer is cleared.
|
|
277
|
-
* This ensures that dismissed previews are not re-enriched in the future.
|
|
278
|
-
*/
|
|
267
|
+
/** Clears all previews except dismissed ones, so those are not re-enriched. */
|
|
279
268
|
clearPreviews = () => {
|
|
280
269
|
const currentPreviews = this.previews;
|
|
281
270
|
const newPreviews = new Map<LinkURL, LinkPreview>();
|
|
282
271
|
|
|
283
|
-
// Keep only dismissed previews
|
|
284
272
|
currentPreviews.forEach((preview, url) => {
|
|
285
273
|
if (LinkPreviewsManager.previewIsDismissed(preview)) {
|
|
286
274
|
newPreviews.set(url, preview);
|