mirror of
https://gitcode.com/GitHub_Trending/ji/jitsi-meet.git
synced 2025-12-30 11:22:31 +00:00
feat(android/ios): Native API events for show/hide notification (#15577)
Added show/hide notification events for native Android/iOS
This commit is contained in:
@@ -51,6 +51,8 @@ import { getLocalTracks, isLocalTrackMuted } from '../../base/tracks/functions.n
|
||||
import { ITrack } from '../../base/tracks/types';
|
||||
import { CLOSE_CHAT, OPEN_CHAT } from '../../chat/actionTypes';
|
||||
import { closeChat, openChat, sendMessage, setPrivateMessageRecipient } from '../../chat/actions.native';
|
||||
import { hideNotification, showNotification } from '../../notifications/actions';
|
||||
import { NOTIFICATION_TIMEOUT_TYPE, NOTIFICATION_TYPE } from '../../notifications/constants';
|
||||
import { setRequestingSubtitles } from '../../subtitles/actions.any';
|
||||
import { CUSTOM_BUTTON_PRESSED } from '../../toolbox/actionTypes';
|
||||
import { muteLocal } from '../../video-menu/actions.native';
|
||||
@@ -419,6 +421,35 @@ function _registerForNativeEvents(store: IStore) {
|
||||
eventEmitter.addListener(ExternalAPI.TOGGLE_CAMERA, () => {
|
||||
dispatch(toggleCameraFacingMode());
|
||||
});
|
||||
|
||||
eventEmitter.addListener(ExternalAPI.SHOW_NOTIFICATION,
|
||||
({ appearance, description, timeout, title, uid }: any) => {
|
||||
const validTypes = Object.values(NOTIFICATION_TYPE);
|
||||
const validTimeouts = Object.values(NOTIFICATION_TIMEOUT_TYPE);
|
||||
|
||||
if (!validTypes.includes(appearance)) {
|
||||
logger.error(`Invalid notification type "${appearance}". Expecting one of ${validTypes}`);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!validTimeouts.includes(timeout)) {
|
||||
logger.error(`Invalid notification timeout "${timeout}". Expecting one of ${validTimeouts}`);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch(showNotification({
|
||||
appearance,
|
||||
description,
|
||||
title,
|
||||
uid
|
||||
}, timeout));
|
||||
});
|
||||
|
||||
eventEmitter.addListener(ExternalAPI.HIDE_NOTIFICATION, ({ uid }: any) => {
|
||||
dispatch(hideNotification(uid));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -439,6 +470,8 @@ function _unregisterForNativeEvents() {
|
||||
eventEmitter.removeAllListeners(ExternalAPI.SEND_CHAT_MESSAGE);
|
||||
eventEmitter.removeAllListeners(ExternalAPI.SET_CLOSED_CAPTIONS_ENABLED);
|
||||
eventEmitter.removeAllListeners(ExternalAPI.TOGGLE_CAMERA);
|
||||
eventEmitter.removeAllListeners(ExternalAPI.SHOW_NOTIFICATION);
|
||||
eventEmitter.removeAllListeners(ExternalAPI.HIDE_NOTIFICATION);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user