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.
@@ -3453,7 +3453,8 @@ var _AttachmentManager = class _AttachmentManager {
3453
3453
  return attachment;
3454
3454
  };
3455
3455
  this.uploadFiles = async (files) => {
3456
- if (!this.isUploadEnabled) return;
3456
+ if (this.hasCustomDoUploadRequest && !this.hasAvailableUploadSlots || !this.hasCustomDoUploadRequest && !this.isUploadEnabled)
3457
+ return;
3457
3458
  const iterableFiles = isFileList(files) ? Array.from(files) : files;
3458
3459
  return await Promise.all(
3459
3460
  iterableFiles.slice(0, this.availableUploadSlots).map(this.uploadFile)
@@ -3522,8 +3523,14 @@ var _AttachmentManager = class _AttachmentManager {
3522
3523
  get hasUploadPermission() {
3523
3524
  return !!this.channel.data?.own_capabilities?.includes("upload-file");
3524
3525
  }
3526
+ get hasCustomDoUploadRequest() {
3527
+ return typeof this.config.doUploadRequest === "function";
3528
+ }
3529
+ get hasAvailableUploadSlots() {
3530
+ return this.availableUploadSlots > 0;
3531
+ }
3525
3532
  get isUploadEnabled() {
3526
- return this.hasUploadPermission && this.availableUploadSlots > 0;
3533
+ return this.hasUploadPermission && this.hasAvailableUploadSlots;
3527
3534
  }
3528
3535
  get successfulUploads() {
3529
3536
  return this.getUploadsByState("finished");
@@ -14659,7 +14666,7 @@ var StreamChat = class _StreamChat {
14659
14666
  return this.userAgent;
14660
14667
  }
14661
14668
  if (!this.cachedUserAgent) {
14662
- const version = "9.50.1";
14669
+ const version = "9.50.3";
14663
14670
  const { name: sdkName, version: sdkVersion } = this.sdkIdentifier ?? {};
14664
14671
  const { name: appName, version: appVersion } = this.appIdentifier ?? {};
14665
14672
  const { os, model: deviceModel } = this.deviceIdentifier ?? {};
@@ -18243,10 +18250,22 @@ var OfflineDBSyncManager = class {
18243
18250
  */
18244
18251
  this.invokeSyncStatusListeners = async (status) => {
18245
18252
  this.syncStatus = status;
18246
- this.syncStatusListeners.forEach((l) => l(status));
18253
+ this.syncStatusListeners.forEach((l) => {
18254
+ try {
18255
+ l(status);
18256
+ } catch (error) {
18257
+ console.log("Error in a sync status listener.", error);
18258
+ }
18259
+ });
18247
18260
  if (status) {
18248
18261
  const promises = Array.from(this.scheduledSyncStatusCallbacks.values()).map(
18249
- (cb) => cb()
18262
+ async (cb) => {
18263
+ try {
18264
+ await cb();
18265
+ } catch (error) {
18266
+ console.log("Error executing a scheduled sync status callback.", error);
18267
+ }
18268
+ }
18250
18269
  );
18251
18270
  await Promise.all(promises);
18252
18271
  this.scheduledSyncStatusCallbacks.clear();
@@ -18308,10 +18327,25 @@ var OfflineDBSyncManager = class {
18308
18327
  };
18309
18328
  /**
18310
18329
  * Executes any tasks that were queued while offline and then performs a sync.
18330
+ *
18331
+ * Each step is isolated so a failure in one does not prevent the other, and
18332
+ * neither can escape to the callers (init + the connection.changed handler).
18333
+ * This guarantees the subsequent invokeSyncStatusListeners(true) always runs,
18334
+ * so syncStatus recovers to true and gated channel queries are unblocked.
18335
+ * Failed syncs degrade to "possibly stale data until the next query" rather
18336
+ * than freezing all future queries. See issue #1816.
18311
18337
  */
18312
18338
  this.syncAndExecutePendingTasks = async () => {
18313
- await this.offlineDb.executePendingTasks();
18314
- await this.sync();
18339
+ try {
18340
+ await this.offlineDb.executePendingTasks();
18341
+ } catch (error) {
18342
+ console.log("Error executing pending tasks during sync.", error);
18343
+ }
18344
+ try {
18345
+ await this.sync();
18346
+ } catch (error) {
18347
+ console.log("Error while syncing the DB.", error);
18348
+ }
18315
18349
  };
18316
18350
  this.client = client;
18317
18351
  this.offlineDb = offlineDb;