@stream-io/video-client 0.4.8 → 0.4.10
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 +14 -0
- package/dist/index.browser.es.js +28 -4
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +28 -4
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +28 -4
- package/dist/index.es.js.map +1 -1
- package/dist/src/StreamVideoServerClient.d.ts +5 -0
- package/package.json +1 -1
- package/src/StreamVideoServerClient.ts +5 -0
- package/src/__tests__/server-side/call-types.test.ts +1 -1
- package/src/store/CallState.ts +23 -3
- package/src/store/__tests__/CallState.test.ts +50 -0
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { StreamVideoClient } from './StreamVideoClient';
|
|
2
2
|
import { StreamClientOptions } from './coordinator/connection/types';
|
|
3
3
|
import { CreateCallTypeRequest, CreateCallTypeResponse, GetCallTypeResponse, ListCallTypeResponse, UpdateCallTypeRequest, UpdateCallTypeResponse } from './gen/coordinator';
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated Please use the `@stream-io/node-sdk` package instead.
|
|
6
|
+
*
|
|
7
|
+
* @see https://getstream.io/video/docs/api/
|
|
8
|
+
*/
|
|
4
9
|
export declare class StreamVideoServerClient extends StreamVideoClient {
|
|
5
10
|
constructor(apiKey: string, options: StreamClientOptions);
|
|
6
11
|
/**
|
package/package.json
CHANGED
|
@@ -9,6 +9,11 @@ import {
|
|
|
9
9
|
UpdateCallTypeResponse,
|
|
10
10
|
} from './gen/coordinator';
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated Please use the `@stream-io/node-sdk` package instead.
|
|
14
|
+
*
|
|
15
|
+
* @see https://getstream.io/video/docs/api/
|
|
16
|
+
*/
|
|
12
17
|
export class StreamVideoServerClient extends StreamVideoClient {
|
|
13
18
|
constructor(apiKey: string, options: StreamClientOptions) {
|
|
14
19
|
super({ apiKey, options });
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
const apiKey = process.env.STREAM_API_KEY!;
|
|
12
12
|
const secret = process.env.STREAM_SECRET!;
|
|
13
13
|
|
|
14
|
-
describe('call types CRUD API', () => {
|
|
14
|
+
describe.skip('call types CRUD API', () => {
|
|
15
15
|
let client: StreamVideoServerClient;
|
|
16
16
|
const callTypeName = `calltype${generateUUIDv4()}`;
|
|
17
17
|
|
package/src/store/CallState.ts
CHANGED
|
@@ -1047,13 +1047,33 @@ export class CallState {
|
|
|
1047
1047
|
return session;
|
|
1048
1048
|
}
|
|
1049
1049
|
const { participants, participants_count_by_role } = session;
|
|
1050
|
-
const { user } = event.participant;
|
|
1050
|
+
const { user, user_session_id } = event.participant;
|
|
1051
|
+
// It could happen that the backend delivers the same participant more than once.
|
|
1052
|
+
// Once with the call.session_started event and once again with the
|
|
1053
|
+
// call.session_participant_joined event. In this case,
|
|
1054
|
+
// we should update the existing participant and prevent duplicating it.
|
|
1055
|
+
let shouldInsertParticipant = true;
|
|
1056
|
+
const updatedParticipants = participants.map((p) => {
|
|
1057
|
+
if (p.user_session_id === user_session_id) {
|
|
1058
|
+
shouldInsertParticipant = false;
|
|
1059
|
+
return event.participant;
|
|
1060
|
+
}
|
|
1061
|
+
return p;
|
|
1062
|
+
});
|
|
1063
|
+
if (shouldInsertParticipant) {
|
|
1064
|
+
// this is a new array, we can safely push the new participant
|
|
1065
|
+
updatedParticipants.push(event.participant);
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
// If we are updating an existing participant, we don't want to increment
|
|
1069
|
+
// the participant_by_role count.
|
|
1070
|
+
const increment = shouldInsertParticipant ? 1 : 0;
|
|
1051
1071
|
return {
|
|
1052
1072
|
...session,
|
|
1053
|
-
participants:
|
|
1073
|
+
participants: updatedParticipants,
|
|
1054
1074
|
participants_count_by_role: {
|
|
1055
1075
|
...participants_count_by_role,
|
|
1056
|
-
[user.role]: (participants_count_by_role[user.role] || 0) +
|
|
1076
|
+
[user.role]: (participants_count_by_role[user.role] || 0) + increment,
|
|
1057
1077
|
},
|
|
1058
1078
|
};
|
|
1059
1079
|
});
|
|
@@ -613,6 +613,56 @@ describe('CallState', () => {
|
|
|
613
613
|
},
|
|
614
614
|
});
|
|
615
615
|
});
|
|
616
|
+
|
|
617
|
+
it('should update existing participant', () => {
|
|
618
|
+
const state = new CallState();
|
|
619
|
+
state.updateFromCallResponse({
|
|
620
|
+
// @ts-ignore
|
|
621
|
+
session: {
|
|
622
|
+
participants: [
|
|
623
|
+
{
|
|
624
|
+
// @ts-ignore
|
|
625
|
+
user: {
|
|
626
|
+
id: 'user-id',
|
|
627
|
+
role: 'user',
|
|
628
|
+
},
|
|
629
|
+
user_session_id: '123',
|
|
630
|
+
},
|
|
631
|
+
],
|
|
632
|
+
participants_count_by_role: {
|
|
633
|
+
user: 1,
|
|
634
|
+
},
|
|
635
|
+
},
|
|
636
|
+
});
|
|
637
|
+
state.updateFromEvent({
|
|
638
|
+
type: 'call.session_participant_joined',
|
|
639
|
+
participant: {
|
|
640
|
+
// @ts-ignore
|
|
641
|
+
user: {
|
|
642
|
+
id: 'user-id',
|
|
643
|
+
role: 'user',
|
|
644
|
+
name: 'Updated user',
|
|
645
|
+
},
|
|
646
|
+
user_session_id: '123',
|
|
647
|
+
},
|
|
648
|
+
});
|
|
649
|
+
expect(state.session).toEqual({
|
|
650
|
+
participants: [
|
|
651
|
+
{
|
|
652
|
+
// @ts-ignore
|
|
653
|
+
user: {
|
|
654
|
+
id: 'user-id',
|
|
655
|
+
role: 'user',
|
|
656
|
+
name: 'Updated user',
|
|
657
|
+
},
|
|
658
|
+
user_session_id: '123',
|
|
659
|
+
},
|
|
660
|
+
],
|
|
661
|
+
participants_count_by_role: {
|
|
662
|
+
user: 1,
|
|
663
|
+
},
|
|
664
|
+
});
|
|
665
|
+
});
|
|
616
666
|
});
|
|
617
667
|
});
|
|
618
668
|
});
|