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 { appNavigate } from '../app/actions';
import { IStore } from '../app/types'; import { IStore } from '../app/types';
import { import {
CONFERENCE_FAILED,
CONFERENCE_JOINED, CONFERENCE_JOINED,
CONFERENCE_LEFT, CONFERENCE_LEFT,
KICKED_OUT KICKED_OUT
@ -77,6 +78,13 @@ MiddlewareRegistry.register(store => next => action => {
break; break;
} }
case CONFERENCE_FAILED: {
clearInterval(intervalId);
intervalId = null;
break;
}
} }
return result; return result;
@ -179,35 +187,31 @@ function _maybeDisplayCalendarNotification({ dispatch, getState }: IStore) {
let eventToShow; let eventToShow;
if (eventList?.length) { if (!calendarEnabled && reducedUI) {
for (const event of eventList) { return;
const eventURL }
= event?.url
&& getURLWithoutParamsNormalized(new URL(event.url));
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 // @ts-ignore
if ((!eventToShow && event.startDate > now || (event.startDate < now && event.endDate > now)) {
// @ts-ignore eventToShow = event;
&& event.startDate < now + ALERT_MILLISECONDS)
// @ts-ignore
|| (event.startDate < now && event.endDate > now)) {
eventToShow = event;
}
} }
} }
} }
if (calendarEnabled && !reducedUI) { _calendarNotification(
_calendarNotification( {
{ dispatch,
dispatch, getState
getState }, eventToShow
}, eventToShow );
);
}
return undefined;
} }
/** /**
@ -228,33 +232,33 @@ function _calendarNotification({ dispatch, getState }: IStore, eventToShow: any)
= locationURL ? getURLWithoutParamsNormalized(locationURL) : ''; = locationURL ? getURLWithoutParamsNormalized(locationURL) : '';
const now = Date.now(); const now = Date.now();
if (eventToShow) { if (!eventToShow) {
const customActionNameKey = [ 'notify.joinMeeting' ]; return;
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));
} }
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));
} }