Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/web 3039 ios notification undefined #3301

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ClientAnalyticsTransport implements IAnalyticsTransportProvider {
private failedEvents = new LocalStorage<AnalyticsEvent[]>('client-events');
isConnected = true;
private env: null | ENV = null;
private websocketURL = '';
public websocketURL = '';
Copy link
Collaborator

Choose a reason for hiding this comment

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

@hdz-666 can we make sure we create branches from proper base branches. always create from dev instead of another branches


setEnv(env: ENV) {
this.env = env;
Expand Down
3 changes: 3 additions & 0 deletions packages/hms-video-store/src/interfaces/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ export interface HMSRoom {
isHipaaEnabled?: boolean;
isNoiseCancellationEnabled?: boolean;
transcriptions?: HMSTranscriptionInfo[];
enabledFlags?: string[];
websocketUrl?: string;
initEndpoint?: string;
}

export interface HMSRecording {
Expand Down
3 changes: 3 additions & 0 deletions packages/hms-video-store/src/reactive-store/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ export class SDKToHMS {
isVBEnabled: sdkRoom.isVBEnabled,
effectsKey: sdkRoom.effectsKey,
isHipaaEnabled: sdkRoom.isHipaaEnabled,
enabledFlags: sdkRoom.enabledFlags,
websocketUrl: sdkRoom.websocketUrl,
initEndpoint: sdkRoom.initEndpoint,
isNoiseCancellationEnabled: sdkRoom.isNoiseCancellationEnabled,
};
}
Expand Down
3 changes: 3 additions & 0 deletions packages/hms-video-store/src/schema/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,7 @@ export interface HMSRoom {
effectsKey?: string;
isHipaaEnabled?: boolean;
isNoiseCancellationEnabled?: boolean;
enabledFlags?: string[];
websocketUrl?: string;
initEndpoint?: string;
}
3 changes: 3 additions & 0 deletions packages/hms-video-store/src/sdk/models/HMSRoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ export default class Room implements HMSRoom {
effectsKey?: string;
isHipaaEnabled?: boolean;
isNoiseCancellationEnabled?: boolean;
enabledFlags?: string[];
websocketUrl?: string;
initEndpoint?: string;

constructor(id: string) {
this.id = id;
Expand Down
4 changes: 3 additions & 1 deletion packages/hms-video-store/src/selectors/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,9 @@ export const selectIsLargeRoom = createSelector(selectRoom, room => !!room.isLar
export const selectIsEffectsEnabled = createSelector(selectRoom, room => !!room.isEffectsEnabled);
export const selectIsVBEnabled = createSelector(selectRoom, room => !!room.isVBEnabled);
export const selectEffectsKey = createSelector(selectRoom, room => room.effectsKey);

export const selectWebsocketURL = createSelector(selectRoom, room => room.websocketUrl);
export const selectInitEndpoint = createSelector(selectRoom, room => room.initEndpoint);
export const selectEnabledFlags = createSelector(selectRoom, room => room.enabledFlags);
export const selectTemplateAppData = (store: HMSStore) => store.templateAppData;
/** @deprecated - use `selectSessionStore` instead */
export const selectSessionMetadata = (store: HMSStore) => store.sessionMetadata;
Expand Down
8 changes: 8 additions & 0 deletions packages/hms-video-store/src/transport/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,7 @@ export default class HMSTransport {
}
}

// eslint-disable-next-line complexity
private async internalConnect(token: string, initEndpoint: string, peerId: string, iceServers?: HMSICEServer[]) {
HMSLogger.d(TAG, 'connect: started ⏰');
const connectRequestedAt = new Date();
Expand All @@ -1109,9 +1110,16 @@ export default class HMSTransport {
room.isVBEnabled = this.isFlagEnabled(InitFlags.FLAG_VB_ENABLED);
room.isHipaaEnabled = this.isFlagEnabled(InitFlags.FLAG_HIPAA_ENABLED);
room.isNoiseCancellationEnabled = this.isFlagEnabled(InitFlags.FLAG_NOISE_CANCELLATION);
room.enabledFlags = [];
const allFlags = Object.values(InitFlags);
room.enabledFlags = allFlags.filter(flag => this.isFlagEnabled(flag));
room.initEndpoint = initEndpoint;
}
this.analyticsTimer.end(TimedEvent.INIT);
HTTPAnalyticsTransport.setWebsocketEndpoint(this.initConfig.endpoint);
if (room) {
room.websocketUrl = HTTPAnalyticsTransport.websocketURL;
}
// if leave was called while init was going on, don't open websocket
this.validateNotDisconnected('post init');
await this.openSignal(token, peerId);
Expand Down
38 changes: 27 additions & 11 deletions packages/react-sdk/src/hooks/useAwayNotifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,36 @@ import { useHMSVanillaStore } from '../primitives/HmsRoomProvider';
// Do not prompt if preview is not available. Skips for beam
export const useAwayNotifications = () => {
const vanillaStore = useHMSVanillaStore();
// eslint-disable-next-line complexity
const requestPermission = useCallback(async () => {
// Headless check for beam
if (navigator.webdriver) {
return;
}
if (!Notification || Notification?.permission === 'granted' || Notification?.permission === 'denied') {
return;
}
const unsubscribe = vanillaStore.subscribe(async role => {
if (role && role !== '__internal_recorder') {
await Notification.requestPermission();
unsubscribe?.();

try {
if (navigator.webdriver) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

let us combine the 3 if blocks

return;
}
if (!('Notification' in window)) {
// Notifications not supported
return;
}
}, selectLocalPeerRoleName);

if (!Notification) {
return;
}

if (Notification?.permission === 'granted' || Notification?.permission === 'denied') {
return;
}
console.log('###### Requesting Notification Permission unsubscribe', Notification);
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove test log. check with yogesh and 16.5.1 in browserstack

const unsubscribe = vanillaStore.subscribe(async role => {
if (role && role !== '__internal_recorder') {
await Notification?.requestPermission();
unsubscribe?.();
}
}, selectLocalPeerRoleName);
} catch (e) {
console.log(e);
}
}, [vanillaStore]);

const showNotification = useCallback((title: string, options?: NotificationOptions) => {
Expand Down
1 change: 1 addition & 0 deletions packages/react-sdk/src/primitives/HmsRoomProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ export const useHMSNotifications = <T extends HMSNotificationTypeParam>(
if (!HMSContextConsumer.notifications) {
return;
}

const unsubscribe = HMSContextConsumer.notifications.onNotification<T>(notification => {
setNotification(notification);
}, type);
Expand Down
12 changes: 12 additions & 0 deletions packages/roomkit-react/src/Stats/Stats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
RID,
selectConnectionQualityByPeerID,
selectHMSStats,
selectRoom,
simulcastMapping,
useHMSStatsStore,
useHMSStore,
Expand Down Expand Up @@ -35,6 +36,7 @@ export function VideoTileStats({ videoTrackID, audioTrackID, peerID, isLocal = f
const downlinkScore = useHMSStore(selectConnectionQualityByPeerID(peerID))?.downlinkQuality;
const availableOutgoingBitrate = useHMSStatsStore(selectHMSStats.availablePublishBitrate);
const qoe = useQoE({ videoTrackID, audioTrackID, isLocal });
const { websocketUrl = '', initEndpoint = '', enabledFlags = [] } = useHMSStore(selectRoom);

// Viewer role - no stats to show
if (!(audioTrackStats || videoTrackStats)) {
Expand All @@ -52,6 +54,16 @@ export function VideoTileStats({ videoTrackID, audioTrackID, peerID, isLocal = f
tooltip="Available Outgoing Bitrate"
value={formatBytes(availableOutgoingBitrate, 'b/s')}
/>

<Stats.Gap />
<StatsRow show={!!websocketUrl} label="Websocket" tooltip="WebsocketURL" value={websocketUrl} />
<StatsRow show={!!initEndpoint} label="InitEndpoint" tooltip="InitEndpoint" value={initEndpoint} />
<StatsRow show={enabledFlags.length > 0} label="Enabled Flags" value={' '} />
{enabledFlags.map(flag => (
<StatsRow key={flag} show label={flag} />
))}

<Stats.Gap />
{localVideoTrackStats?.map(stat => {
if (!stat) {
return null;
Expand Down
Loading