stream-chat 10.0.0-rc.30 → 10.0.0-rc.31

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.
Files changed (29) hide show
  1. package/dist/cjs/index.browser.js +200 -147
  2. package/dist/cjs/index.browser.js.map +3 -3
  3. package/dist/cjs/index.node.js +204 -147
  4. package/dist/cjs/index.node.js.map +3 -3
  5. package/dist/esm/index.mjs +200 -147
  6. package/dist/esm/index.mjs.map +3 -3
  7. package/dist/types/messageComposer/middleware/messageComposer/commandInjection.d.ts +5 -0
  8. package/dist/types/messageComposer/middleware/messageComposer/index.d.ts +1 -0
  9. package/dist/types/messageComposer/middleware/messageComposer/userDataInjection.d.ts +5 -0
  10. package/dist/types/messageComposer/middleware/textComposer/commandUtils.d.ts +4 -0
  11. package/dist/types/messageComposer/textComposer.d.ts +5 -0
  12. package/dist/types/messageOperations/MessageOperationStatePolicy.d.ts +5 -1
  13. package/dist/types/offline-support/queueableOperations.d.ts +6 -0
  14. package/package.json +1 -1
  15. package/src/messageComposer/messageComposer.ts +6 -1
  16. package/src/messageComposer/middleware/messageComposer/MessageComposerMiddlewareExecutor.ts +6 -0
  17. package/src/messageComposer/middleware/messageComposer/commandInjection.ts +10 -4
  18. package/src/messageComposer/middleware/messageComposer/customData.ts +14 -2
  19. package/src/messageComposer/middleware/messageComposer/index.ts +1 -0
  20. package/src/messageComposer/middleware/messageComposer/userDataInjection.ts +8 -1
  21. package/src/messageComposer/middleware/textComposer/TextComposerMiddlewareExecutor.ts +7 -0
  22. package/src/messageComposer/middleware/textComposer/commandUtils.ts +9 -1
  23. package/src/messageComposer/textComposer.ts +10 -0
  24. package/src/messageOperations/MessageOperationStatePolicy.ts +19 -8
  25. package/src/messageOperations/MessageOperations.ts +2 -2
  26. package/src/offline-support/offline_support_api.ts +5 -0
  27. package/src/offline-support/queueableOperations.ts +26 -0
  28. package/src/pagination/paginators/BasePaginator.ts +8 -3
  29. package/src/search/MessageSearchSource.ts +2 -1
