stream-chat 9.50.2 → 10.0.0-rc.1
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 +18869 -13986
- package/dist/cjs/index.browser.js.map +4 -4
- package/dist/cjs/index.node.js +18888 -13992
- package/dist/cjs/index.node.js.map +4 -4
- package/dist/esm/index.mjs +18866 -13983
- package/dist/esm/index.mjs.map +4 -4
- package/dist/types/ChannelPaginatorsOrchestrator.d.ts +130 -0
- package/dist/types/EventHandlerPipeline.d.ts +104 -0
- package/dist/types/api-client.d.ts +26 -0
- package/dist/types/campaign.d.ts +0 -44
- package/dist/types/channel.d.ts +436 -480
- package/dist/types/channel_batch_updater.d.ts +0 -93
- package/dist/types/channel_manager.d.ts +8 -10
- package/dist/types/channel_state.d.ts +53 -201
- package/dist/types/client.d.ts +440 -1910
- package/dist/types/client_state.d.ts +4 -4
- package/dist/types/configuration/InstanceConfigurationService.d.ts +26 -0
- package/dist/types/configuration/index.d.ts +1 -0
- package/dist/types/configuration/types.d.ts +53 -0
- package/dist/types/connection.d.ts +49 -41
- package/dist/types/connection_fallback.d.ts +6 -4
- package/dist/types/constants.d.ts +0 -4
- package/dist/types/custom_types.d.ts +2 -0
- package/dist/types/errors.d.ts +2 -2
- package/dist/types/gen/chat/ChannelApi.d.ts +45 -0
- package/dist/types/gen/chat/ChatApi.d.ts +334 -0
- package/dist/types/gen/model-decoders/decoders.d.ts +3 -0
- package/dist/types/gen/model-decoders/event-decoder-mapping.d.ts +6 -0
- package/dist/types/gen/models/index.d.ts +8836 -0
- package/dist/types/gen/moderation/ModerationApi.d.ts +50 -0
- package/dist/types/gen-imports.d.ts +3 -0
- package/dist/types/index.d.ts +5 -5
- package/dist/types/insights.d.ts +7 -6
- package/dist/types/logger.d.ts +9 -0
- package/dist/types/messageComposer/LocationComposer.d.ts +7 -4
- package/dist/types/messageComposer/attachmentIdentity.d.ts +2 -2
- package/dist/types/messageComposer/attachmentManager.d.ts +8 -4
- package/dist/types/messageComposer/configuration/types.d.ts +11 -11
- package/dist/types/messageComposer/linkPreviewsManager.d.ts +25 -13
- package/dist/types/messageComposer/messageComposer.d.ts +10 -10
- package/dist/types/messageComposer/middleware/messageComposer/types.d.ts +3 -3
- package/dist/types/messageComposer/middleware/pollComposer/types.d.ts +4 -7
- package/dist/types/messageComposer/middleware/textComposer/commandUtils.d.ts +3 -3
- package/dist/types/messageComposer/middleware/textComposer/commands.d.ts +7 -7
- package/dist/types/messageComposer/middleware/textComposer/mentions.d.ts +218 -4
- package/dist/types/messageComposer/middleware/textComposer/types.d.ts +9 -4
- package/dist/types/messageComposer/pollComposer.d.ts +5 -4
- package/dist/types/messageComposer/textComposer.d.ts +8 -3
- package/dist/types/messageComposer/types.d.ts +6 -28
- package/dist/types/messageDelivery/MessageDeliveryReporter.d.ts +40 -25
- package/dist/types/messageDelivery/MessageReceiptsTracker.d.ts +53 -12
- package/dist/types/messageOperations/MessageOperationStatePolicy.d.ts +19 -0
- package/dist/types/messageOperations/MessageOperations.d.ts +17 -0
- package/dist/types/messageOperations/index.d.ts +3 -0
- package/dist/types/messageOperations/types.d.ts +49 -0
- package/dist/types/moderation.d.ts +21 -203
- package/dist/types/notifications/types.d.ts +8 -7
- package/dist/types/offline-support/offline_support_api.d.ts +110 -87
- package/dist/types/offline-support/types.d.ts +19 -23
- package/dist/types/offline-support/util.d.ts +4 -2
- package/dist/types/pagination/FilterBuilder.d.ts +1 -1
- package/dist/types/pagination/ItemIndex.d.ts +82 -0
- package/dist/types/pagination/cursorDerivation/createdAtAroundPaginationFlags.d.ts +9 -0
- package/dist/types/pagination/cursorDerivation/idAroundPaginationFlags.d.ts +6 -0
- package/dist/types/pagination/cursorDerivation/index.d.ts +1 -0
- package/dist/types/pagination/cursorDerivation/linearPaginationFlags.d.ts +6 -0
- package/dist/types/pagination/filterCompiler.d.ts +7 -0
- package/dist/types/pagination/index.d.ts +1 -3
- package/dist/types/pagination/paginators/BasePaginator.d.ts +709 -0
- package/dist/types/pagination/paginators/ChannelPaginator.d.ts +58 -0
- package/dist/types/pagination/paginators/MessageIntervalPaginator.d.ts +260 -0
- package/dist/types/pagination/paginators/MessagePaginator.d.ts +208 -0
- package/dist/types/pagination/paginators/PinnedMessagePaginator.d.ts +39 -0
- package/dist/types/pagination/paginators/ReminderPaginator.d.ts +19 -0
- package/dist/types/pagination/paginators/UserGroupPaginator.d.ts +24 -0
- package/dist/types/pagination/paginators/index.d.ts +7 -0
- package/dist/types/pagination/sortCompiler.d.ts +49 -0
- package/dist/types/pagination/types.normalization.d.ts +11 -0
- package/dist/types/pagination/utility.normalization.d.ts +18 -0
- package/dist/types/pagination/utility.queryChannel.d.ts +26 -0
- package/dist/types/pagination/utility.search.d.ts +13 -0
- package/dist/types/permissions.d.ts +1 -1
- package/dist/types/poll.d.ts +29 -32
- package/dist/types/poll_manager.d.ts +2 -2
- package/dist/types/reminders/Reminder.d.ts +2 -5
- package/dist/types/reminders/ReminderManager.d.ts +2 -9
- package/dist/types/search/MessageSearchSource.d.ts +4 -4
- package/dist/types/search/UserSearchSource.d.ts +1 -1
- package/dist/types/search/types.d.ts +3 -3
- package/dist/types/segment.d.ts +0 -34
- package/dist/types/signing.d.ts +105 -65
- package/dist/types/store.d.ts +1 -0
- package/dist/types/thread.d.ts +51 -34
- package/dist/types/thread_manager.d.ts +3 -3
- package/dist/types/token_manager.d.ts +15 -10
- package/dist/types/types.d.ts +196 -3384
- package/dist/types/utils/FixedSizeQueueCache.d.ts +12 -6
- package/dist/types/utils/WithSubscriptions.d.ts +2 -1
- package/dist/types/utils/concurrency.d.ts +4 -4
- package/dist/types/utils/mergeWith/mergeWith.d.ts +3 -3
- package/dist/types/utils/mergeWith/mergeWithCore.d.ts +8 -3
- package/dist/types/utils/retryable.d.ts +34 -0
- package/dist/types/utils.d.ts +104 -137
- package/package.json +7 -3
- package/src/ChannelPaginatorsOrchestrator.ts +545 -0
- package/src/CooldownTimer.ts +2 -2
- package/src/EventHandlerPipeline.ts +228 -0
- package/src/LiveLocationManager.ts +12 -11
- package/src/api-client.ts +275 -0
- package/src/campaign.ts +1 -77
- package/src/channel.ts +1262 -1277
- package/src/channel_batch_updater.ts +1 -211
- package/src/channel_manager.ts +92 -88
- package/src/channel_state.ts +144 -1013
- package/src/client.ts +888 -3944
- package/src/client_state.ts +4 -4
- package/src/configuration/InstanceConfigurationService.ts +73 -0
- package/src/configuration/index.ts +1 -0
- package/src/configuration/types.ts +81 -0
- package/src/connection.ts +145 -94
- package/src/connection_fallback.ts +29 -27
- package/src/constants.ts +1 -5
- package/src/custom_types.ts +4 -1
- package/src/errors.ts +2 -2
- package/src/gen/chat/ChannelApi.ts +275 -0
- package/src/gen/chat/ChatApi.ts +2554 -0
- package/src/gen/model-decoders/decoders.ts +2680 -0
- package/src/gen/model-decoders/event-decoder-mapping.ts +198 -0
- package/src/gen/models/index.ts +12673 -0
- package/src/gen/moderation/ModerationApi.ts +607 -0
- package/src/gen-imports.ts +3 -0
- package/src/index.ts +5 -10
- package/src/insights.ts +6 -5
- package/src/logger.ts +28 -0
- package/src/messageComposer/LocationComposer.ts +9 -5
- package/src/messageComposer/MessageComposerEffectHandlers.ts +1 -0
- package/src/messageComposer/attachmentIdentity.ts +16 -9
- package/src/messageComposer/attachmentManager.ts +13 -8
- package/src/messageComposer/configuration/types.ts +11 -11
- package/src/messageComposer/linkPreviewsManager.ts +9 -10
- package/src/messageComposer/messageComposer.ts +57 -53
- package/src/messageComposer/middleware/messageComposer/attachments.ts +1 -2
- package/src/messageComposer/middleware/messageComposer/cleanData.ts +1 -1
- package/src/messageComposer/middleware/messageComposer/compositionValidation.ts +2 -2
- package/src/messageComposer/middleware/messageComposer/messageComposerState.ts +2 -2
- package/src/messageComposer/middleware/messageComposer/sharedLocation.ts +4 -3
- package/src/messageComposer/middleware/messageComposer/textComposer.ts +2 -2
- package/src/messageComposer/middleware/messageComposer/types.ts +3 -4
- package/src/messageComposer/middleware/messageComposer/userDataInjection.ts +9 -5
- package/src/messageComposer/middleware/pollComposer/state.ts +0 -2
- package/src/messageComposer/middleware/pollComposer/types.ts +4 -7
- package/src/messageComposer/middleware/textComposer/TextComposerMiddlewareExecutor.ts +10 -1
- package/src/messageComposer/middleware/textComposer/commandEffects.ts +4 -4
- package/src/messageComposer/middleware/textComposer/commandUtils.ts +3 -6
- package/src/messageComposer/middleware/textComposer/commands.ts +3 -3
- package/src/messageComposer/middleware/textComposer/mentionUtils.ts +1 -1
- package/src/messageComposer/middleware/textComposer/mentions.ts +31 -15
- package/src/messageComposer/middleware/textComposer/types.ts +9 -4
- package/src/messageComposer/pollComposer.ts +6 -8
- package/src/messageComposer/textComposer.ts +27 -2
- package/src/messageComposer/types.ts +6 -28
- package/src/messageDelivery/MessageDeliveryReporter.ts +101 -45
- package/src/messageDelivery/MessageReceiptsTracker.ts +294 -21
- package/src/messageOperations/MessageOperationStatePolicy.ts +77 -0
- package/src/messageOperations/MessageOperations.ts +212 -0
- package/src/messageOperations/index.ts +10 -0
- package/src/messageOperations/types.ts +64 -0
- package/src/moderation.ts +38 -431
- package/src/notifications/types.ts +8 -7
- package/src/offline-support/offline_support_api.ts +198 -132
- package/src/offline-support/offline_sync_manager.ts +17 -7
- package/src/offline-support/types.ts +23 -26
- package/src/offline-support/util.ts +5 -4
- package/src/pagination/FilterBuilder.ts +4 -1
- package/src/pagination/ItemIndex.ts +112 -0
- package/src/pagination/cursorDerivation/createdAtAroundPaginationFlags.ts +73 -0
- package/src/pagination/cursorDerivation/idAroundPaginationFlags.ts +53 -0
- package/src/pagination/cursorDerivation/index.ts +1 -0
- package/src/pagination/cursorDerivation/linearPaginationFlags.ts +86 -0
- package/src/pagination/filterCompiler.ts +196 -0
- package/src/pagination/index.ts +1 -3
- package/src/pagination/paginators/BasePaginator.ts +2393 -0
- package/src/pagination/paginators/ChannelPaginator.ts +427 -0
- package/src/pagination/paginators/MessageIntervalPaginator.ts +1073 -0
- package/src/pagination/paginators/MessagePaginator.ts +496 -0
- package/src/pagination/paginators/PinnedMessagePaginator.ts +105 -0
- package/src/pagination/paginators/ReminderPaginator.ts +105 -0
- package/src/pagination/paginators/UserGroupPaginator.ts +125 -0
- package/src/pagination/paginators/index.ts +7 -0
- package/src/pagination/sortCompiler.ts +178 -0
- package/src/pagination/types.normalization.ts +14 -0
- package/src/pagination/utility.normalization.ts +106 -0
- package/src/pagination/utility.queryChannel.ts +84 -0
- package/src/pagination/utility.search.ts +80 -0
- package/src/permissions.ts +7 -8
- package/src/poll.ts +101 -110
- package/src/poll_manager.ts +14 -8
- package/src/reminders/Reminder.ts +2 -5
- package/src/reminders/ReminderManager.ts +19 -21
- package/src/search/BaseSearchSource.ts +0 -3
- package/src/search/ChannelMemberSearchSource.ts +7 -1
- package/src/search/ChannelSearchSource.ts +10 -3
- package/src/search/MessageSearchSource.ts +29 -30
- package/src/search/UserSearchSource.ts +12 -8
- package/src/search/types.ts +3 -4
- package/src/segment.ts +1 -95
- package/src/signing.ts +107 -67
- package/src/store.ts +2 -1
- package/src/thread.ts +439 -236
- package/src/thread_manager.ts +36 -15
- package/src/token_manager.ts +21 -10
- package/src/types.ts +375 -4524
- package/src/uploadManager.ts +8 -0
- package/src/utils/FixedSizeQueueCache.ts +12 -6
- package/src/utils/WithSubscriptions.ts +2 -1
- package/src/utils/concurrency.ts +4 -4
- package/src/utils/mergeWith/mergeWith.ts +3 -3
- package/src/utils/mergeWith/mergeWithCore.ts +140 -164
- package/src/utils/mergeWith/mergeWithDiff.ts +3 -3
- package/src/utils/retryable.ts +117 -0
- package/src/utils.ts +133 -524
- package/dist/types/events.d.ts +0 -72
- package/dist/types/pagination/BasePaginator.d.ts +0 -69
- package/dist/types/pagination/ReminderPaginator.d.ts +0 -16
- package/dist/types/pagination/UserGroupPaginator.d.ts +0 -21
- package/src/events.ts +0 -75
- package/src/pagination/BasePaginator.ts +0 -184
- package/src/pagination/ReminderPaginator.ts +0 -56
- package/src/pagination/UserGroupPaginator.ts +0 -93
|
@@ -1,211 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import type {
|
|
3
|
-
APIResponse,
|
|
4
|
-
BatchChannelDataUpdate,
|
|
5
|
-
NewMemberPayload,
|
|
6
|
-
UpdateChannelsBatchFilters,
|
|
7
|
-
UpdateChannelsBatchResponse,
|
|
8
|
-
} from './types';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* ChannelBatchUpdater - A class that provides convenience methods for batch channel operations
|
|
12
|
-
*/
|
|
13
|
-
export class ChannelBatchUpdater {
|
|
14
|
-
client: StreamChat;
|
|
15
|
-
|
|
16
|
-
constructor(client: StreamChat) {
|
|
17
|
-
this.client = client;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// Member operations
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* addMembers - Add members to channels matching the filter
|
|
24
|
-
*
|
|
25
|
-
* @param {UpdateChannelsBatchFilters} filter Filter to select channels
|
|
26
|
-
* @param {string[] | NewMemberPayload[]} members Members to add
|
|
27
|
-
* @return {Promise<APIResponse & UpdateChannelsBatchResponse>} The server response
|
|
28
|
-
*/
|
|
29
|
-
async addMembers(
|
|
30
|
-
filter: UpdateChannelsBatchFilters,
|
|
31
|
-
members: string[] | NewMemberPayload[],
|
|
32
|
-
): Promise<APIResponse & UpdateChannelsBatchResponse> {
|
|
33
|
-
return await this.client.updateChannelsBatch({
|
|
34
|
-
operation: 'addMembers',
|
|
35
|
-
filter,
|
|
36
|
-
members,
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* removeMembers - Remove members from channels matching the filter
|
|
42
|
-
*
|
|
43
|
-
* @param {UpdateChannelsBatchFilters} filter Filter to select channels
|
|
44
|
-
* @param {string[]} members Member IDs to remove
|
|
45
|
-
* @return {Promise<APIResponse & UpdateChannelsBatchResponse>} The server response
|
|
46
|
-
*/
|
|
47
|
-
async removeMembers(
|
|
48
|
-
filter: UpdateChannelsBatchFilters,
|
|
49
|
-
members: string[],
|
|
50
|
-
): Promise<APIResponse & UpdateChannelsBatchResponse> {
|
|
51
|
-
return await this.client.updateChannelsBatch({
|
|
52
|
-
operation: 'removeMembers',
|
|
53
|
-
filter,
|
|
54
|
-
members,
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* inviteMembers - Invite members to channels matching the filter
|
|
60
|
-
*
|
|
61
|
-
* @param {UpdateChannelsBatchFilters} filter Filter to select channels
|
|
62
|
-
* @param {string[] | NewMemberPayload[]} members Members to invite
|
|
63
|
-
* @return {Promise<APIResponse & UpdateChannelsBatchResponse>} The server response
|
|
64
|
-
*/
|
|
65
|
-
async inviteMembers(
|
|
66
|
-
filter: UpdateChannelsBatchFilters,
|
|
67
|
-
members: string[] | NewMemberPayload[],
|
|
68
|
-
): Promise<APIResponse & UpdateChannelsBatchResponse> {
|
|
69
|
-
return await this.client.updateChannelsBatch({
|
|
70
|
-
operation: 'inviteMembers',
|
|
71
|
-
filter,
|
|
72
|
-
members,
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* addModerators - Add moderators to channels matching the filter
|
|
78
|
-
*
|
|
79
|
-
* @param {UpdateChannelsBatchFilters} filter Filter to select channels
|
|
80
|
-
* @param {string[]} members Member IDs to promote to moderator
|
|
81
|
-
* @return {Promise<APIResponse & UpdateChannelsBatchResponse>} The server response
|
|
82
|
-
*/
|
|
83
|
-
async addModerators(
|
|
84
|
-
filter: UpdateChannelsBatchFilters,
|
|
85
|
-
members: string[],
|
|
86
|
-
): Promise<APIResponse & UpdateChannelsBatchResponse> {
|
|
87
|
-
return await this.client.updateChannelsBatch({
|
|
88
|
-
operation: 'addModerators',
|
|
89
|
-
filter,
|
|
90
|
-
members,
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* demoteModerators - Remove moderator role from members in channels matching the filter
|
|
96
|
-
*
|
|
97
|
-
* @param {UpdateChannelsBatchFilters} filter Filter to select channels
|
|
98
|
-
* @param {string[]} members Member IDs to demote
|
|
99
|
-
* @return {Promise<APIResponse & UpdateChannelsBatchResponse>} The server response
|
|
100
|
-
*/
|
|
101
|
-
async demoteModerators(
|
|
102
|
-
filter: UpdateChannelsBatchFilters,
|
|
103
|
-
members: string[],
|
|
104
|
-
): Promise<APIResponse & UpdateChannelsBatchResponse> {
|
|
105
|
-
return await this.client.updateChannelsBatch({
|
|
106
|
-
operation: 'demoteModerators',
|
|
107
|
-
filter,
|
|
108
|
-
members,
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* assignRoles - Assign roles to members in channels matching the filter
|
|
114
|
-
*
|
|
115
|
-
* @param {UpdateChannelsBatchFilters} filter Filter to select channels
|
|
116
|
-
* @param {NewMemberPayload[]} members Members with role assignments
|
|
117
|
-
* @return {Promise<APIResponse & UpdateChannelsBatchResponse>} The server response
|
|
118
|
-
*/
|
|
119
|
-
async assignRoles(
|
|
120
|
-
filter: UpdateChannelsBatchFilters,
|
|
121
|
-
members: NewMemberPayload[],
|
|
122
|
-
): Promise<APIResponse & UpdateChannelsBatchResponse> {
|
|
123
|
-
return await this.client.updateChannelsBatch({
|
|
124
|
-
operation: 'assignRoles',
|
|
125
|
-
filter,
|
|
126
|
-
members,
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// Visibility operations
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* hide - Hide channels matching the filter
|
|
134
|
-
*
|
|
135
|
-
* @param {UpdateChannelsBatchFilters} filter Filter to select channels
|
|
136
|
-
* @return {Promise<APIResponse & UpdateChannelsBatchResponse>} The server response
|
|
137
|
-
*/
|
|
138
|
-
async hide(
|
|
139
|
-
filter: UpdateChannelsBatchFilters,
|
|
140
|
-
): Promise<APIResponse & UpdateChannelsBatchResponse> {
|
|
141
|
-
return await this.client.updateChannelsBatch({
|
|
142
|
-
operation: 'hide',
|
|
143
|
-
filter,
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* show - Show channels matching the filter
|
|
149
|
-
*
|
|
150
|
-
* @param {UpdateChannelsBatchFilters} filter Filter to select channels
|
|
151
|
-
* @return {Promise<APIResponse & UpdateChannelsBatchResponse>} The server response
|
|
152
|
-
*/
|
|
153
|
-
async show(
|
|
154
|
-
filter: UpdateChannelsBatchFilters,
|
|
155
|
-
): Promise<APIResponse & UpdateChannelsBatchResponse> {
|
|
156
|
-
return await this.client.updateChannelsBatch({
|
|
157
|
-
operation: 'show',
|
|
158
|
-
filter,
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* archive - Archive channels matching the filter
|
|
164
|
-
*
|
|
165
|
-
* @param {UpdateChannelsBatchFilters} filter Filter to select channels
|
|
166
|
-
* @return {Promise<APIResponse & UpdateChannelsBatchResponse>} The server response
|
|
167
|
-
*/
|
|
168
|
-
async archive(
|
|
169
|
-
filter: UpdateChannelsBatchFilters,
|
|
170
|
-
): Promise<APIResponse & UpdateChannelsBatchResponse> {
|
|
171
|
-
return await this.client.updateChannelsBatch({
|
|
172
|
-
operation: 'archive',
|
|
173
|
-
filter,
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* unarchive - Unarchive channels matching the filter
|
|
179
|
-
*
|
|
180
|
-
* @param {UpdateChannelsBatchFilters} filter Filter to select channels
|
|
181
|
-
* @return {Promise<APIResponse & UpdateChannelsBatchResponse>} The server response
|
|
182
|
-
*/
|
|
183
|
-
async unarchive(
|
|
184
|
-
filter: UpdateChannelsBatchFilters,
|
|
185
|
-
): Promise<APIResponse & UpdateChannelsBatchResponse> {
|
|
186
|
-
return await this.client.updateChannelsBatch({
|
|
187
|
-
operation: 'unarchive',
|
|
188
|
-
filter,
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// Data operations
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* updateData - Update data on channels matching the filter
|
|
196
|
-
*
|
|
197
|
-
* @param {UpdateChannelsBatchFilters} filter Filter to select channels
|
|
198
|
-
* @param {BatchChannelDataUpdate} data Data to update
|
|
199
|
-
* @return {Promise<APIResponse & UpdateChannelsBatchResponse>} The server response
|
|
200
|
-
*/
|
|
201
|
-
async updateData(
|
|
202
|
-
filter: UpdateChannelsBatchFilters,
|
|
203
|
-
data: BatchChannelDataUpdate,
|
|
204
|
-
): Promise<APIResponse & UpdateChannelsBatchResponse> {
|
|
205
|
-
return await this.client.updateChannelsBatch({
|
|
206
|
-
operation: 'updateData',
|
|
207
|
-
filter,
|
|
208
|
-
data,
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
}
|
|
1
|
+
// ChannelBatchUpdater functionality has been moved to the server-side SDK.
|
package/src/channel_manager.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { QueryChannelsResponseWithChannels, StreamChat } from './client';
|
|
2
2
|
import type {
|
|
3
3
|
ChannelFilters,
|
|
4
|
-
ChannelOptions,
|
|
5
4
|
ChannelSort,
|
|
6
5
|
ChannelStateOptions,
|
|
7
6
|
Event,
|
|
8
|
-
|
|
7
|
+
EventPayload,
|
|
8
|
+
QueryChannelsRequest,
|
|
9
|
+
QueryChannelsResponse,
|
|
9
10
|
} from './types';
|
|
11
|
+
import { chatLoggerSystem } from './logger';
|
|
10
12
|
import type { ValueOrPatch } from './store';
|
|
11
13
|
import { isPatch, StateStore } from './store';
|
|
12
14
|
import type { Channel } from './channel';
|
|
@@ -29,15 +31,15 @@ import {
|
|
|
29
31
|
} from './constants';
|
|
30
32
|
import { WithSubscriptions } from './utils/WithSubscriptions';
|
|
31
33
|
|
|
34
|
+
const logger = chatLoggerSystem.getLogger('channel-manager');
|
|
35
|
+
|
|
32
36
|
export type ChannelManagerPagination = {
|
|
33
|
-
filters: ChannelFilters;
|
|
34
37
|
hasNext: boolean;
|
|
35
38
|
isLoading: boolean;
|
|
36
39
|
isLoadingNext: boolean;
|
|
37
|
-
options
|
|
38
|
-
responseFilters?:
|
|
39
|
-
responseSort?:
|
|
40
|
-
sort: ChannelSort;
|
|
40
|
+
options?: QueryChannelsRequest;
|
|
41
|
+
responseFilters?: QueryChannelsRequest['filter_conditions'];
|
|
42
|
+
responseSort?: QueryChannelsRequest['sort'];
|
|
41
43
|
};
|
|
42
44
|
|
|
43
45
|
export type ChannelManagerState = {
|
|
@@ -56,9 +58,7 @@ export type ChannelManagerState = {
|
|
|
56
58
|
export type ChannelSetterParameterType = ValueOrPatch<ChannelManagerState['channels']>;
|
|
57
59
|
export type ChannelSetterType = (arg: ChannelSetterParameterType) => void;
|
|
58
60
|
|
|
59
|
-
export type GenericEventHandlerType<T extends unknown[]> = (
|
|
60
|
-
...args: T
|
|
61
|
-
) => void | (() => void) | ((...args: T) => Promise<void>) | Promise<void>;
|
|
61
|
+
export type GenericEventHandlerType<T extends unknown[]> = (...args: T) => any;
|
|
62
62
|
export type EventHandlerType = GenericEventHandlerType<[Event]>;
|
|
63
63
|
export type EventHandlerOverrideType = GenericEventHandlerType<
|
|
64
64
|
[ChannelSetterType, Event]
|
|
@@ -92,10 +92,9 @@ export type ChannelManagerEventHandlerOverrides = Partial<
|
|
|
92
92
|
Record<ChannelManagerEventHandlerNames, EventHandlerOverrideType>
|
|
93
93
|
>;
|
|
94
94
|
|
|
95
|
-
export type ExecuteChannelsQueryPayload = Pick<
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
> & { stateOptions: ChannelStateOptions };
|
|
95
|
+
export type ExecuteChannelsQueryPayload = Pick<ChannelManagerPagination, 'options'> & {
|
|
96
|
+
stateOptions: ChannelStateOptions;
|
|
97
|
+
};
|
|
99
98
|
|
|
100
99
|
export const channelManagerEventToHandlerMapping: {
|
|
101
100
|
[key in ChannelManagerEventTypes]: ChannelManagerEventHandlerNames;
|
|
@@ -139,9 +138,7 @@ export type ChannelManagerOptions = {
|
|
|
139
138
|
export type QueryChannelsRequestOutput = Channel[] | QueryChannelsResponseWithChannels;
|
|
140
139
|
|
|
141
140
|
export type QueryChannelsRequestType = (
|
|
142
|
-
|
|
143
|
-
sort?: ChannelSort,
|
|
144
|
-
options?: ChannelOptions,
|
|
141
|
+
options?: QueryChannelsRequest,
|
|
145
142
|
stateOptions?: ChannelStateOptions,
|
|
146
143
|
) => Promise<QueryChannelsRequestOutput>;
|
|
147
144
|
|
|
@@ -160,18 +157,11 @@ export const DEFAULT_CHANNEL_MANAGER_PAGINATION_OPTIONS = {
|
|
|
160
157
|
offset: 0,
|
|
161
158
|
};
|
|
162
159
|
|
|
163
|
-
const mapPredefinedFilterSortToChannelSort = (
|
|
164
|
-
sort: NonNullable<QueryChannelsAPIResponse['predefined_filter']>['sort'],
|
|
165
|
-
): ChannelSort =>
|
|
166
|
-
(sort ?? []).map(({ direction = 1, field }) => ({
|
|
167
|
-
[field]: direction,
|
|
168
|
-
})) as ChannelSort;
|
|
169
|
-
|
|
170
160
|
const getResponsePaginationParams = ({
|
|
171
161
|
queryChannelsResponse,
|
|
172
162
|
sort,
|
|
173
163
|
}: {
|
|
174
|
-
queryChannelsResponse?: Pick<
|
|
164
|
+
queryChannelsResponse?: Pick<QueryChannelsResponse, 'predefined_filter'>;
|
|
175
165
|
sort: ChannelSort;
|
|
176
166
|
}): Pick<ChannelManagerPagination, 'responseFilters' | 'responseSort'> => {
|
|
177
167
|
const predefinedFilter = queryChannelsResponse?.predefined_filter;
|
|
@@ -182,18 +172,13 @@ const getResponsePaginationParams = ({
|
|
|
182
172
|
|
|
183
173
|
return {
|
|
184
174
|
responseFilters: predefinedFilter.filter as ChannelFilters,
|
|
185
|
-
responseSort:
|
|
186
|
-
predefinedFilter.sort !== undefined
|
|
187
|
-
? mapPredefinedFilterSortToChannelSort(predefinedFilter.sort)
|
|
188
|
-
: sort,
|
|
175
|
+
responseSort: predefinedFilter.sort ?? sort,
|
|
189
176
|
};
|
|
190
177
|
};
|
|
191
178
|
|
|
192
|
-
const getResponseFiltersAndSort = (
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
filters: pagination.responseFilters ?? pagination.filters,
|
|
196
|
-
sort: pagination.responseSort ?? pagination.sort,
|
|
179
|
+
const getResponseFiltersAndSort = (pagination: ChannelManagerPagination) => ({
|
|
180
|
+
filters: pagination.responseFilters ?? pagination.options?.filter_conditions,
|
|
181
|
+
sort: pagination.responseSort ?? pagination.options?.sort,
|
|
197
182
|
});
|
|
198
183
|
|
|
199
184
|
const omitResponsePaginationParams = (pagination: ChannelManagerPagination) => {
|
|
@@ -245,8 +230,6 @@ export class ChannelManager extends WithSubscriptions {
|
|
|
245
230
|
isLoading: false,
|
|
246
231
|
isLoadingNext: false,
|
|
247
232
|
hasNext: false,
|
|
248
|
-
filters: {},
|
|
249
|
-
sort: {},
|
|
250
233
|
options: DEFAULT_CHANNEL_MANAGER_PAGINATION_OPTIONS,
|
|
251
234
|
},
|
|
252
235
|
initialized: false,
|
|
@@ -255,7 +238,8 @@ export class ChannelManager extends WithSubscriptions {
|
|
|
255
238
|
this.setEventHandlerOverrides(eventHandlerOverrides);
|
|
256
239
|
this.setOptions(options);
|
|
257
240
|
this.queryChannelsRequest =
|
|
258
|
-
queryChannelsOverride ??
|
|
241
|
+
queryChannelsOverride ??
|
|
242
|
+
((...params) => this.client.queryChannelsAndHydrate(...params));
|
|
259
243
|
this.eventHandlers = new Map(
|
|
260
244
|
Object.entries<EventHandlerType>({
|
|
261
245
|
channelDeletedHandler: this.channelDeletedHandler,
|
|
@@ -287,15 +271,22 @@ export class ChannelManager extends WithSubscriptions {
|
|
|
287
271
|
});
|
|
288
272
|
const {
|
|
289
273
|
channels,
|
|
290
|
-
pagination: {
|
|
274
|
+
pagination: { options },
|
|
291
275
|
} = this.state.getLatestValue();
|
|
292
276
|
this.client.offlineDb?.executeQuerySafely(
|
|
293
277
|
(db) =>
|
|
278
|
+
// TODO: filters/sort must be passed explicitly (even though they live inside `options`)
|
|
279
|
+
// because `convertFilterSortToQuery` keys the offline query off the top-level filters/sort
|
|
280
|
+
// args, not `options.filter_conditions`/`options.sort`. Omitting them here writes reorders
|
|
281
|
+
// to a mismatched cache key, so the persisted channel order goes stale until a full requery.
|
|
282
|
+
// Proper fix: make `convertFilterSortToQuery` derive filters/sort from `options` so no call
|
|
283
|
+
// site has to pass them redundantly (requires a DB schema-version bump to flush stale
|
|
284
|
+
// `channelQueries` rows keyed by the old format).
|
|
294
285
|
db.upsertCidsForQuery({
|
|
295
286
|
cids: channels.map((channel) => channel.cid),
|
|
296
|
-
filters,
|
|
287
|
+
filters: options?.filter_conditions,
|
|
297
288
|
options,
|
|
298
|
-
sort,
|
|
289
|
+
sort: options?.sort,
|
|
299
290
|
}),
|
|
300
291
|
{ method: 'upsertCidsForQuery' },
|
|
301
292
|
);
|
|
@@ -329,18 +320,16 @@ export class ChannelManager extends WithSubscriptions {
|
|
|
329
320
|
payload: ExecuteChannelsQueryPayload,
|
|
330
321
|
retryCount = 0,
|
|
331
322
|
): Promise<void> => {
|
|
332
|
-
const {
|
|
323
|
+
const { options, stateOptions } = payload;
|
|
333
324
|
const { offset, limit } = {
|
|
334
325
|
...DEFAULT_CHANNEL_MANAGER_PAGINATION_OPTIONS,
|
|
335
326
|
...options,
|
|
336
327
|
};
|
|
337
328
|
try {
|
|
338
|
-
const queryChannelsResponse = await this.queryChannelsRequest(
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
{ ...stateOptions, withResponse: true },
|
|
343
|
-
);
|
|
329
|
+
const queryChannelsResponse = await this.queryChannelsRequest(options, {
|
|
330
|
+
...stateOptions,
|
|
331
|
+
withResponse: true,
|
|
332
|
+
});
|
|
344
333
|
const channels = isQueryChannelsResponseWithChannels(queryChannelsResponse)
|
|
345
334
|
? queryChannelsResponse.channels
|
|
346
335
|
: queryChannelsResponse;
|
|
@@ -351,7 +340,7 @@ export class ChannelManager extends WithSubscriptions {
|
|
|
351
340
|
queryChannelsResponse: isQueryChannelsResponseWithChannels(queryChannelsResponse)
|
|
352
341
|
? queryChannelsResponse
|
|
353
342
|
: undefined,
|
|
354
|
-
sort,
|
|
343
|
+
sort: options?.sort ?? [],
|
|
355
344
|
});
|
|
356
345
|
const paginationWithoutResponseParams = omitResponsePaginationParams(pagination);
|
|
357
346
|
|
|
@@ -376,18 +365,22 @@ export class ChannelManager extends WithSubscriptions {
|
|
|
376
365
|
(db) =>
|
|
377
366
|
db.upsertCidsForQuery({
|
|
378
367
|
cids: channels.map((channel) => channel.cid),
|
|
379
|
-
filters: pagination.
|
|
368
|
+
filters: pagination.options?.filter_conditions,
|
|
380
369
|
options,
|
|
381
|
-
sort: pagination.sort,
|
|
370
|
+
sort: pagination.options?.sort,
|
|
382
371
|
}),
|
|
383
372
|
{ method: 'upsertCidsForQuery' },
|
|
384
373
|
);
|
|
385
|
-
} catch (
|
|
374
|
+
} catch (error) {
|
|
386
375
|
if (retryCount >= DEFAULT_QUERY_CHANNELS_RETRY_COUNT) {
|
|
387
|
-
|
|
376
|
+
logger
|
|
377
|
+
.withExtraTags('executeChannelsQuery')
|
|
378
|
+
.error('Failed to query channels after the maximum number of retries.', {
|
|
379
|
+
error,
|
|
380
|
+
});
|
|
388
381
|
|
|
389
382
|
const wrappedError = new Error(
|
|
390
|
-
`Maximum number of retries reached in queryChannels. Last error message is: ${
|
|
383
|
+
`Maximum number of retries reached in queryChannels. Last error message is: ${error}`,
|
|
391
384
|
);
|
|
392
385
|
|
|
393
386
|
const state = this.state.getLatestValue();
|
|
@@ -413,13 +406,11 @@ export class ChannelManager extends WithSubscriptions {
|
|
|
413
406
|
};
|
|
414
407
|
|
|
415
408
|
public queryChannels = async (
|
|
416
|
-
|
|
417
|
-
sort: ChannelSort = [],
|
|
418
|
-
options: ChannelOptions = {},
|
|
409
|
+
request?: QueryChannelsRequest,
|
|
419
410
|
stateOptions: ChannelStateOptions = {},
|
|
420
411
|
) => {
|
|
421
412
|
const {
|
|
422
|
-
pagination: { isLoading,
|
|
413
|
+
pagination: { isLoading, options: optionsFromState },
|
|
423
414
|
initialized,
|
|
424
415
|
} = this.state.getLatestValue();
|
|
425
416
|
|
|
@@ -428,12 +419,18 @@ export class ChannelManager extends WithSubscriptions {
|
|
|
428
419
|
!this.options.abortInFlightQuery &&
|
|
429
420
|
// TODO: Figure a proper way to either deeply compare these or
|
|
430
421
|
// create hashes from each.
|
|
431
|
-
JSON.stringify(
|
|
422
|
+
JSON.stringify(optionsFromState?.filter_conditions) ===
|
|
423
|
+
JSON.stringify(request?.filter_conditions)
|
|
432
424
|
) {
|
|
433
425
|
return;
|
|
434
426
|
}
|
|
435
427
|
|
|
436
|
-
const executeChannelsQueryPayload = {
|
|
428
|
+
const executeChannelsQueryPayload = {
|
|
429
|
+
filters: request?.filter_conditions,
|
|
430
|
+
sort: request?.sort,
|
|
431
|
+
options: request,
|
|
432
|
+
stateOptions,
|
|
433
|
+
};
|
|
437
434
|
|
|
438
435
|
try {
|
|
439
436
|
this.stateOptions = stateOptions;
|
|
@@ -443,9 +440,7 @@ export class ChannelManager extends WithSubscriptions {
|
|
|
443
440
|
...omitResponsePaginationParams(currentState.pagination),
|
|
444
441
|
isLoading: true,
|
|
445
442
|
isLoadingNext: false,
|
|
446
|
-
|
|
447
|
-
sort,
|
|
448
|
-
options,
|
|
443
|
+
options: request,
|
|
449
444
|
},
|
|
450
445
|
error: undefined,
|
|
451
446
|
}));
|
|
@@ -454,9 +449,7 @@ export class ChannelManager extends WithSubscriptions {
|
|
|
454
449
|
if (!initialized) {
|
|
455
450
|
const channelsFromDB = await this.client.offlineDb.getChannelsForQuery({
|
|
456
451
|
userId: this.client.user.id,
|
|
457
|
-
|
|
458
|
-
options,
|
|
459
|
-
sort,
|
|
452
|
+
options: request,
|
|
460
453
|
});
|
|
461
454
|
|
|
462
455
|
if (channelsFromDB) {
|
|
@@ -481,7 +474,7 @@ export class ChannelManager extends WithSubscriptions {
|
|
|
481
474
|
}
|
|
482
475
|
await this.executeChannelsQuery(executeChannelsQueryPayload);
|
|
483
476
|
} catch (error) {
|
|
484
|
-
|
|
477
|
+
logger.withExtraTags('queryChannels').error('Failed to query channels.', { error });
|
|
485
478
|
this.state.next((currentState) => ({
|
|
486
479
|
...currentState,
|
|
487
480
|
pagination: { ...currentState.pagination, isLoading: false },
|
|
@@ -492,7 +485,7 @@ export class ChannelManager extends WithSubscriptions {
|
|
|
492
485
|
|
|
493
486
|
public loadNext = async () => {
|
|
494
487
|
const { pagination, initialized } = this.state.getLatestValue();
|
|
495
|
-
const {
|
|
488
|
+
const { options, isLoadingNext, hasNext } = pagination;
|
|
496
489
|
|
|
497
490
|
if (!initialized || isLoadingNext || !hasNext) {
|
|
498
491
|
return;
|
|
@@ -507,8 +500,6 @@ export class ChannelManager extends WithSubscriptions {
|
|
|
507
500
|
pagination: { ...pagination, isLoading: false, isLoadingNext: true },
|
|
508
501
|
});
|
|
509
502
|
const queryChannelsResponse = await this.queryChannelsRequest(
|
|
510
|
-
filters,
|
|
511
|
-
sort,
|
|
512
503
|
options,
|
|
513
504
|
this.stateOptions,
|
|
514
505
|
);
|
|
@@ -530,7 +521,9 @@ export class ChannelManager extends WithSubscriptions {
|
|
|
530
521
|
},
|
|
531
522
|
});
|
|
532
523
|
} catch (error) {
|
|
533
|
-
|
|
524
|
+
logger
|
|
525
|
+
.withExtraTags('loadNext')
|
|
526
|
+
.error('Failed to load the next page of channels.', { error });
|
|
534
527
|
this.state.next((currentState) => ({
|
|
535
528
|
...currentState,
|
|
536
529
|
pagination: {
|
|
@@ -543,7 +536,8 @@ export class ChannelManager extends WithSubscriptions {
|
|
|
543
536
|
}
|
|
544
537
|
};
|
|
545
538
|
|
|
546
|
-
private notificationAddedToChannelHandler = async (
|
|
539
|
+
private notificationAddedToChannelHandler = async (event_: Event) => {
|
|
540
|
+
const event = event_ as EventPayload<'notification.added_to_channel'>;
|
|
547
541
|
const { id, type, members } = event?.channel ?? {};
|
|
548
542
|
|
|
549
543
|
if (
|
|
@@ -573,7 +567,7 @@ export class ChannelManager extends WithSubscriptions {
|
|
|
573
567
|
return;
|
|
574
568
|
}
|
|
575
569
|
|
|
576
|
-
const { sort } = getResponseFiltersAndSort(pagination);
|
|
570
|
+
const { sort = [] } = getResponseFiltersAndSort(pagination);
|
|
577
571
|
|
|
578
572
|
this.setChannels(
|
|
579
573
|
promoteChannel({
|
|
@@ -584,7 +578,11 @@ export class ChannelManager extends WithSubscriptions {
|
|
|
584
578
|
);
|
|
585
579
|
};
|
|
586
580
|
|
|
587
|
-
private channelDeletedHandler = (
|
|
581
|
+
private channelDeletedHandler = (event_: Event) => {
|
|
582
|
+
const event = event_ as EventPayload<
|
|
583
|
+
'channel.deleted' | 'channel.hidden' | 'notification.removed_from_channel'
|
|
584
|
+
>;
|
|
585
|
+
|
|
588
586
|
const { channels } = this.state.getLatestValue();
|
|
589
587
|
if (!channels) {
|
|
590
588
|
return;
|
|
@@ -605,12 +603,14 @@ export class ChannelManager extends WithSubscriptions {
|
|
|
605
603
|
|
|
606
604
|
private channelHiddenHandler = this.channelDeletedHandler;
|
|
607
605
|
|
|
608
|
-
private newMessageHandler = (
|
|
606
|
+
private newMessageHandler = (event_: Event) => {
|
|
607
|
+
const event = event_ as EventPayload<'message.new'>;
|
|
608
|
+
|
|
609
609
|
const { pagination, channels } = this.state.getLatestValue();
|
|
610
610
|
if (!channels) {
|
|
611
611
|
return;
|
|
612
612
|
}
|
|
613
|
-
const { filters, sort } = getResponseFiltersAndSort(pagination);
|
|
613
|
+
const { filters, sort = [] } = getResponseFiltersAndSort(pagination);
|
|
614
614
|
|
|
615
615
|
const channelType = event.channel_type;
|
|
616
616
|
const channelId = event.channel_id;
|
|
@@ -631,9 +631,9 @@ export class ChannelManager extends WithSubscriptions {
|
|
|
631
631
|
|
|
632
632
|
if (
|
|
633
633
|
// filter is defined, target channel is archived and filter option is set to false
|
|
634
|
-
(considerArchivedChannels && isTargetChannelArchived && !filters
|
|
634
|
+
(considerArchivedChannels && isTargetChannelArchived && !filters?.archived) ||
|
|
635
635
|
// filter is defined, target channel isn't archived and filter option is set to true
|
|
636
|
-
(considerArchivedChannels && !isTargetChannelArchived && filters
|
|
636
|
+
(considerArchivedChannels && !isTargetChannelArchived && filters?.archived) ||
|
|
637
637
|
// sort option is defined, target channel is pinned
|
|
638
638
|
(considerPinnedChannels && isTargetChannelPinned) ||
|
|
639
639
|
// list order is locked
|
|
@@ -655,7 +655,9 @@ export class ChannelManager extends WithSubscriptions {
|
|
|
655
655
|
);
|
|
656
656
|
};
|
|
657
657
|
|
|
658
|
-
private notificationNewMessageHandler = async (
|
|
658
|
+
private notificationNewMessageHandler = async (event_: Event) => {
|
|
659
|
+
const event = event_ as EventPayload<'notification.message_new'>;
|
|
660
|
+
|
|
659
661
|
const { id, type } = event?.channel ?? {};
|
|
660
662
|
|
|
661
663
|
if (!id || !type) {
|
|
@@ -669,15 +671,15 @@ export class ChannelManager extends WithSubscriptions {
|
|
|
669
671
|
});
|
|
670
672
|
|
|
671
673
|
const { channels, pagination } = this.state.getLatestValue();
|
|
672
|
-
const { filters, sort } = getResponseFiltersAndSort(pagination);
|
|
674
|
+
const { filters, sort = [] } = getResponseFiltersAndSort(pagination);
|
|
673
675
|
|
|
674
676
|
const considerArchivedChannels = shouldConsiderArchivedChannels(filters);
|
|
675
677
|
const isTargetChannelArchived = isChannelArchived(channel);
|
|
676
678
|
|
|
677
679
|
if (
|
|
678
680
|
!channels ||
|
|
679
|
-
(considerArchivedChannels && isTargetChannelArchived && !filters
|
|
680
|
-
(considerArchivedChannels && !isTargetChannelArchived && filters
|
|
681
|
+
(considerArchivedChannels && isTargetChannelArchived && !filters?.archived) ||
|
|
682
|
+
(considerArchivedChannels && !isTargetChannelArchived && filters?.archived) ||
|
|
681
683
|
!this.options.allowNotLoadedChannelPromotionForEvent?.['notification.message_new']
|
|
682
684
|
) {
|
|
683
685
|
return;
|
|
@@ -692,7 +694,8 @@ export class ChannelManager extends WithSubscriptions {
|
|
|
692
694
|
);
|
|
693
695
|
};
|
|
694
696
|
|
|
695
|
-
private channelVisibleHandler = async (
|
|
697
|
+
private channelVisibleHandler = async (event_: Event) => {
|
|
698
|
+
const event = event_ as EventPayload<'channel.visible' | 'channel.hidden'>;
|
|
696
699
|
const { channel_type: channelType, channel_id: channelId } = event;
|
|
697
700
|
|
|
698
701
|
if (!channelType || !channelId) {
|
|
@@ -706,15 +709,15 @@ export class ChannelManager extends WithSubscriptions {
|
|
|
706
709
|
});
|
|
707
710
|
|
|
708
711
|
const { channels, pagination } = this.state.getLatestValue();
|
|
709
|
-
const { filters, sort } = getResponseFiltersAndSort(pagination);
|
|
712
|
+
const { filters, sort = [] } = getResponseFiltersAndSort(pagination);
|
|
710
713
|
|
|
711
714
|
const considerArchivedChannels = shouldConsiderArchivedChannels(filters);
|
|
712
715
|
const isTargetChannelArchived = isChannelArchived(channel);
|
|
713
716
|
|
|
714
717
|
if (
|
|
715
718
|
!channels ||
|
|
716
|
-
(considerArchivedChannels && isTargetChannelArchived && !filters
|
|
717
|
-
(considerArchivedChannels && !isTargetChannelArchived && filters
|
|
719
|
+
(considerArchivedChannels && isTargetChannelArchived && !filters?.archived) ||
|
|
720
|
+
(considerArchivedChannels && !isTargetChannelArchived && filters?.archived) ||
|
|
718
721
|
!this.options.allowNotLoadedChannelPromotionForEvent?.['channel.visible']
|
|
719
722
|
) {
|
|
720
723
|
return;
|
|
@@ -731,12 +734,13 @@ export class ChannelManager extends WithSubscriptions {
|
|
|
731
734
|
|
|
732
735
|
private notificationRemovedFromChannelHandler = this.channelDeletedHandler;
|
|
733
736
|
|
|
734
|
-
private memberUpdatedHandler = (
|
|
737
|
+
private memberUpdatedHandler = (event_: Event) => {
|
|
738
|
+
const event = event_ as EventPayload<'member.updated'>;
|
|
735
739
|
const { pagination, channels } = this.state.getLatestValue();
|
|
736
|
-
const { filters, sort } = getResponseFiltersAndSort(pagination);
|
|
740
|
+
const { filters, sort = [] } = getResponseFiltersAndSort(pagination);
|
|
737
741
|
if (
|
|
738
742
|
!event.member?.user ||
|
|
739
|
-
event.member.user.id !== this.client.
|
|
743
|
+
event.member.user.id !== this.client.userId ||
|
|
740
744
|
!event.channel_type ||
|
|
741
745
|
!event.channel_id
|
|
742
746
|
) {
|