stream-chat 9.50.1 → 9.50.3

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.
@@ -3668,7 +3668,8 @@ var _AttachmentManager = class _AttachmentManager {
3668
3668
  return attachment;
3669
3669
  };
3670
3670
  this.uploadFiles = async (files) => {
3671
- if (!this.isUploadEnabled) return;
3671
+ if (this.hasCustomDoUploadRequest && !this.hasAvailableUploadSlots || !this.hasCustomDoUploadRequest && !this.isUploadEnabled)
3672
+ return;
3672
3673
  const iterableFiles = isFileList(files) ? Array.from(files) : files;
3673
3674
  return await Promise.all(
3674
3675
  iterableFiles.slice(0, this.availableUploadSlots).map(this.uploadFile)
@@ -3737,8 +3738,14 @@ var _AttachmentManager = class _AttachmentManager {
3737
3738
  get hasUploadPermission() {
3738
3739
  return !!this.channel.data?.own_capabilities?.includes("upload-file");
3739
3740
  }
3741
+ get hasCustomDoUploadRequest() {
3742
+ return typeof this.config.doUploadRequest === "function";
3743
+ }
3744
+ get hasAvailableUploadSlots() {
3745
+ return this.availableUploadSlots > 0;
3746
+ }
3740
3747
  get isUploadEnabled() {
3741
- return this.hasUploadPermission && this.availableUploadSlots > 0;
3748
+ return this.hasUploadPermission && this.hasAvailableUploadSlots;
3742
3749
  }
3743
3750
  get successfulUploads() {
3744
3751
  return this.getUploadsByState("finished");
@@ -14874,7 +14881,7 @@ var StreamChat = class _StreamChat {
14874
14881
  return this.userAgent;
14875
14882
  }
14876
14883
  if (!this.cachedUserAgent) {
14877
- const version = "9.50.1";
14884
+ const version = "9.50.3";
14878
14885
  const { name: sdkName, version: sdkVersion } = this.sdkIdentifier ?? {};
14879
14886
  const { name: appName, version: appVersion } = this.appIdentifier ?? {};
14880
14887
  const { os, model: deviceModel } = this.deviceIdentifier ?? {};
@@ -18458,10 +18465,22 @@ var OfflineDBSyncManager = class {
18458
18465
  */
18459
18466
  this.invokeSyncStatusListeners = async (status) => {
18460
18467
  this.syncStatus = status;
18461
- this.syncStatusListeners.forEach((l) => l(status));
18468
+ this.syncStatusListeners.forEach((l) => {
18469
+ try {
18470
+ l(status);
18471
+ } catch (error) {
18472
+ console.log("Error in a sync status listener.", error);
18473
+ }
18474
+ });
18462
18475
  if (status) {
18463
18476
  const promises = Array.from(this.scheduledSyncStatusCallbacks.values()).map(
18464
- (cb) => cb()
18477
+ async (cb) => {
18478
+ try {
18479
+ await cb();
18480
+ } catch (error) {
18481
+ console.log("Error executing a scheduled sync status callback.", error);
18482
+ }
18483
+ }
18465
18484
  );
18466
18485
  await Promise.all(promises);
18467
18486
  this.scheduledSyncStatusCallbacks.clear();
@@ -18523,10 +18542,25 @@ var OfflineDBSyncManager = class {
18523
18542
  };
18524
18543
  /**
18525
18544
  * Executes any tasks that were queued while offline and then performs a sync.
18545
+ *
18546
+ * Each step is isolated so a failure in one does not prevent the other, and
18547
+ * neither can escape to the callers (init + the connection.changed handler).
18548
+ * This guarantees the subsequent invokeSyncStatusListeners(true) always runs,
18549
+ * so syncStatus recovers to true and gated channel queries are unblocked.
18550
+ * Failed syncs degrade to "possibly stale data until the next query" rather
18551
+ * than freezing all future queries. See issue #1816.
18526
18552
  */
18527
18553
  this.syncAndExecutePendingTasks = async () => {
18528
- await this.offlineDb.executePendingTasks();
18529
- await this.sync();
18554
+ try {
18555
+ await this.offlineDb.executePendingTasks();
18556
+ } catch (error) {
18557
+ console.log("Error executing pending tasks during sync.", error);
18558
+ }
18559
+ try {
18560
+ await this.sync();
18561
+ } catch (error) {
18562
+ console.log("Error while syncing the DB.", error);
18563
+ }
18530
18564
  };
18531
18565
  this.client = client;
18532
18566
  this.offlineDb = offlineDb;