feat(conference): review remarks

This commit is contained in:
Calin-Teodor 2023-03-08 13:45:10 +02:00
parent c7062e5a4a
commit dc099eda44
1 changed files with 54 additions and 50 deletions

View File

@ -6,6 +6,7 @@ import { batch } from 'react-redux';
import { appNavigate } from '../app/actions';
import { IStore } from '../app/types';
import {
CONFERENCE_FAILED,
CONFERENCE_JOINED,
CONFERENCE_LEFT,
KICKED_OUT
@ -77,6 +78,13 @@ MiddlewareRegistry.register(store => next => action => {
break;
}
case CONFERENCE_FAILED: {
clearInterval(intervalId);
intervalId = null;
break;
}
}
return result;
@ -179,35 +187,31 @@ function _maybeDisplayCalendarNotification({ dispatch, getState }: IStore) {
let eventToShow;
if (eventList?.length) {
for (const event of eventList) {
const eventURL
= event?.url
&& getURLWithoutParamsNormalized(new URL(event.url));
if (!calendarEnabled && reducedUI) {
return;
}
if (eventURL && eventURL !== currentConferenceURL) {
for (const event of eventList) {
const eventURL
= event?.url && getURLWithoutParamsNormalized(new URL(event.url));
if (eventURL && eventURL !== currentConferenceURL) {
// @ts-ignore
if ((!eventToShow && event.startDate > now && event.startDate < now + ALERT_MILLISECONDS)
// @ts-ignore
if ((!eventToShow && event.startDate > now
// @ts-ignore
&& event.startDate < now + ALERT_MILLISECONDS)
// @ts-ignore
|| (event.startDate < now && event.endDate > now)) {
eventToShow = event;
}
|| (event.startDate < now && event.endDate > now)) {
eventToShow = event;
}
}
}
if (calendarEnabled && !reducedUI) {
_calendarNotification(
{
dispatch,
getState
}, eventToShow
);
}
return undefined;
_calendarNotification(
{
dispatch,
getState
}, eventToShow
);
}
/**
@ -228,33 +232,33 @@ function _calendarNotification({ dispatch, getState }: IStore, eventToShow: any)
= locationURL ? getURLWithoutParamsNormalized(locationURL) : '';
const now = Date.now();
if (eventToShow) {
const customActionNameKey = [ 'notify.joinMeeting' ];
const customActionType = [ BUTTON_TYPES.PRIMARY ];
const customActionHandler = [ () => batch(() => {
dispatch(hideNotification(CALENDAR_NOTIFICATION_ID));
if (eventToShow?.url && (eventToShow.url !== currentConferenceURL)) {
dispatch(appNavigate(eventToShow.url));
}
}) ];
const description
= getLocalizedDateFormatter(eventToShow.startDate).fromNow();
const icon = NOTIFICATION_ICON.WARNING;
const title = (eventToShow.startDate < now) && (eventToShow.endDate > now)
? i18n.t('calendarSync.ongoingMeeting')
: i18n.t('calendarSync.nextMeeting');
const uid = CALENDAR_NOTIFICATION_ID;
dispatch(showNotification({
customActionHandler,
customActionNameKey,
customActionType,
description,
icon,
title,
uid
}, NOTIFICATION_TIMEOUT_TYPE.STICKY));
if (!eventToShow) {
return;
}
return null;
const customActionNameKey = [ 'notify.joinMeeting' ];
const customActionType = [ BUTTON_TYPES.PRIMARY ];
const customActionHandler = [ () => batch(() => {
dispatch(hideNotification(CALENDAR_NOTIFICATION_ID));
if (eventToShow?.url && (eventToShow.url !== currentConferenceURL)) {
dispatch(appNavigate(eventToShow.url));
}
}) ];
const description
= getLocalizedDateFormatter(eventToShow.startDate).fromNow();
const icon = NOTIFICATION_ICON.WARNING;
const title = (eventToShow.startDate < now) && (eventToShow.endDate > now)
? i18n.t('calendarSync.ongoingMeeting')
: i18n.t('calendarSync.nextMeeting');
const uid = CALENDAR_NOTIFICATION_ID;
dispatch(showNotification({
customActionHandler,
customActionNameKey,
customActionType,
description,
icon,
title,
uid
}, NOTIFICATION_TIMEOUT_TYPE.STICKY));
}