@@ -132,6 +132,7 @@ __export(src_exports, {
132
132
  ThreadPaginator: () => ThreadPaginator,
133
133
  TokenManager: () => TokenManager,
134
134
  UPDATE_LIVE_LOCATION_REQUEST_MIN_THROTTLE_TIMEOUT: () => UPDATE_LIVE_LOCATION_REQUEST_MIN_THROTTLE_TIMEOUT,
135
+ USER_DATA_INJECTION_MIDDLEWARE_ID: () => USER_DATA_INJECTION_MIDDLEWARE_ID,
135
136
  UploadManager: () => UploadManager,
136
137
  UserFromToken: () => UserFromToken,
137
138
  UserGroupPaginator: () => UserGroupPaginator,
@@ -148,6 +149,7 @@ __export(src_exports, {
148
149
  chatCodes: () => chatCodes,
149
150
  chatLoggerSystem: () => chatLoggerSystem,
150
151
  clampWSConnectionConfig: () => clampWSConnectionConfig,
152
+ commandTakesNoArguments: () => commandTakesNoArguments,
151
153
  convertTimestampToDate: () => convertTimestampToDate,
152
154
  createActiveCommandGuardMiddleware: () => createActiveCommandGuardMiddleware,
153
155
  createAttachmentsCompositionMiddleware: () => createAttachmentsCompositionMiddleware,
@@ -179,6 +181,7 @@ __export(src_exports, {
179
181
  createTextComposerPreValidationMiddleware: () => createTextComposerPreValidationMiddleware,
180
182
  createUploadConfigCheckMiddleware: () => createUploadConfigCheckMiddleware,
181
183
  createUploadErrorHandlerMiddleware: () => createUploadErrorHandlerMiddleware,
184
+ createUserDataInjectionMiddleware: () => createUserDataInjectionMiddleware,
182
185
  createWSConnectionNetworkStatusReporter: () => createWSConnectionNetworkStatusReporter,
183
186
  dateToNs: () => dateToNs,
184
187
  defaultCommandSendabilityValidator: () => defaultCommandSendabilityValidator,
@@ -262,6 +265,7 @@ __export(src_exports, {
262
265
  stripCommandFromText: () => stripCommandFromText,
263
266
  stripMentionTokens: () => stripMentionTokens,
264
267
  textIsEmpty: () => textIsEmpty,
268
+ textStartsWithCommand: () => textStartsWithCommand,
265
269
  timeLeftMs: () => timeLeftMs,
266
270
  withCancellation: () => withCancellation,
267
271
  withoutConcurrency: () => withoutConcurrency
@@ -3567,6 +3571,8 @@ var createCompositionDataCleanupMiddleware = (composer) => ({
3567
3571
  });
3568
3572
 
3569
3573
  // src/messageComposer/middleware/messageComposer/customData.ts
3574
+ var hasFields = (data) => !!data && Object.keys(data).length > 0;
3575
+ var editClearsCustomData = (composer) => hasFields(composer.editedMessage?.custom) && !hasFields(composer.customDataManager.customMessageData);
3570
3576
  var createCustomDataCompositionMiddleware = (composer) => ({
3571
3577
  id: "stream-io/message-composer-middleware/custom-data",
3572
3578
  handlers: {
@@ -3576,7 +3582,7 @@ var createCustomDataCompositionMiddleware = (composer) => ({
3576
3582
  forward
3577
3583
  }) => {
3578
3584
  const data = composer.customDataManager.customMessageData;
3579
- if (!data || !Object.keys(data).length) return forward();
3585
+ if (!hasFields(data) && !editClearsCustomData(composer)) return forward();
3580
3586
  return next({
3581
3587
  ...state,
3582
3588
  localMessage: {
@@ -3600,7 +3606,7 @@ var createDraftCustomDataCompositionMiddleware = (composer) => ({
3600
3606
  forward
3601
3607
  }) => {
3602
3608
  const data = composer.customDataManager.customMessageData;
3603
- if (!data || !Object.keys(data).length) return forward();
3609
+ if (!hasFields(data)) return forward();
3604
3610
  return next({
3605
3611
  ...state,
3606
3612
  draft: {
@@ -3635,6 +3641,80 @@ var userSuggestionToUserResponse = (suggestion) => {
3635
3641
  };
3636
3642
  var userSuggestionToMentionEntity = (suggestion) => userResponseToMentionEntity(userSuggestionToUserResponse(suggestion));
3637
3643
 
3644
+ // src/messageComposer/middleware/textComposer/commandUtils.ts
3645
+ function escapeCommandRegExp(text) {
3646
+ return text.replace(/[-[\]{}()*+?.,/\\^$|#]/g, "\\$&");
3647
+ }
3648
+ var getRawCommandName = (text) => text?.match(/^\/(\S+)(?:\s.*)?$/)?.[1];
3649
+ var getCompleteCommandInString = (text) => {
3650
+ const match = text.match(/^\/(\S+)\s+.*/);
3651
+ const commandName = match && match[1];
3652
+ return commandName;
3653
+ };
3654
+ var stripCommandFromText = (text, commandName) => text.replace(new RegExp(`^${escapeCommandRegExp(`/${commandName}`)}\\s*`, "i"), "");
3655
+ var textStartsWithCommand = (text, commandName) => new RegExp(`^${escapeCommandRegExp(`/${commandName}`)}(\\s|$)`, "i").test(text);
3656
+ var commandTakesNoArguments = (command) => !command.args?.trim();
3657
+ var stripMentionTokens = (text, mentionedUsersInText, trigger = "@") => mentionedUsersInText.reduce((value, user) => {
3658
+ let next = value.replace(`${trigger}${user.id}`, "");
3659
+ if (user.name) {
3660
+ next = next.replace(`${trigger}${user.name}`, "");
3661
+ }
3662
+ return next.trim();
3663
+ }, text.trim());
3664
+ var getMentionedUsersInText = (text, mentionedUsers) => Array.from(
3665
+ new Set(
3666
+ mentionedUsers.filter(
3667
+ ({ id, name }) => text.includes(`@${id}`) || !!name && text.includes(`@${name}`)
3668
+ )
3669
+ )
3670
+ );
3671
+ var getCommandByName = (searchSource, commandName) => {
3672
+ if (!commandName) return;
3673
+ const normalizedCommandName = commandName.toLowerCase();
3674
+ return searchSource.query(normalizedCommandName).items.find((command) => command.name?.toLowerCase() === normalizedCommandName);
3675
+ };
3676
+ var notifyCommandDisabled = (composer, command) => {
3677
+ const disabledReason = composer.getCommandDisabledReason(command);
3678
+ if (!disabledReason) return;
3679
+ composer.client.notifications.addWarning({
3680
+ message: disabledReason === "editing" ? "Command not available while editing" : "Command not available while replying",
3681
+ origin: {
3682
+ emitter: "MessageComposer",
3683
+ context: { command, composer }
3684
+ },
3685
+ options: {
3686
+ type: CORE_NOTIFICATION_TYPE.commandDisabled,
3687
+ metadata: {
3688
+ command: command.name,
3689
+ reason: disabledReason
3690
+ }
3691
+ }
3692
+ });
3693
+ return true;
3694
+ };
3695
+ var notifyCommandNotReady = ({
3696
+ composer,
3697
+ sendability
3698
+ }) => {
3699
+ if (sendability.ready) return;
3700
+ composer.client.notifications.addWarning({
3701
+ message: "Command not ready to be sent",
3702
+ origin: {
3703
+ emitter: "MessageComposer",
3704
+ context: { command: sendability.command, composer }
3705
+ },
3706
+ options: {
3707
+ type: CORE_NOTIFICATION_TYPE.commandNotReady,
3708
+ metadata: {
3709
+ command: sendability.command.name,
3710
+ ...sendability.reason ? { reason: sendability.reason } : {},
3711
+ ...sendability.metadata ?? {}
3712
+ }
3713
+ }
3714
+ });
3715
+ return true;
3716
+ };
3717
+
3638
3718
  // src/messageComposer/textComposer.ts
3639
3719
  var textIsEmpty = (text) => {
3640
3720
  const trimmedText = text.trim();
@@ -3987,6 +4067,14 @@ var TextComposer = class {
3987
4067
  get textIsEmpty() {
3988
4068
  return textIsEmpty(this.text);
3989
4069
  }
4070
+ /**
4071
+ * Whether the active command is content on its own: a command that takes no arguments is sent as
4072
+ * `/shrug` with no text. A command that takes arguments still needs text.
4073
+ */
4074
+ get activeCommandIsContent() {
4075
+ const { command } = this;
4076
+ return !!command && commandTakesNoArguments(command);
4077
+ }
3990
4078
  setMentionedUsers(users) {
3991
4079
  const nonUserMentions = this.mentions.filter(
3992
4080
  (entity) => !isUserMentionEntity(entity)
@@ -7105,7 +7193,7 @@ var BasePaginator = class {
7105
7193
  if (interval && updateState) {
7106
7194
  this.setActiveInterval(interval, { updateState: false });
7107
7195
  stateUpdate.items = this.intervalToItems(interval);
7108
- } else if (updateState && !items.length && (keepPreviousItems || !isFirstPage)) {
7196
+ } else if (updateState && !filteredItems.length && (keepPreviousItems || !isFirstPage)) {
7109
7197
  stateUpdate.items = this.items;
7110
7198
  }
7111
7199
  const continuesActiveIntervalFlags = !isSeparateInterval || !!interval && this.isActiveInterval(interval);
@@ -10905,7 +10993,7 @@ var MessageSearchSource = class extends BaseSearchSource {
10905
10993
  initialFilterConfig: {
10906
10994
  text: {
10907
10995
  enabled: true,
10908
- generate: ({ searchQuery }) => searchQuery ? { text: searchQuery } : null
10996
+ generate: ({ searchQuery }) => searchQuery ? { text: { $autocomplete: searchQuery } } : null
10909
10997
  },
10910
10998
  ...filterBuilderOptions?.messageSearch?.initialFilterConfig
10911
10999
  }
@@ -11032,78 +11120,6 @@ var MessageSearchSource = class extends BaseSearchSource {
11032
11120
  }
11033
11121
  };
11034
11122
 
11035
- // src/messageComposer/middleware/textComposer/commandUtils.ts
11036
- function escapeCommandRegExp(text) {
11037
- return text.replace(/[-[\]{}()*+?.,/\\^$|#]/g, "\\$&");
11038
- }
11039
- var getRawCommandName = (text) => text?.match(/^\/(\S+)(?:\s.*)?$/)?.[1];
11040
- var getCompleteCommandInString = (text) => {
11041
- const match = text.match(/^\/(\S+)\s+.*/);
11042
- const commandName = match && match[1];
11043
- return commandName;
11044
- };
11045
- var stripCommandFromText = (text, commandName) => text.replace(new RegExp(`^${escapeCommandRegExp(`/${commandName}`)}\\s*`), "");
11046
- var stripMentionTokens = (text, mentionedUsersInText, trigger = "@") => mentionedUsersInText.reduce((value, user) => {
11047
- let next = value.replace(`${trigger}${user.id}`, "");
11048
- if (user.name) {
11049
- next = next.replace(`${trigger}${user.name}`, "");
11050
- }
11051
- return next.trim();
11052
- }, text.trim());
11053
- var getMentionedUsersInText = (text, mentionedUsers) => Array.from(
11054
- new Set(
11055
- mentionedUsers.filter(
11056
- ({ id, name }) => text.includes(`@${id}`) || !!name && text.includes(`@${name}`)
11057
- )
11058
- )
11059
- );
11060
- var getCommandByName = (searchSource, commandName) => {
11061
- if (!commandName) return;
11062
- const normalizedCommandName = commandName.toLowerCase();
11063
- return searchSource.query(normalizedCommandName).items.find((command) => command.name?.toLowerCase() === normalizedCommandName);
11064
- };
11065
- var notifyCommandDisabled = (composer, command) => {
11066
- const disabledReason = composer.getCommandDisabledReason(command);
11067
- if (!disabledReason) return;
11068
- composer.client.notifications.addWarning({
11069
- message: disabledReason === "editing" ? "Command not available while editing" : "Command not available while replying",
11070
- origin: {
11071
- emitter: "MessageComposer",
11072
- context: { command, composer }
11073
- },
11074
- options: {
11075
- type: CORE_NOTIFICATION_TYPE.commandDisabled,
11076
- metadata: {
11077
- command: command.name,
11078
- reason: disabledReason
11079
- }
11080
- }
11081
- });
11082
- return true;
11083
- };
11084
- var notifyCommandNotReady = ({
11085
- composer,
11086
- sendability
11087
- }) => {
11088
- if (sendability.ready) return;
11089
- composer.client.notifications.addWarning({
11090
- message: "Command not ready to be sent",
11091
- origin: {
11092
- emitter: "MessageComposer",
11093
- context: { command: sendability.command, composer }
11094
- },
11095
- options: {
11096
- type: CORE_NOTIFICATION_TYPE.commandNotReady,
11097
- metadata: {
11098
- command: sendability.command.name,
11099
- ...sendability.reason ? { reason: sendability.reason } : {},
11100
- ...sendability.metadata ?? {}
11101
- }
11102
- }
11103
- });
11104
- return true;
11105
- };
11106
-
11107
11123
  // src/messageComposer/middleware/textComposer/textMiddlewareUtils.ts
11108
11124
  var getTriggerCharWithToken = ({
11109
11125
  trigger,
@@ -11635,9 +11651,66 @@ var createDraftMessageComposerStateCompositionMiddleware = (composer) => ({
11635
11651
  }
11636
11652
  });
11637
11653
 
11654
+ // src/messageComposer/middleware/messageComposer/commandInjection.ts
11655
+ var createCommandInjectionMiddleware = (composer) => ({
11656
+ handlers: {
11657
+ compose: ({
11658
+ forward,
11659
+ next,
11660
+ state
11661
+ }) => {
11662
+ const command = composer.textComposer.command;
11663
+ const { text } = state.localMessage;
11664
+ if (!command || textStartsWithCommand(text, command.name)) {
11665
+ return forward();
11666
+ }
11667
+ const injection = `/${command?.name}`;
11668
+ const enrichedText = `${injection} ${text}`;
11669
+ return next({
11670
+ ...state,
11671
+ localMessage: {
11672
+ ...state.localMessage,
11673
+ text: enrichedText
11674
+ },
11675
+ message: {
11676
+ ...state.message,
11677
+ text: enrichedText
11678
+ }
11679
+ });
11680
+ }
11681
+ },
11682
+ id: "stream-io/message-composer-middleware/command-string-injection"
11683
+ });
11684
+ var createDraftCommandInjectionMiddleware = (composer) => ({
11685
+ handlers: {
11686
+ compose: ({
11687
+ forward,
11688
+ next,
11689
+ state
11690
+ }) => {
11691
+ const command = composer.textComposer.command;
11692
+ const { text } = state.draft;
11693
+ if (!command || textStartsWithCommand(text ?? "", command.name)) {
11694
+ return forward();
11695
+ }
11696
+ const injection = `/${command?.name}`;
11697
+ const enrichedText = `${injection} ${text}`;
11698
+ return next({
11699
+ ...state,
11700
+ draft: {
11701
+ ...state.draft,
11702
+ text: enrichedText
11703
+ }
11704
+ });
11705
+ }
11706
+ },
11707
+ id: "stream-io/message-composer-middleware/draft-command-string-injection"
11708
+ });
11709
+
11638
11710
  // src/messageComposer/middleware/messageComposer/userDataInjection.ts
11711
+ var USER_DATA_INJECTION_MIDDLEWARE_ID = "stream-io/message-composer-middleware/user-data-injection";
11639
11712
  var createUserDataInjectionMiddleware = (composer) => ({
11640
- id: "stream-io/message-composer-middleware/user-data-injection",
11713
+ id: USER_DATA_INJECTION_MIDDLEWARE_ID,
11641
11714
  handlers: {
11642
11715
  compose: ({
11643
11716
  state,
@@ -11753,6 +11826,7 @@ var MessageComposerMiddlewareExecutor = class extends MiddlewareExecutor {
11753
11826
  createPollOnlyCompositionMiddleware(composer),
11754
11827
  createTextComposerCompositionMiddleware(composer),
11755
11828
  createAttachmentsCompositionMiddleware(composer),
11829
+ createCommandInjectionMiddleware(composer),
11756
11830
  createLinkPreviewsCompositionMiddleware(composer),
11757
11831
  createSharedLocationCompositionMiddleware(composer),
11758
11832
  createMessageComposerStateCompositionMiddleware(composer),
@@ -11768,6 +11842,7 @@ var MessageDraftComposerMiddlewareExecutor = class extends MiddlewareExecutor {
11768
11842
  this.use([
11769
11843
  createDraftTextComposerCompositionMiddleware(composer),
11770
11844
  createDraftAttachmentsCompositionMiddleware(composer),
11845
+ createDraftCommandInjectionMiddleware(composer),
11771
11846
  createDraftLinkPreviewsCompositionMiddleware(composer),
11772
11847
  createDraftMessageComposerStateCompositionMiddleware(composer),
11773
11848
  createDraftCustomDataCompositionMiddleware(composer),
@@ -11776,62 +11851,6 @@ var MessageDraftComposerMiddlewareExecutor = class extends MiddlewareExecutor {
11776
11851
  }
11777
11852
  };
11778
11853
 
11779
- // src/messageComposer/middleware/messageComposer/commandInjection.ts
11780
- var createCommandInjectionMiddleware = (composer) => ({
11781
- handlers: {
11782
- compose: ({
11783
- forward,
11784
- next,
11785
- state
11786
- }) => {
11787
- const command = composer.textComposer.command;
11788
- if (!command) {
11789
- return forward();
11790
- }
11791
- const { text } = state.localMessage;
11792
- const injection = `/${command?.name}`;
11793
- const enrichedText = `${injection} ${text}`;
11794
- return next({
11795
- ...state,
11796
- localMessage: {
11797
- ...state.localMessage,
11798
- text: enrichedText
11799
- },
11800
- message: {
11801
- ...state.message,
11802
- text: enrichedText
11803
- }
11804
- });
11805
- }
11806
- },
11807
- id: "stream-io/message-composer-middleware/command-string-injection"
11808
- });
11809
- var createDraftCommandInjectionMiddleware = (composer) => ({
11810
- handlers: {
11811
- compose: ({
11812
- forward,
11813
- next,
11814
- state
11815
- }) => {
11816
- const command = composer.textComposer.command;
11817
- if (!command) {
11818
- return forward();
11819
- }
11820
- const { text } = state.draft;
11821
- const injection = `/${command?.name}`;
11822
- const enrichedText = `${injection} ${text}`;
11823
- return next({
11824
- ...state,
11825
- draft: {
11826
- ...state.draft,
11827
- text: enrichedText
11828
- }
11829
- });
11830
- }
11831
- },
11832
- id: "stream-io/message-composer-middleware/draft-command-string-injection"
11833
- });
11834
-
11835
11854
  // src/messageComposer/middleware/pollComposer/validation.ts
11836
11855
  var POLL_COMPOSER_VALIDATION_CODE = {
11837
11856
  maxVotesNotNumeric: "validation:poll:maxVotes:notNumeric",
@@ -12833,9 +12852,14 @@ var TextComposerMiddlewareExecutor = class extends MiddlewareExecutor {
12833
12852
  this.use([
12834
12853
  createTextComposerPreValidationMiddleware(composer),
12835
12854
  createMentionsMiddleware(composer.channel),
12855
+ // While a command is active, the guard stops the commands middleware from suggesting or
12856
+ // activating another one. The extraction moves the active command out of the text, which
12857
+ // the command injection composition middleware puts back in front of the sent text.
12858
+ createActiveCommandGuardMiddleware(),
12836
12859
  createCommandsMiddleware(composer.channel, {
12837
12860
  composer
12838
12861
  }),
12862
+ createCommandStringExtractionMiddleware(),
12839
12863
  createCommandEffectsMiddleware()
12840
12864
  ]);
12841
12865
  }
@@ -13745,6 +13769,22 @@ var QUEUEABLE_OPERATIONS = {
13745
13769
  }
13746
13770
  channelOf(client, task).messagePaginator.trackLatestMessage(formatMessage(message));
13747
13771
  },
13772
+ // the server has the message, meaning an earlier attempt landed but its response was lost
13773
+ onReplayRejected: ({ client, error, task }) => {
13774
+ const store = client.messageStore;
13775
+ const held = store.get(task.messageId);
13776
+ if (held?.status === "failed" && isAlreadyExistsError(error, parseError(error))) {
13777
+ const received = { ...held, error: void 0, status: "received" };
13778
+ store.upsert(received);
13779
+ store.flushSubscribers(received.id);
13780
+ client.offlineDb?.executeQuerySafely(
13781
+ (db) => db.upsertMessageWithChannelGuard({
13782
+ message: { ...received, cid: `${task.channelType}:${task.channelId}` }
13783
+ }),
13784
+ { method: "sendMessage:replayRejected" }
13785
+ );
13786
+ }
13787
+ },
13748
13788
  run: ({ channel, client, task }) => channelOf(client, task, channel).sendMessage(...task.payload)
13749
13789
  },
13750
13790
  "send-reaction": {
@@ -14745,6 +14785,10 @@ var MessageOperationStatePolicy = class {
14745
14785
  }
14746
14786
  return unhandledKind(kind);
14747
14787
  }
14788
+ /**
14789
+ * Records a failed request. Resolves `true` when the error shows the request took effect on the
14790
+ * server, so the operation succeeded after all.
14791
+ */
14748
14792
  async failure({
14749
14793
  error,
14750
14794
  kind,
@@ -14754,23 +14798,27 @@ var MessageOperationStatePolicy = class {
14754
14798
  options
14755
14799
  }) {
14756
14800
  const parsed = parseError(error);
14757
- if (isAlreadyExistsError(error, parsed)) {
14801
+ if ((kind === "send" || kind === "retry") && isAlreadyExistsError(error, parsed)) {
14758
14802
  const existing = this.ctx.get(messageId);
14759
14803
  if (existing?.status === "sending") {
14760
- const received = { ...localMessage, status: "received" };
14804
+ const received = {
14805
+ ...localMessage,
14806
+ error: void 0,
14807
+ status: "received"
14808
+ };
14761
14809
  this.ctx.ingest(received);
14762
14810
  this.ctx.persist(received);
14763
14811
  }
14764
- return;
14812
+ return true;
14765
14813
  }
14766
14814
  const pendingTaskTypes = PENDING_WHEN_QUEUED[kind];
14767
14815
  const queued = pendingTaskTypes.length > 0 && await this.ctx.isQueued(messageId, pendingTaskTypes);
14768
14816
  if (kind === "delete") {
14769
14817
  if (!queued) this.revertDelete({ messageId, optimistic, options });
14770
- return;
14818
+ return false;
14771
14819
  }
14772
14820
  if (kind === "update") {
14773
- if (queued) return;
14821
+ if (queued) return false;
14774
14822
  const failed = {
14775
14823
  ...this.ctx.get(messageId) ?? localMessage,
14776
14824
  error: parsed,
@@ -14778,13 +14826,14 @@ var MessageOperationStatePolicy = class {
14778
14826
  };
14779
14827
  this.ctx.ingest(failed);
14780
14828
  this.ctx.persist(failed);
14781
- return;
14829
+ return false;
14782
14830
  }
14783
14831
  if (kind === "send" || kind === "retry") {
14832
+ if (this.ctx.get(messageId)?.status === "received") return true;
14784
14833
  const failed = { ...localMessage, error: parsed, status: "failed" };
14785
14834
  this.ctx.ingest(failed);
14786
14835
  this.ctx.persist(failed);
14787
- return;
14836
+ return false;
14788
14837
  }
14789
14838
  return unhandledKind(kind);
14790
14839
  }
@@ -14912,7 +14961,7 @@ var MessageOperations = class {
14912
14961
  options: params.options
14913
14962
  });
14914
14963
  } catch (e) {
14915
- await this.policy.failure({
14964
+ const succeeded = await this.policy.failure({
14916
14965
  error: e,
14917
14966
  kind,
14918
14967
  localMessage: effective.localMessage,
@@ -14920,7 +14969,7 @@ var MessageOperations = class {
14920
14969
  optimistic,
14921
14970
  options: params.options
14922
14971
  });
14923
- throw e;
14972
+ if (!succeeded) throw e;
14924
14973
  }
14925
14974
  }
14926
14975
  /*
@@ -18093,8 +18142,10 @@ var _MessageComposer = class _MessageComposer extends WithSubscriptions {
18093
18142
  }
18094
18143
  this.clear();
18095
18144
  }).unsubscribe;
18145
+ // The command is selected too: an active command that takes no arguments is content, so clearing
18146
+ // one can empty the composition without changing the text.
18096
18147
  this.subscribeTextComposerStateChanged = () => this.textComposer.state.subscribeWithSelector(
18097
- ({ text }) => [text],
18148
+ ({ command, text }) => [text, command],
18098
18149
  ([currentText], previousSelection) => {
18099
18150
  if (typeof previousSelection === "undefined") return;
18100
18151
  this.logStateUpdateTimestamp();
@@ -18590,15 +18641,15 @@ var _MessageComposer = class _MessageComposer extends WithSubscriptions {
18590
18641
  const hasSendableAttachment = this.attachmentManager.attachments.some(
18591
18642
  (attachment) => isFinishedUpload(attachment) || isPendingUpload(attachment) || isFailedUpload(attachment)
18592
18643
  );
18593
- return !!(!this.textComposer.textIsEmpty || hasSendableAttachment || this.pollId || this.locationComposer.validLocation);
18644
+ return !!(!this.textComposer.textIsEmpty || this.textComposer.activeCommandIsContent || hasSendableAttachment || this.pollId || this.locationComposer.validLocation);
18594
18645
  }
18595
- return !!(!this.attachmentManager.uploadsInProgressCount && (!this.textComposer.textIsEmpty || this.attachmentManager.successfulUploadsCount > 0) || this.pollId || !!this.locationComposer.validLocation);
18646
+ return !!(!this.attachmentManager.uploadsInProgressCount && (!this.textComposer.textIsEmpty || this.textComposer.activeCommandIsContent || this.attachmentManager.successfulUploadsCount > 0) || this.pollId || !!this.locationComposer.validLocation);
18596
18647
  }
18597
18648
  get compositionIsEmpty() {
18598
18649
  return !this.quotedMessage && this.contentIsEmpty;
18599
18650
  }
18600
18651
  get contentIsEmpty() {
18601
- return this.textComposer.textIsEmpty && !this.attachmentManager.attachments.length && !this.pollId && !this.locationComposer.validLocation;
18652
+ return this.textComposer.textIsEmpty && !this.textComposer.activeCommandIsContent && !this.attachmentManager.attachments.length && !this.pollId && !this.locationComposer.validLocation;
18602
18653
  }
18603
18654
  get lastChangeOriginIsLocal() {
18604
18655
  const initiatedWithoutDraft = this.lastChange.draftUpdate === null;
@@ -25205,7 +25256,7 @@ var StreamChat = class _StreamChat extends ChatApi {
25205
25256
  return this.userAgent;
25206
25257
  }
25207
25258
  if (!this.cachedUserAgent) {
25208
- const version = "10.0.0-rc.30";
25259
+ const version = "10.0.0-rc.31";
25209
25260
  const { name: sdkName, version: sdkVersion } = this.sdkIdentifier ?? {};
25210
25261
  const { name: appName, version: appVersion } = this.appIdentifier ?? {};
25211
25262
  const { os, model: deviceModel } = this.deviceIdentifier ?? {};
@@ -27723,6 +27774,8 @@ var AbstractOfflineDB = class {
27723
27774
  true
27724
27775
  );
27725
27776
  } catch (e) {
27777
+ const operation = QUEUEABLE_OPERATIONS[task.type];
27778
+ operation.onReplayRejected?.({ client: this.client, error: e, task });
27726
27779
  const error = e;
27727
27780
  if (!this.shouldSkipQueueingTask(error)) {
27728
27781
  continue;