Files
jitsi-meet/react/features/conference/actions.native.ts
Avram Tudor 974e2a5106 ref: improve handling for room destroyed events (#13591)
* ref: improve handling for room destroyed events

* add missing translation

* code review

* implement kick handling

* implement native handling

* fix tests

* code review changes

* add dialog testId

* fix end conf for react native

* fix lobby test

* add translation for lobby closing

---------

Co-authored-by: Gabriel Borlea <gabriel.borlea@8x8.com>
2023-08-28 15:14:03 +03:00

79 lines
2.3 KiB
TypeScript

import { IStore } from '../app/types';
import { hideDialog, openDialog } from '../base/dialog/actions';
import AlertDialog from '../base/dialog/components/native/AlertDialog';
import { getParticipantDisplayName } from '../base/participants/functions';
import { DISMISS_CALENDAR_NOTIFICATION } from './actionTypes';
/**
* Notify that we've been kicked out of the conference.
*
* @param {JitsiParticipant} participant - The {@link JitsiParticipant}
* instance which initiated the kick event.
* @param {?Function} submit - The function to execute after submiting the dialog.
* @returns {Function}
*/
export function notifyKickedOut(participant: any, submit?: Function) {
return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
if (!participant || participant?.isReplaced?.()) {
submit?.();
return;
}
dispatch(openDialog(AlertDialog, {
contentKey: {
key: 'dialog.kickTitle',
params: {
participantDisplayName: getParticipantDisplayName(getState, participant.getId())
}
},
onSubmit: submit
}));
};
}
/**
* Notify that we've been kicked out of the conference.
*
* @param {string} reasonKey - The translation key for the reason why the conference failed.
* @param {?Function} submit - The function to execute after submiting the dialog.
* @returns {Function}
*/
export function notifyConferenceFailed(reasonKey: string, submit?: Function) {
return (dispatch: IStore['dispatch']) => {
if (!reasonKey) {
submit?.();
return;
}
// we have to push the opening of the dialog to the queue
// so that we make sure it will be visible after the events
// of conference destroyed are done
setTimeout(() => dispatch(openDialog(AlertDialog, {
contentKey: {
key: reasonKey
},
params: {
},
onSubmit: () => {
submit?.();
dispatch(hideDialog(AlertDialog));
}
})));
};
}
/**
* Dismisses calendar notification about next or ongoing event.
*
* @returns {Object}
*/
export function dismissCalendarNotification() {
return {
type: DISMISS_CALENDAR_NOTIFICATION
};
}