@stream-io/video-client 1.38.0 → 1.38.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.
- package/CHANGELOG.md +13 -0
- package/dist/index.browser.es.js +19 -26
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +19 -26
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +19 -26
- package/dist/index.es.js.map +1 -1
- package/dist/src/store/stateStore.d.ts +6 -0
- package/package.json +1 -1
- package/src/Call.ts +2 -2
- package/src/store/CallState.ts +2 -25
- package/src/store/stateStore.ts +15 -0
|
@@ -38,6 +38,12 @@ export declare class StreamVideoWriteableStateStore {
|
|
|
38
38
|
* @param call the call to add.
|
|
39
39
|
*/
|
|
40
40
|
registerCall: (call: Call) => void;
|
|
41
|
+
/**
|
|
42
|
+
* Registers a {@link Call} object if it doesn't exist, otherwise updates it.
|
|
43
|
+
*
|
|
44
|
+
* @param call the call to register or update.
|
|
45
|
+
*/
|
|
46
|
+
registerOrUpdateCall: (call: Call) => void | Call[];
|
|
41
47
|
/**
|
|
42
48
|
* Removes a {@link Call} object from the list of {@link Call} objects created/tracked by this client.
|
|
43
49
|
*
|
package/package.json
CHANGED
package/src/Call.ts
CHANGED
|
@@ -757,7 +757,7 @@ export class Call {
|
|
|
757
757
|
|
|
758
758
|
if (this.streamClient._hasConnectionID()) {
|
|
759
759
|
this.watching = true;
|
|
760
|
-
this.clientStore.
|
|
760
|
+
this.clientStore.registerOrUpdateCall(this);
|
|
761
761
|
}
|
|
762
762
|
|
|
763
763
|
await this.applyDeviceConfig(response.call.settings, false);
|
|
@@ -787,7 +787,7 @@ export class Call {
|
|
|
787
787
|
|
|
788
788
|
if (this.streamClient._hasConnectionID()) {
|
|
789
789
|
this.watching = true;
|
|
790
|
-
this.clientStore.
|
|
790
|
+
this.clientStore.registerOrUpdateCall(this);
|
|
791
791
|
}
|
|
792
792
|
|
|
793
793
|
await this.applyDeviceConfig(response.call.settings, false);
|
package/src/store/CallState.ts
CHANGED
|
@@ -74,29 +74,6 @@ type OrphanedTrack = {
|
|
|
74
74
|
track: MediaStream;
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
-
/**
|
|
78
|
-
* Creates a stable participant filter function, ready to be used in combination
|
|
79
|
-
* with the `useSyncExternalStore` hook.
|
|
80
|
-
*
|
|
81
|
-
* @param predicate the predicate to use.
|
|
82
|
-
*/
|
|
83
|
-
const createStableParticipantsFilter = (
|
|
84
|
-
predicate: (p: StreamVideoParticipant) => boolean,
|
|
85
|
-
) => {
|
|
86
|
-
const empty: StreamVideoParticipant[] = [];
|
|
87
|
-
return (participants: StreamVideoParticipant[]) => {
|
|
88
|
-
// no need to filter if there are no participants
|
|
89
|
-
if (!participants.length) return participants;
|
|
90
|
-
|
|
91
|
-
// return a stable empty array if there are no remote participants
|
|
92
|
-
// instead of creating an empty one
|
|
93
|
-
const filteredParticipants = participants.filter(predicate);
|
|
94
|
-
if (!filteredParticipants.length) return empty;
|
|
95
|
-
|
|
96
|
-
return filteredParticipants;
|
|
97
|
-
};
|
|
98
|
-
};
|
|
99
|
-
|
|
100
77
|
/**
|
|
101
78
|
* Holds the state of the current call.
|
|
102
79
|
* @react You don't have to use this class directly, as we are exposing the state through Hooks.
|
|
@@ -376,12 +353,12 @@ export class CallState {
|
|
|
376
353
|
);
|
|
377
354
|
|
|
378
355
|
this.remoteParticipants$ = this.participants$.pipe(
|
|
379
|
-
map(
|
|
356
|
+
map((participants) => participants.filter((p) => !p.isLocalParticipant)),
|
|
380
357
|
shareReplay({ bufferSize: 1, refCount: true }),
|
|
381
358
|
);
|
|
382
359
|
|
|
383
360
|
this.pinnedParticipants$ = this.participants$.pipe(
|
|
384
|
-
map(
|
|
361
|
+
map((participants) => participants.filter((p) => !!p.pin)),
|
|
385
362
|
shareReplay({ bufferSize: 1, refCount: true }),
|
|
386
363
|
);
|
|
387
364
|
|
package/src/store/stateStore.ts
CHANGED
|
@@ -81,6 +81,21 @@ export class StreamVideoWriteableStateStore {
|
|
|
81
81
|
}
|
|
82
82
|
};
|
|
83
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Registers a {@link Call} object if it doesn't exist, otherwise updates it.
|
|
86
|
+
*
|
|
87
|
+
* @param call the call to register or update.
|
|
88
|
+
*/
|
|
89
|
+
registerOrUpdateCall = (call: Call) => {
|
|
90
|
+
if (this.calls.find((c) => c.cid === call.cid)) {
|
|
91
|
+
return this.setCalls((calls) =>
|
|
92
|
+
calls.map((c) => (c.cid === call.cid ? call : c)),
|
|
93
|
+
);
|
|
94
|
+
} else {
|
|
95
|
+
return this.registerCall(call);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
84
99
|
/**
|
|
85
100
|
* Removes a {@link Call} object from the list of {@link Call} objects created/tracked by this client.
|
|
86
101
|
*
|