Skip to content

Commit

Permalink
feat: merge main to prod
Browse files Browse the repository at this point in the history
  • Loading branch information
raviteja83 authored Sep 22, 2023
2 parents 9de837c + 1ac01df commit 045fd6f
Show file tree
Hide file tree
Showing 87 changed files with 947 additions and 500 deletions.
4 changes: 2 additions & 2 deletions apps/100ms-custom-app/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 24 additions & 4 deletions apps/100ms-custom-app/src/components/InviteLinksModal.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useRef, useState } from 'react';
import {
CheckCircleIcon,
ChevronDownIcon,
ChevronUpIcon,
CrossIcon,
Expand All @@ -19,8 +20,10 @@ import {
const InviteLinksModal = ({ onClose, roomLinks }) => {
const roles = Object.keys(roomLinks);
const [selectedRole, setSelectedRole] = useState(roles[0]);
const [linkCopied, setLinkCopied] = useState(false);
const [open, setOpen] = useState(false);
const ref = useRef();

return (
<Dialog.Root defaultOpen onOpenChange={value => !value && onClose()}>
<Dialog.Portal>
Expand Down Expand Up @@ -90,12 +93,29 @@ const InviteLinksModal = ({ onClose, roomLinks }) => {
variant="standard"
css={{ mt: 'auto' }}
onClick={() => {
navigator.clipboard?.writeText(
getRoomUrl(roomLinks[selectedRole])
);
try {
if (!linkCopied) {
navigator.clipboard?.writeText(
getRoomUrl(roomLinks[selectedRole])
);
setLinkCopied(true);
setTimeout(() => setLinkCopied(false), 2000);
}
} catch (e) {
console.log(e);
}
}}
>
<LinkIcon /> Copy Invite Link
{linkCopied ? (
<>
<CheckCircleIcon />
Link Copied!
</>
) : (
<>
<LinkIcon /> Copy Invite Link
</>
)}
</Button>
</LeftContainer>
<RightContainer>
Expand Down
10 changes: 5 additions & 5 deletions apps/100ms-web/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/hls-player/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/hls-stats/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/hms-noise-suppression/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/hms-video-store/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion packages/hms-video-store/src/core/IHMSActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
TokenRequest,
TokenRequestOptions,
} from '@100mslive/hms-video';
import { IHMSInteractivityCenter } from './hmsSDKStore/HMSInteractivityCenter';
import { HLSConfig, RTMPRecordingConfig } from './hmsSDKStore/sdkTypes';
import {
HMSChangeMultiTrackStateParams,
Expand All @@ -24,6 +23,7 @@ import {
HMSRoleName,
HMSTrackID,
HMSTrackSource,
IHMSInteractivityCenter,
IHMSPlaylistActions,
IHMSSessionStoreActions,
} from './schema';
Expand Down Expand Up @@ -505,4 +505,9 @@ export interface IHMSActions<T extends HMSGenericTypes = { sessionStore: Record<
sessionStore: IHMSSessionStoreActions<T['sessionStore']>;

interactivityCenter: IHMSInteractivityCenter;

raiseLocalPeerHand(): Promise<void>;
lowerLocalPeerHand(): Promise<void>;
raiseRemotePeerHand(peerId: string): Promise<void>;
lowerRemotePeerHand(peerId: string): Promise<void>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,7 @@ import {
HMSPollQuestionResponseCreateParams,
HMSSdk,
} from '@100mslive/hms-video';

export interface IHMSInteractivityCenter {
createPoll(poll: HMSPollCreateParams): Promise<void>;
startPoll(poll: string | HMSPollCreateParams): Promise<void>;
stopPoll(poll: string): Promise<void>;
addQuestionsToPoll(pollID: string, questions: HMSPollQuestionCreateParams[]): Promise<void>;
addResponsesToPoll(pollID: string, responses: HMSPollQuestionResponseCreateParams[]): Promise<void>;
}
import { IHMSInteractivityCenter } from '../schema';

export class HMSInteractivityCenter implements IHMSInteractivityCenter {
constructor(private sdk: HMSSdk) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,17 @@ export class HMSNotifications<T extends HMSGenericTypes = { sessionStore: Record
}

sendPeerList(peers: HMSPeer[]) {
if (peers.length === 0) {
return;
}
const notification = this.createNotification(HMSNotificationTypes.PEER_LIST, peers, HMSNotificationSeverity.INFO);
this.emitEvent(notification);
}

sendPeerUpdate(type: sdkTypes.HMSPeerUpdate, peer: HMSPeer | null) {
const hmsPeer = this.store.getState(selectPeerByID(peer?.id)) || peer;
const notificationType = PEER_NOTIFICATION_TYPES[type];
if (notificationType) {
if (notificationType && hmsPeer) {
const notification = this.createNotification(notificationType, hmsPeer, HMSNotificationSeverity.INFO);
this.emitEvent(notification);
}
Expand Down
43 changes: 33 additions & 10 deletions packages/hms-video-store/src/core/hmsSDKStore/HMSSDKActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
mergeTrackArrayFields,
} from './sdkUtils/storeMergeUtils';
import { SDKToHMS } from './adapter';
import { HMSInteractivityCenter, IHMSInteractivityCenter } from './HMSInteractivityCenter';
import { HMSInteractivityCenter } from './HMSInteractivityCenter';
import { HMSNotifications } from './HMSNotifications';
import { HMSPlaylist } from './HMSPlaylist';
import { HMSSessionStore } from './HMSSessionStore';
Expand All @@ -60,6 +60,7 @@ import {
HMSTrackID,
HMSTrackSource,
HMSVideoTrack,
IHMSInteractivityCenter,
IHMSPlaylistActions,
IHMSSessionStoreActions,
} from '../schema';
Expand Down Expand Up @@ -557,6 +558,19 @@ export class HMSSDKActions<T extends HMSGenericTypes = { sessionStore: Record<st
this.removeRoleChangeRequest(request);
}

async raiseLocalPeerHand() {
await this.sdk.raiseLocalPeerHand();
}
async lowerLocalPeerHand() {
await this.sdk.lowerLocalPeerHand();
}
async raiseRemotePeerHand(peerId: string) {
await this.sdk.raiseRemotePeerHand(peerId);
}
async lowerRemotePeerHand(peerId: string) {
await this.sdk.lowerRemotePeerHand(peerId);
}

initAppData(appData: Record<string, any>) {
this.setState(store => {
store.appData = appData;
Expand Down Expand Up @@ -902,6 +916,7 @@ export class HMSSDKActions<T extends HMSGenericTypes = { sessionStore: Record<st
const newHmsTracks: Record<HMSTrackID, Partial<HMSTrack>> = {};
const newHmsSDkTracks: Record<HMSTrackID, SDKHMSTrack> = {};
const newMediaSettings: Partial<HMSMediaSettings> = {};
const newNetworkQuality: Record<HMSPeerID, sdkTypes.HMSConnectionQuality> = {};
let newPreview: HMSStore['preview'];

const sdkPeers: sdkTypes.HMSPeer[] = this.sdk.getPeers();
Expand All @@ -911,6 +926,10 @@ export class HMSSDKActions<T extends HMSGenericTypes = { sessionStore: Record<st
const hmsPeer = SDKToHMS.convertPeer(sdkPeer);
newHmsPeers[hmsPeer.id] = hmsPeer;
newHmsPeerIDs.push(hmsPeer.id);
newNetworkQuality[hmsPeer.id] = {
peerID: hmsPeer.id,
downlinkQuality: sdkPeer.networkQuality || -1,
};

const sdkTracks = [sdkPeer.audioTrack, sdkPeer.videoTrack, ...sdkPeer.auxiliaryTracks];
for (const sdkTrack of sdkTracks) {
Expand Down Expand Up @@ -944,6 +963,7 @@ export class HMSSDKActions<T extends HMSGenericTypes = { sessionStore: Record<st
mergeNewPeersInDraft(draftPeers, newHmsPeers);
mergeNewTracksInDraft(draftTracks, newHmsTracks);
Object.assign(draftStore.settings, newMediaSettings);
Object.assign(draftStore.connectionQualities, newNetworkQuality);
this.hmsSDKTracks = newHmsSDkTracks;

/**
Expand Down Expand Up @@ -1123,26 +1143,17 @@ export class HMSSDKActions<T extends HMSGenericTypes = { sessionStore: Record<st
*/
protected onConnectionQualityUpdate(newQualities: sdkTypes.HMSConnectionQuality[]) {
this.setState(store => {
const currentPeerIDs = new Set();
newQualities.forEach(sdkUpdate => {
const peerID = sdkUpdate.peerID;
if (!peerID) {
return;
}
currentPeerIDs.add(peerID);
if (!store.connectionQualities[peerID]) {
store.connectionQualities[peerID] = sdkUpdate;
} else {
Object.assign(store.connectionQualities[peerID], sdkUpdate);
}
});
const peerIDsStored = Object.keys(store.connectionQualities);
for (const storedPeerID of peerIDsStored) {
if (!currentPeerIDs.has(storedPeerID)) {
// peer is likely no longer there, it wasn't in the update sent by the server
delete store.connectionQualities[storedPeerID];
}
}
}, 'connectionQuality');
}

Expand Down Expand Up @@ -1444,6 +1455,7 @@ export class HMSSDKActions<T extends HMSGenericTypes = { sessionStore: Record<st
}, action);
};

// eslint-disable-next-line complexity
private sendPeerUpdateNotification = (type: sdkTypes.HMSPeerUpdate, sdkPeer: sdkTypes.HMSPeer) => {
let peer = this.store.getState(selectPeerByID(sdkPeer.peerId));
const actionName = PEER_NOTIFICATION_TYPES[type] || 'peerUpdate';
Expand All @@ -1456,6 +1468,17 @@ export class HMSSDKActions<T extends HMSGenericTypes = { sessionStore: Record<st
if (!peer) {
peer = this.store.getState(selectPeerByID(sdkPeer.peerId));
}
} else if (
[
sdkTypes.HMSPeerUpdate.HAND_RAISE_CHANGED,
sdkTypes.HMSPeerUpdate.PEER_REMOVED,
sdkTypes.HMSPeerUpdate.PEER_ADDED,
].includes(type)
) {
this.syncRoomState(actionName);
if (!peer) {
peer = this.store.getState(selectPeerByID(sdkPeer.peerId));
}
} else {
const hmsPeer = SDKToHMS.convertPeer(sdkPeer) as HMSPeer;
this.setState(draftStore => {
Expand Down
2 changes: 2 additions & 0 deletions packages/hms-video-store/src/core/hmsSDKStore/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export class SDKToHMS {
customerUserId: sdkPeer.customerUserId,
metadata: sdkPeer.metadata,
joinedAt: sdkPeer.joinedAt,
groups: sdkPeer.groups,
isHandRaised: sdkPeer.isHandRaised,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const PEER_NOTIFICATION_TYPES: PeerNotificationMap = {
[sdkTypes.HMSPeerUpdate.ROLE_UPDATED]: HMSNotificationTypes.ROLE_UPDATED,
[sdkTypes.HMSPeerUpdate.NAME_UPDATED]: HMSNotificationTypes.NAME_UPDATED,
[sdkTypes.HMSPeerUpdate.METADATA_UPDATED]: HMSNotificationTypes.METADATA_UPDATED,
[sdkTypes.HMSPeerUpdate.HAND_RAISE_CHANGED]: HMSNotificationTypes.HAND_RAISE_CHANGED,
};

type TrackNotificationMap = { [key in sdkTypes.HMSTrackUpdate]: HMSNotificationTypes };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { HMSPeerStats, HMSTrackStats } from '../sdkTypes';
* @param newHmsTracks this will be update if required
* @param newHmsSDkTracks this is future value of local hms tacks map
*/
// eslint-disable-next-line complexity
export const mergeNewPeersInDraft = (
draftPeers: Record<HMSPeerID, HMSPeer>,
newPeers: Record<HMSPeerID, Partial<HMSPeer>>,
Expand All @@ -24,6 +25,9 @@ export const mergeNewPeersInDraft = (
if (areArraysEqual(oldPeer.auxiliaryTracks, newPeer.auxiliaryTracks)) {
newPeer.auxiliaryTracks = oldPeer.auxiliaryTracks;
}
if (oldPeer.groups && areArraysEqual(oldPeer.groups, newPeer.groups)) {
newPeer.groups = oldPeer.groups;
}
Object.assign(oldPeer, newPeer);
} else if (isEntityRemoved(oldPeer, newPeer)) {
delete draftPeers[peerID];
Expand Down
1 change: 1 addition & 0 deletions packages/hms-video-store/src/core/schema/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ export * from './device-change';
export * from './playlist';
export * from './session-store';
export * from './playlist-selectors';
export * from './interactivity-center';
13 changes: 13 additions & 0 deletions packages/hms-video-store/src/core/schema/interactivity-center.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {
HMSPollCreateParams,
HMSPollQuestionCreateParams,
HMSPollQuestionResponseCreateParams,
} from '@100mslive/hms-video';

export interface IHMSInteractivityCenter {
createPoll(poll: HMSPollCreateParams): Promise<void>;
startPoll(poll: string | HMSPollCreateParams): Promise<void>;
stopPoll(poll: string): Promise<void>;
addQuestionsToPoll(pollID: string, questions: HMSPollQuestionCreateParams[]): Promise<void>;
addResponsesToPoll(pollID: string, responses: HMSPollQuestionResponseCreateParams[]): Promise<void>;
}
4 changes: 3 additions & 1 deletion packages/hms-video-store/src/core/schema/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export enum HMSNotificationTypes {
POLL_STARTED = 'POLL_STARTED',
POLL_STOPPED = 'POLL_STOPPED',
POLL_VOTES_UPDATED = 'POLL_VOTES_UPDATED',
HAND_RAISE_CHANGED = 'HAND_RAISE_CHANGED',
}

export type HMSNotificationMapping<T extends HMSNotificationTypes, C = any> = {
Expand Down Expand Up @@ -154,9 +155,10 @@ export type HMSNotificationMapping<T extends HMSNotificationTypes, C = any> = {
[HMSNotificationTypes.POLL_STOPPED]: HMSPollNotification;
[HMSNotificationTypes.POLL_VOTES_UPDATED]: HMSPollNotification;
[HMSNotificationTypes.POLL_CREATED]: HMSPollNotification;
[HMSNotificationTypes.HAND_RAISE_CHANGED]: HMSPeerNotification;
}[T];

type MappedNotifications<Type extends HMSNotificationTypes[]> = {
export type MappedNotifications<Type extends HMSNotificationTypes[]> = {
[index in keyof Type]: HMSNotificationMapping<Type[index]>;
};

Expand Down
2 changes: 2 additions & 0 deletions packages/hms-video-store/src/core/schema/peer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export interface HMSPeer {
customerUserId?: string;
metadata?: string;
joinedAt?: Date;
groups?: string[];
isHandRaised: boolean;
}

/**
Expand Down
Loading

2 comments on commit 045fd6f

@vercel
Copy link

@vercel vercel bot commented on 045fd6f Sep 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

storybook-app – ./packages/roomkit-react

storybook-app-git-production-100mslive.vercel.app
storybook-app-five.vercel.app
storybook-app-100mslive.vercel.app
ui.100ms.live

@vercel
Copy link

@vercel vercel bot commented on 045fd6f Sep 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.