@stream-io/video-client 0.7.5 → 0.7.7

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.
@@ -79,6 +79,7 @@ export declare class Call {
79
79
  private sfuClient?;
80
80
  private reconnectAttempts;
81
81
  private maxReconnectAttempts;
82
+ private isLeaving;
82
83
  /**
83
84
  * A list hooks/functions to invoke when the call is left.
84
85
  * A typical use case is to clean up some global event handlers.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stream-io/video-client",
3
- "version": "0.7.5",
3
+ "version": "0.7.7",
4
4
  "packageManager": "yarn@3.2.4",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.es.js",
package/src/Call.ts CHANGED
@@ -216,6 +216,7 @@ export class Call {
216
216
  private sfuClient?: StreamSfuClient;
217
217
  private reconnectAttempts = 0;
218
218
  private maxReconnectAttempts = 10;
219
+ private isLeaving = false;
219
220
 
220
221
  /**
221
222
  * A list hooks/functions to invoke when the call is left.
@@ -479,6 +480,8 @@ export class Call {
479
480
  await this.assertCallJoined();
480
481
  }
481
482
 
483
+ this.isLeaving = true;
484
+
482
485
  if (this.ringing) {
483
486
  // I'm the one who started the call, so I should cancel it.
484
487
  const hasOtherParticipants = this.state.remoteParticipants.length > 0;
@@ -887,6 +890,9 @@ export class Call {
887
890
  // unregister the "goAway" handler, as we won't need it anymore for this connection.
888
891
  // the upcoming re-join will register a new handler anyway
889
892
  unregisterGoAway();
893
+ // when the user has initiated "call.leave()" operation, we shouldn't
894
+ // care for the WS close code and we shouldn't ever attempt to reconnect
895
+ if (this.isLeaving) return;
890
896
  // do nothing if the connection was closed on purpose
891
897
  if (e.code === StreamSfuClient.NORMAL_CLOSURE) return;
892
898
  // do nothing if the connection was closed because of a policy violation
@@ -1933,9 +1939,8 @@ export class Call {
1933
1939
  if (rating < 1 || rating > 5) {
1934
1940
  throw new Error('Rating must be between 1 and 5');
1935
1941
  }
1936
- const userSessionId = this.sfuClient?.sessionId;
1937
1942
  const callSessionId = this.state.session?.id;
1938
- if (!callSessionId || !userSessionId) {
1943
+ if (!callSessionId) {
1939
1944
  throw new Error(
1940
1945
  'Feedback can be submitted only in the context of a call session',
1941
1946
  );
@@ -1945,6 +1950,9 @@ export class Call {
1945
1950
  getClientDetails(),
1946
1951
  );
1947
1952
 
1953
+ // user sessionId is not available once the call has been left
1954
+ // until we relax the backend validation, we'll send N/A
1955
+ const userSessionId = this.sfuClient?.sessionId ?? 'N/A';
1948
1956
  const endpoint = `${this.streamClientBasePath}/feedback/${callSessionId}`;
1949
1957
  return this.streamClient.post<
1950
1958
  CollectUserFeedbackResponse,