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
|
@@ -24,347 +24,198 @@ export type PrepareBatchDBQueries =
|
|
|
24
24
|
| [string]
|
|
25
25
|
| [string, Array<unknown> | Array<Array<unknown>>];
|
|
26
26
|
|
|
27
|
-
/**
|
|
28
|
-
* Options to insert a reaction into a message.
|
|
29
|
-
*/
|
|
30
27
|
export type DBInsertReactionType = {
|
|
31
|
-
/** MessageRequest to which the reaction is applied. */
|
|
32
28
|
message: MessageResponse | LocalMessage;
|
|
33
|
-
/** The reaction to insert. */
|
|
34
29
|
reaction: ReactionResponse;
|
|
35
|
-
/** Whether to immediately execute the operation. */
|
|
36
30
|
execute?: boolean;
|
|
37
31
|
};
|
|
38
32
|
|
|
39
|
-
/**
|
|
40
|
-
* Options to upsert channel IDs associated with a query.
|
|
41
|
-
*/
|
|
42
33
|
export type DBUpsertCidsForQueryType = {
|
|
43
|
-
/** Array of channel IDs. */
|
|
44
34
|
cids: string[];
|
|
45
|
-
/** Optional filters for the channels. */
|
|
46
35
|
filters?: ChannelFilters;
|
|
47
|
-
/** Optional full query options for the channels. */
|
|
48
36
|
options?: ChannelOptions;
|
|
49
|
-
/** Whether to immediately execute the operation. */
|
|
50
37
|
execute?: boolean;
|
|
51
38
|
/**
|
|
52
|
-
* The predefined-filter metadata the backend resolved for this query, stored
|
|
53
|
-
*
|
|
54
|
-
*
|
|
39
|
+
* The predefined-filter metadata the backend resolved for this query, stored with the cid order
|
|
40
|
+
* so a cache-seeded list sorts and matches by the same rule. Absent for a plain
|
|
41
|
+
* `filter_conditions` query, which clears any stored metadata.
|
|
55
42
|
*/
|
|
56
43
|
predefinedFilter?: ParsedPredefinedFilterResponse;
|
|
57
|
-
/** Optional sorting applied to the channels. */
|
|
58
44
|
sort?: SortParamRequest[];
|
|
59
45
|
};
|
|
60
46
|
|
|
61
|
-
/**
|
|
62
|
-
* Options to upsert multiple channels.
|
|
63
|
-
*/
|
|
64
47
|
export type DBUpsertChannelsType = {
|
|
65
|
-
/** Array of channel API responses. */
|
|
66
48
|
channels: ChannelStateResponseFields[];
|
|
67
|
-
/** Whether to immediately execute the operation. */
|
|
68
49
|
execute?: boolean;
|
|
69
50
|
/** If true, marks that the latest messages are already set. */
|
|
70
51
|
isLatestMessagesSet?: boolean;
|
|
71
52
|
};
|
|
72
53
|
|
|
73
|
-
/**
|
|
74
|
-
* Options to upsert application settings for a user.
|
|
75
|
-
*/
|
|
76
54
|
export type DBUpsertAppSettingsType = {
|
|
77
|
-
/** App settings data. */
|
|
78
55
|
appSettings: GetApplicationResponse;
|
|
79
|
-
/** ID of the user the settings belong to. */
|
|
80
56
|
userId: string;
|
|
81
|
-
/** Whether to immediately execute the operation. */
|
|
82
57
|
execute?: boolean;
|
|
83
58
|
};
|
|
84
59
|
|
|
85
|
-
/**
|
|
86
|
-
* Sync status information for a user.
|
|
87
|
-
*/
|
|
88
60
|
export type DBUpsertUserSyncStatusType = {
|
|
89
|
-
/** ID of the user. */
|
|
90
61
|
userId: string;
|
|
91
|
-
/**
|
|
62
|
+
/** A date string `new Date()` can parse. */
|
|
92
63
|
lastSyncedAt: string;
|
|
93
|
-
/** Whether to immediately execute the operation. */
|
|
94
64
|
execute?: boolean;
|
|
95
65
|
};
|
|
96
66
|
|
|
97
|
-
/**
|
|
98
|
-
* Options to upsert a poll.
|
|
99
|
-
*/
|
|
100
67
|
export type DBUpsertPollType = {
|
|
101
|
-
/** Poll data to be stored. */
|
|
102
68
|
poll: PollResponseData;
|
|
103
|
-
/** Whether to immediately execute the operation. */
|
|
104
69
|
execute?: boolean;
|
|
105
70
|
};
|
|
106
71
|
|
|
107
|
-
/**
|
|
108
|
-
* Options to upsert individual channel data.
|
|
109
|
-
*/
|
|
110
72
|
export type DBUpsertChannelDataType = {
|
|
111
|
-
/** Channel data. */
|
|
112
73
|
channel: ChannelResponse;
|
|
113
|
-
/** Whether to immediately execute the operation. */
|
|
114
74
|
execute?: boolean;
|
|
115
75
|
};
|
|
116
76
|
|
|
117
|
-
/**
|
|
118
|
-
* Options to upsert read statuses for a channel.
|
|
119
|
-
*/
|
|
120
77
|
export type DBUpsertReadsType = {
|
|
121
|
-
/** Channel ID. */
|
|
122
78
|
cid: string;
|
|
123
|
-
/** Array of read statuses. */
|
|
124
79
|
reads: ReadStateResponse[];
|
|
125
|
-
/** Whether to immediately execute the operation. */
|
|
126
80
|
execute?: boolean;
|
|
127
81
|
};
|
|
128
82
|
|
|
129
|
-
/**
|
|
130
|
-
* Options to upsert multiple messages.
|
|
131
|
-
*/
|
|
132
83
|
export type DBUpsertMessagesType = {
|
|
133
|
-
/** Array of message responses. */
|
|
134
84
|
messages: MessageResponse[];
|
|
135
|
-
/** Whether to immediately execute the operation. */
|
|
136
85
|
execute?: boolean;
|
|
137
86
|
};
|
|
138
87
|
|
|
139
|
-
/**
|
|
140
|
-
* Options to upsert members in a channel.
|
|
141
|
-
*/
|
|
142
88
|
export type DBUpsertMembersType = {
|
|
143
|
-
/** Channel ID. */
|
|
144
89
|
cid: string;
|
|
145
|
-
/** Array of channel members. */
|
|
146
90
|
members: ChannelMemberResponse[];
|
|
147
|
-
/** Whether to immediately execute the operation. */
|
|
148
91
|
execute?: boolean;
|
|
149
92
|
};
|
|
150
93
|
|
|
151
|
-
/**
|
|
152
|
-
* Options to update a reaction.
|
|
153
|
-
*/
|
|
154
94
|
export type DBUpdateReactionType = {
|
|
155
|
-
/** MessageRequest associated with the reaction. */
|
|
156
95
|
message: MessageResponse | LocalMessage;
|
|
157
|
-
/** The updated reaction. */
|
|
158
96
|
reaction: ReactionResponse;
|
|
159
|
-
/** Whether to immediately execute the operation. */
|
|
160
97
|
execute?: boolean;
|
|
161
98
|
};
|
|
162
99
|
|
|
163
|
-
/**
|
|
164
|
-
* Options to update a message.
|
|
165
|
-
*/
|
|
166
100
|
export type DBUpdateMessageType = {
|
|
167
|
-
/** MessageRequest to update. */
|
|
168
101
|
message: MessageResponse | LocalMessage;
|
|
169
|
-
/** Whether to immediately execute the operation. */
|
|
170
102
|
execute?: boolean;
|
|
171
103
|
};
|
|
172
104
|
|
|
173
|
-
/**
|
|
174
|
-
* Options to get channels by their IDs.
|
|
175
|
-
*/
|
|
176
105
|
export type DBGetChannelsType = {
|
|
177
|
-
/** Array of channel IDs. */
|
|
178
106
|
cids: string[];
|
|
179
|
-
/** ID of the user. */
|
|
180
107
|
userId: string;
|
|
181
108
|
};
|
|
182
109
|
|
|
183
|
-
/**
|
|
184
|
-
* Options to get channels based on filters.
|
|
185
|
-
*/
|
|
186
110
|
export type DBGetChannelsForQueryType = {
|
|
187
|
-
/** ID of the user. */
|
|
188
111
|
userId: string;
|
|
189
|
-
/** Optional filters for channels. */
|
|
190
112
|
options?: QueryChannelsRequest;
|
|
191
113
|
};
|
|
192
114
|
|
|
193
115
|
/**
|
|
194
|
-
* A cached channel query:
|
|
195
|
-
* produced that order.
|
|
196
|
-
* the order without the rule is what lets a cache-seeded list sort and match by the wrong one.
|
|
116
|
+
* A cached channel query: its channels in query order, and the predefined-filter metadata that
|
|
117
|
+
* produced that order. They are written as one cache row, so they are read together.
|
|
197
118
|
*/
|
|
198
119
|
export type DBGetChannelsForQueryResult = {
|
|
199
|
-
/** Channels in cached query order. */
|
|
200
120
|
channels: Omit<ChannelStateResponseFields, 'duration'>[];
|
|
201
|
-
/**
|
|
121
|
+
/** Set when the query was cached from a predefined-filter query. */
|
|
202
122
|
predefinedFilter?: ParsedPredefinedFilterResponse;
|
|
203
123
|
};
|
|
204
124
|
|
|
205
|
-
/**
|
|
206
|
-
* Payload for retrieving the last sync timestamp for a user.
|
|
207
|
-
*/
|
|
208
125
|
export type DBGetLastSyncedAtType = {
|
|
209
|
-
/** ID of the user. */
|
|
210
126
|
userId: string;
|
|
211
127
|
};
|
|
212
128
|
|
|
213
|
-
/**
|
|
214
|
-
* Options to fetch pending tasks for a specific message.
|
|
215
|
-
*/
|
|
216
129
|
export type DBGetPendingTasksType = {
|
|
217
|
-
/**
|
|
130
|
+
/** Returns only this message's tasks. */
|
|
218
131
|
messageId?: string;
|
|
219
132
|
};
|
|
220
133
|
|
|
221
|
-
/**
|
|
222
|
-
* Payload for retrieving application settings for a user.
|
|
223
|
-
*/
|
|
224
134
|
export type DBGetAppSettingsType = {
|
|
225
|
-
/** ID of the user. */
|
|
226
135
|
userId: string;
|
|
227
136
|
};
|
|
228
137
|
|
|
229
|
-
/**
|
|
230
|
-
* Options to retrieve reactions for a message.
|
|
231
|
-
*/
|
|
232
138
|
export type DBGetReactionsType = {
|
|
233
|
-
/** ID of the message. */
|
|
234
139
|
messageId: string;
|
|
235
|
-
/** Optional filter to apply to reactions. */
|
|
236
140
|
filters?: ReactionFilters;
|
|
237
|
-
/** Optional sorting for reactions. */
|
|
238
141
|
sort?: SortParamRequest[];
|
|
239
|
-
/** Optional maximum number of reactions to return. */
|
|
240
142
|
limit?: number;
|
|
241
143
|
};
|
|
242
144
|
|
|
243
|
-
/**
|
|
244
|
-
* Payload for deleting a pending task by ID.
|
|
245
|
-
*/
|
|
246
145
|
export type DBDeletePendingTaskType = {
|
|
247
|
-
/** ID of the pending task. */
|
|
248
146
|
id: number;
|
|
249
147
|
};
|
|
250
148
|
|
|
251
|
-
/**
|
|
252
|
-
* Payload for updating a pending task by ID.
|
|
253
|
-
*/
|
|
254
149
|
export type DBUpdatePendingTaskType = {
|
|
255
|
-
/** ID of the pending task. */
|
|
256
150
|
id: number;
|
|
257
|
-
/** The next task payload to persist. */
|
|
258
151
|
task: PendingTask;
|
|
259
152
|
};
|
|
260
153
|
|
|
261
|
-
/**
|
|
262
|
-
* Options to delete a reaction from a message.
|
|
263
|
-
*/
|
|
264
154
|
export type DBDeleteReactionType = {
|
|
265
|
-
/** The reaction to delete. */
|
|
266
155
|
reaction: ReactionResponse;
|
|
267
|
-
/** Optional message associated with the reaction. */
|
|
268
156
|
message?: MessageResponse | LocalMessage;
|
|
269
|
-
/** Whether to immediately execute the operation. */
|
|
270
157
|
execute?: boolean;
|
|
271
158
|
};
|
|
272
159
|
|
|
273
|
-
/**
|
|
274
|
-
* Options to delete a channel member.
|
|
275
|
-
*/
|
|
276
160
|
export type DBDeleteMemberType = {
|
|
277
|
-
/** Channel ID. */
|
|
278
161
|
cid: string;
|
|
279
|
-
/** Member to remove. */
|
|
280
162
|
member: ChannelMemberResponse;
|
|
281
|
-
/** Whether to immediately execute the operation. */
|
|
282
163
|
execute?: boolean;
|
|
283
164
|
};
|
|
284
165
|
|
|
285
|
-
/**
|
|
286
|
-
* Options to drop all pending tasks for a message.
|
|
287
|
-
*/
|
|
288
166
|
export type DBDropPendingTasksType = {
|
|
289
|
-
/** ID of the message. */
|
|
290
167
|
messageId: string;
|
|
291
|
-
/** Whether to immediately execute the operation. */
|
|
292
168
|
execute?: boolean;
|
|
293
169
|
};
|
|
294
170
|
|
|
295
|
-
/**
|
|
296
|
-
* Options to delete a message.
|
|
297
|
-
*/
|
|
298
171
|
export type DBDeleteMessageType = {
|
|
299
|
-
/** ID of the message. */
|
|
300
172
|
id: string;
|
|
301
|
-
/**
|
|
173
|
+
/** Delete for the current user only. */
|
|
302
174
|
deleteForMe?: boolean;
|
|
303
|
-
/** Whether to immediately execute the operation. */
|
|
304
175
|
execute?: boolean;
|
|
305
176
|
};
|
|
306
177
|
|
|
307
|
-
/**
|
|
308
|
-
* Options to delete a channel.
|
|
309
|
-
*/
|
|
310
178
|
export type DBDeleteChannelType = {
|
|
311
|
-
/** Channel ID. */
|
|
312
179
|
cid: string;
|
|
313
|
-
/** Whether to immediately execute the operation. */
|
|
314
180
|
execute?: boolean;
|
|
315
181
|
};
|
|
316
182
|
|
|
317
|
-
/**
|
|
318
|
-
* Options to delete messages in a channel.
|
|
319
|
-
*/
|
|
320
183
|
export type DBDeleteMessagesForChannelType = {
|
|
321
|
-
/** Channel ID. */
|
|
322
184
|
cid: string;
|
|
323
|
-
/**
|
|
324
|
-
/** Unix nanoseconds, as the API sends it. */
|
|
185
|
+
/** Messages before this timestamp are deleted (unix nanoseconds, as the API sends it). */
|
|
325
186
|
truncated_at?: TimestampNS;
|
|
326
|
-
/** Whether to immediately execute the operation. */
|
|
327
187
|
execute?: boolean;
|
|
328
188
|
};
|
|
329
189
|
|
|
330
|
-
/**
|
|
331
|
-
* Payload for checking whether a channel exists by ID.
|
|
332
|
-
*/
|
|
333
190
|
export type DBChannelExistsType = {
|
|
334
|
-
/** Channel ID. */
|
|
335
191
|
cid: string;
|
|
336
192
|
};
|
|
337
193
|
|
|
338
194
|
export type DBUpsertDraftType = {
|
|
339
|
-
/** Draft message to upsert. */
|
|
340
195
|
draft: DraftResponse;
|
|
341
|
-
/** Whether to immediately execute the operation. */
|
|
342
196
|
execute?: boolean;
|
|
343
197
|
};
|
|
344
198
|
|
|
345
199
|
export type DBGetDraftType = {
|
|
346
|
-
/** Channel ID for which to get the draft. */
|
|
347
200
|
cid: string;
|
|
348
|
-
/** ID of the user requesting the draft. */
|
|
349
201
|
userId: string;
|
|
350
|
-
/**
|
|
202
|
+
/** The thread's parent message ID, for a thread draft. */
|
|
351
203
|
parent_id?: string;
|
|
352
204
|
};
|
|
353
205
|
|
|
354
206
|
export type DBDeleteDraftType = {
|
|
355
|
-
/** Channel ID for which to delete the draft. */
|
|
356
207
|
cid: string;
|
|
357
|
-
/**
|
|
208
|
+
/** The thread's parent message ID, for a thread draft. */
|
|
358
209
|
parent_id?: string;
|
|
359
|
-
/** Whether to immediately execute the operation. */
|
|
360
210
|
execute?: boolean;
|
|
361
211
|
};
|
|
362
212
|
|
|
363
|
-
/**
|
|
364
|
-
* Represents a list of batch SQL queries to be executed.
|
|
365
|
-
*/
|
|
366
213
|
export type ExecuteBatchDBQueriesType = PrepareBatchDBQueries[];
|
|
367
214
|
|
|
215
|
+
/**
|
|
216
|
+
* The storage contract. A member taking `execute` returns its prepared queries whether or not it
|
|
217
|
+
* already ran them.
|
|
218
|
+
*/
|
|
368
219
|
export interface OfflineDBApi {
|
|
369
220
|
insertReaction: (options: DBInsertReactionType) => Promise<ExecuteBatchDBQueriesType>;
|
|
370
221
|
upsertCidsForQuery: (
|
|
@@ -442,15 +293,12 @@ export type PendingTaskTypes = {
|
|
|
442
293
|
};
|
|
443
294
|
|
|
444
295
|
/**
|
|
445
|
-
* Every operation the offline queue can replay,
|
|
446
|
-
*
|
|
447
|
-
*
|
|
448
|
-
* derived from it, and `QUEUEABLE_OPERATIONS` has to supply a resolver for each key — so a new task
|
|
449
|
-
* type is a compile error until both its signature and its resolver exist, rather than a runtime
|
|
450
|
-
* "Tried to execute invalid pending task type" the first time somebody queues one.
|
|
296
|
+
* Every operation the offline queue can replay, as the method that performs it. `PendingTask` is
|
|
297
|
+
* derived from it and `QUEUEABLE_OPERATIONS` needs an entry per key, so a new task type does not
|
|
298
|
+
* compile until both exist.
|
|
451
299
|
*
|
|
452
|
-
* Each
|
|
453
|
-
*
|
|
300
|
+
* Each method only sends the request (a queueing one would re-queue on replay), hence the drafts'
|
|
301
|
+
* `_`-prefixed forms.
|
|
454
302
|
*
|
|
455
303
|
* @internal
|
|
456
304
|
*/
|
|
@@ -467,7 +315,7 @@ export type QueueableOperationSignatures = {
|
|
|
467
315
|
export type QueueableType = keyof QueueableOperationSignatures;
|
|
468
316
|
|
|
469
317
|
/**
|
|
470
|
-
* The argument list of a queueable operation
|
|
318
|
+
* The argument list of a queueable operation, which a task carries as its `payload`.
|
|
471
319
|
*
|
|
472
320
|
* @internal
|
|
473
321
|
*/
|
|
@@ -475,19 +323,12 @@ export type QueueablePayload<T extends QueueableType> = Parameters<
|
|
|
475
323
|
QueueableOperationSignatures[T]
|
|
476
324
|
>;
|
|
477
325
|
|
|
478
|
-
/**
|
|
479
|
-
* What a queueable operation resolves with.
|
|
480
|
-
*
|
|
481
|
-
* @internal
|
|
482
|
-
*/
|
|
326
|
+
/** @internal */
|
|
483
327
|
export type QueueableResult<T extends QueueableType> = Awaited<
|
|
484
328
|
ReturnType<QueueableOperationSignatures[T]>
|
|
485
329
|
>;
|
|
486
330
|
|
|
487
|
-
/**
|
|
488
|
-
* A queued request: which operation, and the arguments to replay it with. The payload is the argument
|
|
489
|
-
* list of the method named in {@link QueueableOperationSignatures}, so the two cannot drift.
|
|
490
|
-
*/
|
|
331
|
+
/** A queued request: the operation and the arguments to replay it with. */
|
|
491
332
|
export type PendingTask = {
|
|
492
333
|
channelId?: string;
|
|
493
334
|
channelType?: string;
|
|
@@ -498,11 +339,7 @@ export type PendingTask = {
|
|
|
498
339
|
[T in QueueableType]: { payload: QueueablePayload<T>; type: T };
|
|
499
340
|
}[QueueableType];
|
|
500
341
|
|
|
501
|
-
/**
|
|
502
|
-
* A task narrowed to one operation.
|
|
503
|
-
*
|
|
504
|
-
* @internal
|
|
505
|
-
*/
|
|
342
|
+
/** @internal */
|
|
506
343
|
export type PendingTaskOf<T extends QueueableType> = Extract<PendingTask, { type: T }>;
|
|
507
344
|
|
|
508
345
|
export type OfflineErrorType = 'connection:lost';
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* it dedupes content across collections and fans changes out to every holder; backed by a private
|
|
6
|
-
* store (the default, owner-less mode) it behaves as a plain per-instance index. Keeping this as an
|
|
7
|
-
* interface lets `BasePaginator` stay agnostic to which backing a given paginator uses.
|
|
8
|
-
*
|
|
9
|
-
* @template T The domain item type managed by the index.
|
|
2
|
+
* The CRUD surface a paginator relies on from its item index. The only implementation is
|
|
3
|
+
* `StoreBackedItemIndex`: on a shared client store it dedupes items across collections and fans
|
|
4
|
+
* changes out to every holder, on a private store it is a plain per-instance index.
|
|
10
5
|
*/
|
|
11
6
|
export interface ItemIndexApi<T> {
|
|
12
7
|
setMany(items: T[]): void;
|
|
@@ -17,9 +12,6 @@ export interface ItemIndexApi<T> {
|
|
|
17
12
|
clear(): void;
|
|
18
13
|
entries(): [string, T][];
|
|
19
14
|
values(): T[];
|
|
20
|
-
/**
|
|
21
|
-
* Runs `fn`, coalescing any change notifications it produces into a single flush. A private-store
|
|
22
|
-
* (owner-less) index has nothing to fan out and simply runs `fn`.
|
|
23
|
-
*/
|
|
15
|
+
/** Runs `fn`, coalescing the change notifications it produces into a single flush. */
|
|
24
16
|
batch<R>(fn: () => R): R;
|
|
25
17
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Interval, PaginationFlags } from '../paginators';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Flags for a page centred on a point (`id_around` / `created_at_around`). The server splits the
|
|
5
|
+
* limit evenly around the point and fills a side that runs out from the other, so on a full page a
|
|
6
|
+
* side with less than the smaller half is exhausted. A page shorter than the limit holds everything.
|
|
7
|
+
*/
|
|
8
|
+
export const deriveAroundPaginationFlags = ({
|
|
9
|
+
interval,
|
|
10
|
+
newerCount,
|
|
11
|
+
olderCount,
|
|
12
|
+
pageLength,
|
|
13
|
+
requestedPageSize,
|
|
14
|
+
}: {
|
|
15
|
+
interval: Interval;
|
|
16
|
+
newerCount: number;
|
|
17
|
+
olderCount: number;
|
|
18
|
+
pageLength: number;
|
|
19
|
+
requestedPageSize: number;
|
|
20
|
+
}): PaginationFlags => {
|
|
21
|
+
const isPageFull = pageLength >= requestedPageSize;
|
|
22
|
+
// The smaller half, so the odd slot the server gives either side does not matter.
|
|
23
|
+
const minShare = Math.floor((olderCount + newerCount) / 2);
|
|
24
|
+
// An interval already known to reach the dataset head or tail stays there.
|
|
25
|
+
return {
|
|
26
|
+
hasMoreHead: !interval.isHead && isPageFull && newerCount >= minShare,
|
|
27
|
+
hasMoreTail: !interval.isTail && isPageFull && olderCount >= minShare,
|
|
28
|
+
};
|
|
29
|
+
};
|
|
@@ -1,77 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { deriveAroundPaginationFlags } from './aroundPaginationFlags';
|
|
2
2
|
import { dateToNs } from '../../utils/time';
|
|
3
3
|
import type { TimestampNS } from '../../types';
|
|
4
|
-
import type {
|
|
5
|
-
import { ComparisonResult } from '../types.normalization';
|
|
4
|
+
import type { CursorDeriveContext, PaginationFlags } from '../paginators';
|
|
6
5
|
|
|
7
6
|
export const deriveCreatedAtAroundPaginationFlags = <
|
|
8
7
|
T extends { id: string; created_at: TimestampNS },
|
|
9
8
|
Q extends { created_at_around?: Date | string },
|
|
10
|
-
P extends BasePaginator<T, Q>,
|
|
11
9
|
>({
|
|
12
10
|
hasMoreHead,
|
|
13
11
|
hasMoreTail,
|
|
14
12
|
interval,
|
|
15
13
|
page,
|
|
16
|
-
paginator,
|
|
17
14
|
queryShape,
|
|
18
15
|
requestedPageSize,
|
|
19
|
-
}: CursorDeriveContext<T, Q>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
// `created_at_around` is a REQUEST field, so it is still a `Date` (or an ISO string). Items carry
|
|
23
|
-
// the wire unit, so bring the bound into that unit before comparing the two.
|
|
16
|
+
}: CursorDeriveContext<T, Q>): PaginationFlags => {
|
|
17
|
+
if (!queryShape?.created_at_around) return { hasMoreHead, hasMoreTail };
|
|
18
|
+
// The bound is a `Date` or ISO string but items carry nanoseconds: convert before comparing.
|
|
24
19
|
const createdAtAround = dateToNs(new Date(queryShape.created_at_around));
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
ComparisonResult.A_PRECEDES_B;
|
|
34
|
-
|
|
35
|
-
const requestedPageSizeNotMet =
|
|
36
|
-
requestedPageSize > interval.itemIds.length && requestedPageSize > page.length;
|
|
37
|
-
const noMoreMessages =
|
|
38
|
-
(requestedPageSize > interval.itemIds.length ||
|
|
39
|
-
interval.itemIds.length >= page.length) &&
|
|
40
|
-
requestedPageSize > page.length;
|
|
41
|
-
|
|
42
|
-
if (isAboveHeadBound) {
|
|
43
|
-
flags.hasMoreHead = false;
|
|
44
|
-
if (requestedPageSizeNotMet) {
|
|
45
|
-
flags.hasMoreTail = false;
|
|
46
|
-
}
|
|
47
|
-
} else if (isBelowTailBound) {
|
|
48
|
-
flags.hasMoreTail = false;
|
|
49
|
-
if (requestedPageSizeNotMet) {
|
|
50
|
-
flags.hasMoreHead = false;
|
|
51
|
-
}
|
|
52
|
-
} else if (noMoreMessages) {
|
|
53
|
-
flags = { hasMoreHead: false, hasMoreTail: false };
|
|
54
|
-
} else {
|
|
55
|
-
const [firstPageMsgIsFirstInSet, lastPageMsgIsLastInSet] = [
|
|
56
|
-
firstPageItem?.id && firstPageItem.id === interval.itemIds[0],
|
|
57
|
-
lastPageItem?.id && lastPageItem.id === interval.itemIds.slice(-1)[0],
|
|
58
|
-
];
|
|
59
|
-
|
|
60
|
-
const midPointByCount = Math.floor(page.length / 2);
|
|
61
|
-
const { insertionIndex } = binarySearch({
|
|
62
|
-
needle: { created_at: createdAtAround } as T,
|
|
63
|
-
length: page.length,
|
|
64
|
-
getItemAt: (index) => page[index],
|
|
65
|
-
compare: (a, b) => a.created_at - b.created_at,
|
|
66
|
-
itemIdentityEquals: (a, b) => a.created_at === b.created_at,
|
|
67
|
-
plateauScan: false,
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
if (insertionIndex !== -1) {
|
|
71
|
-
if (firstPageMsgIsFirstInSet) flags.hasMoreTail = midPointByCount <= insertionIndex;
|
|
72
|
-
if (lastPageMsgIsLastInSet) flags.hasMoreHead = midPointByCount >= insertionIndex;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return flags;
|
|
20
|
+
const olderCount = page.filter((item) => item.created_at < createdAtAround).length;
|
|
21
|
+
return deriveAroundPaginationFlags({
|
|
22
|
+
interval,
|
|
23
|
+
newerCount: page.length - olderCount,
|
|
24
|
+
olderCount,
|
|
25
|
+
pageLength: page.length,
|
|
26
|
+
requestedPageSize,
|
|
27
|
+
});
|
|
77
28
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { deriveAroundPaginationFlags } from './aroundPaginationFlags';
|
|
1
2
|
import type { CursorDeriveContext, PaginationFlags } from '../paginators';
|
|
2
3
|
|
|
3
4
|
export const deriveIdAroundPaginationFlags = <
|
|
@@ -11,43 +12,14 @@ export const deriveIdAroundPaginationFlags = <
|
|
|
11
12
|
queryShape,
|
|
12
13
|
requestedPageSize,
|
|
13
14
|
}: CursorDeriveContext<T, Q>): PaginationFlags => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const midPoint = Math.floor(page.length / 2);
|
|
25
|
-
const noMoreMessages =
|
|
26
|
-
(requestedPageSize > interval.itemIds.length ||
|
|
27
|
-
interval.itemIds.length >= page.length) &&
|
|
28
|
-
requestedPageSize > page.length;
|
|
29
|
-
|
|
30
|
-
if (noMoreMessages) {
|
|
31
|
-
flags = { hasMoreHead: false, hasMoreTail: false };
|
|
32
|
-
} else if (!page[midPoint]) {
|
|
33
|
-
return flags;
|
|
34
|
-
} else if (page[midPoint].id === id_around) {
|
|
35
|
-
flags = { hasMoreHead: true, hasMoreTail: true };
|
|
36
|
-
} else {
|
|
37
|
-
const halves = [page.slice(0, midPoint), page.slice(midPoint)];
|
|
38
|
-
if (firstPageMsgIsFirstInSet) {
|
|
39
|
-
const targetMsg = halves[0].find((message) => message.id === id_around);
|
|
40
|
-
if (targetMsg) {
|
|
41
|
-
flags.hasMoreTail = false;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (lastPageMsgIsLastInSet) {
|
|
45
|
-
const targetMsg = halves[1].find((message) => message.id === id_around);
|
|
46
|
-
if (targetMsg) {
|
|
47
|
-
flags.hasMoreHead = false;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return flags;
|
|
15
|
+
const targetIndex = page.findIndex((item) => item.id === queryShape?.id_around);
|
|
16
|
+
// Without the target in the page, the page says nothing about where it sits.
|
|
17
|
+
if (!queryShape?.id_around || targetIndex === -1) return { hasMoreHead, hasMoreTail };
|
|
18
|
+
return deriveAroundPaginationFlags({
|
|
19
|
+
interval,
|
|
20
|
+
newerCount: page.length - 1 - targetIndex,
|
|
21
|
+
olderCount: targetIndex,
|
|
22
|
+
pageLength: page.length,
|
|
23
|
+
requestedPageSize,
|
|
24
|
+
});
|
|
53
25
|
};
|
|
@@ -2,9 +2,8 @@ import type { CursorDeriveContext, PaginationFlags } from '../paginators';
|
|
|
2
2
|
import type { MessagePaginationParams, TimestampNS } from '../../types';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* The query keys
|
|
6
|
-
*
|
|
7
|
-
* to it, and `offset` is present because the pinned-messages endpoint accepts one.
|
|
5
|
+
* The query keys understood when deriving a cursor direction. `MessagePaginationParams` and
|
|
6
|
+
* `PinnedMessagePaginationOptions` are both assignable to it (`offset` is for pinned messages).
|
|
8
7
|
*/
|
|
9
8
|
type LinearPaginationQueryShape = {
|
|
10
9
|
created_at_after?: Date;
|
|
@@ -85,9 +84,8 @@ export const deriveLinearPaginationFlags = <
|
|
|
85
84
|
typeof queriedMessagesTowardsTail !== 'undefined' ||
|
|
86
85
|
containsUnrecognizedOptionsOnly
|
|
87
86
|
) {
|
|
88
|
-
//
|
|
89
|
-
//
|
|
90
|
-
// to `false` and a subsequent full network first page can never restore it.
|
|
87
|
+
// A partial first page (e.g. an offline prehydrate) must not latch `hasMoreTail` to `false`:
|
|
88
|
+
// a later full network first page has to be able to restore it.
|
|
91
89
|
hasMoreTail = isFirstPage ? hasMore : !hasMoreTail ? false : hasMore;
|
|
92
90
|
}
|
|
93
91
|
if (typeof queriedMessagesTowardsHead !== 'undefined') {
|