stream-chat 9.50.0 → 9.50.2

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.
@@ -33,6 +33,8 @@ export declare class AttachmentManager {
33
33
  setCustomUploadFn: (doUploadRequest: UploadRequestFn) => void;
34
34
  get attachments(): LocalAttachment[];
35
35
  get hasUploadPermission(): boolean;
36
+ get hasCustomDoUploadRequest(): boolean;
37
+ get hasAvailableUploadSlots(): boolean;
36
38
  get isUploadEnabled(): boolean;
37
39
  get successfulUploads(): LocalAttachment[];
38
40
  get successfulUploadsCount(): number;
@@ -5,6 +5,7 @@ import type { QueryThreadsOptions } from './types';
5
5
  import { WithSubscriptions } from './utils/WithSubscriptions';
6
6
  export declare const THREAD_MANAGER_INITIAL_STATE: {
7
7
  active: boolean;
8
+ wasActivatedAtLeastOnce: boolean;
8
9
  isThreadOrderStale: boolean;
9
10
  threads: never[];
10
11
  unreadThreadCount: number;
@@ -19,6 +20,12 @@ export declare const THREAD_MANAGER_INITIAL_STATE: {
19
20
  };
20
21
  export type ThreadManagerState = {
21
22
  active: boolean;
23
+ /**
24
+ * Whether the thread manager has been activated at least once in the current
25
+ * session (i.e. `activate()` was called). Used to avoid requerying threads
26
+ * on connection recovery for consumers that never actually activate the manager.
27
+ */
28
+ wasActivatedAtLeastOnce: boolean;
22
29
  isThreadOrderStale: boolean;
23
30
  lastConnectionDropAt: Date | null;
24
31
  pagination: ThreadManagerPagination;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stream-chat",
3
- "version": "9.50.0",
3
+ "version": "9.50.2",
4
4
  "description": "JS SDK for the Stream Chat API",
5
5
  "homepage": "https://getstream.io/chat/",
6
6
  "author": {
@@ -168,8 +168,16 @@ export class AttachmentManager {
168
168
  )?.includes('upload-file');
169
169
  }
170
170
 
171
+ get hasCustomDoUploadRequest() {
172
+ return typeof this.config.doUploadRequest === 'function';
173
+ }
174
+
175
+ get hasAvailableUploadSlots() {
176
+ return this.availableUploadSlots > 0;
177
+ }
178
+
171
179
  get isUploadEnabled() {
172
- return this.hasUploadPermission && this.availableUploadSlots > 0;
180
+ return this.hasUploadPermission && this.hasAvailableUploadSlots;
173
181
  }
174
182
 
175
183
  get successfulUploads() {
@@ -726,7 +734,12 @@ export class AttachmentManager {
726
734
  };
727
735
 
728
736
  uploadFiles = async (files: FileReference[] | FileList | FileLike[]) => {
729
- if (!this.isUploadEnabled) return;
737
+ if (
738
+ (this.hasCustomDoUploadRequest && !this.hasAvailableUploadSlots) ||
739
+ (!this.hasCustomDoUploadRequest && !this.isUploadEnabled)
740
+ )
741
+ return;
742
+
730
743
  const iterableFiles: FileReference[] | FileLike[] = isFileList(files)
731
744
  ? Array.from(files)
732
745
  : files;
@@ -10,6 +10,7 @@ const DEFAULT_CONNECTION_RECOVERY_THROTTLE_DURATION = 1000;
10
10
  const MAX_QUERY_THREADS_LIMIT = 25;
11
11
  export const THREAD_MANAGER_INITIAL_STATE = {
12
12
  active: false,
13
+ wasActivatedAtLeastOnce: false,
13
14
  isThreadOrderStale: false,
14
15
  threads: [],
15
16
  unreadThreadCount: 0,
@@ -25,6 +26,12 @@ export const THREAD_MANAGER_INITIAL_STATE = {
25
26
 
26
27
  export type ThreadManagerState = {
27
28
  active: boolean;
29
+ /**
30
+ * Whether the thread manager has been activated at least once in the current
31
+ * session (i.e. `activate()` was called). Used to avoid requerying threads
32
+ * on connection recovery for consumers that never actually activate the manager.
33
+ */
34
+ wasActivatedAtLeastOnce: boolean;
28
35
  isThreadOrderStale: boolean;
29
36
  lastConnectionDropAt: Date | null;
30
37
  pagination: ThreadManagerPagination;
@@ -90,7 +97,7 @@ export class ThreadManager extends WithSubscriptions {
90
97
  };
91
98
 
92
99
  public activate = () => {
93
- this.state.partialNext({ active: true });
100
+ this.state.partialNext({ active: true, wasActivatedAtLeastOnce: true });
94
101
  };
95
102
 
96
103
  public deactivate = () => {
@@ -197,8 +204,9 @@ export class ThreadManager extends WithSubscriptions {
197
204
 
198
205
  const throttledHandleConnectionRecovered = throttle(
199
206
  () => {
200
- const { lastConnectionDropAt } = this.state.getLatestValue();
201
- if (!lastConnectionDropAt) return;
207
+ const { lastConnectionDropAt, wasActivatedAtLeastOnce } =
208
+ this.state.getLatestValue();
209
+ if (!lastConnectionDropAt || !wasActivatedAtLeastOnce) return;
202
210
  this.reload({ force: true });
203
211
  },
204
212
  DEFAULT_CONNECTION_RECOVERY_THROTTLE_DURATION,