ref(TS) Convert some features to TS (#12469)
This commit is contained in:
parent
75d7c4b160
commit
69f4b116a9
|
@ -68,6 +68,7 @@ export interface IJitsiConference {
|
||||||
removeTrack: Function;
|
removeTrack: Function;
|
||||||
replaceTrack: Function;
|
replaceTrack: Function;
|
||||||
sendCommand: Function;
|
sendCommand: Function;
|
||||||
|
sendCommandOnce: Function;
|
||||||
sendEndpointMessage: Function;
|
sendEndpointMessage: Function;
|
||||||
sendFeedback: Function;
|
sendFeedback: Function;
|
||||||
sendLobbyMessage: Function;
|
sendLobbyMessage: Function;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// @flow
|
import { IStore } from '../app/types';
|
||||||
|
import { toggleDialog } from '../base/dialog/actions';
|
||||||
import { toggleDialog } from '../base/dialog';
|
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
import { SecurityDialog } from './components/security-dialog';
|
import { SecurityDialog } from './components/security-dialog';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -10,7 +10,7 @@ import { SecurityDialog } from './components/security-dialog';
|
||||||
* @returns {Function}
|
* @returns {Function}
|
||||||
*/
|
*/
|
||||||
export function toggleSecurityDialog() {
|
export function toggleSecurityDialog() {
|
||||||
return function(dispatch: (Object) => Object) {
|
return function(dispatch: IStore['dispatch']) {
|
||||||
dispatch(toggleDialog(SecurityDialog));
|
dispatch(toggleDialog(SecurityDialog));
|
||||||
};
|
};
|
||||||
}
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
/* @flow */
|
import { IStore } from '../app/types';
|
||||||
|
import { getInviteURL } from '../base/connection/functions';
|
||||||
import { getInviteURL } from '../base/connection';
|
|
||||||
|
|
||||||
import { BEGIN_SHARE_ROOM, END_SHARE_ROOM } from './actionTypes';
|
import { BEGIN_SHARE_ROOM, END_SHARE_ROOM } from './actionTypes';
|
||||||
|
|
||||||
|
@ -11,8 +10,8 @@ import { BEGIN_SHARE_ROOM, END_SHARE_ROOM } from './actionTypes';
|
||||||
* @public
|
* @public
|
||||||
* @returns {Function}
|
* @returns {Function}
|
||||||
*/
|
*/
|
||||||
export function beginShareRoom(roomURL: ?string): Function {
|
export function beginShareRoom(roomURL?: string) {
|
||||||
return (dispatch, getState) => {
|
return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
|
||||||
if (!roomURL) {
|
if (!roomURL) {
|
||||||
// eslint-disable-next-line no-param-reassign
|
// eslint-disable-next-line no-param-reassign
|
||||||
roomURL = getInviteURL(getState);
|
roomURL = getInviteURL(getState);
|
||||||
|
@ -37,7 +36,7 @@ export function beginShareRoom(roomURL: ?string): Function {
|
||||||
* shared: boolean
|
* shared: boolean
|
||||||
* }}
|
* }}
|
||||||
*/
|
*/
|
||||||
export function endShareRoom(roomURL: string, shared: boolean): Object {
|
export function endShareRoom(roomURL: string, shared: boolean) {
|
||||||
return {
|
return {
|
||||||
type: END_SHARE_ROOM,
|
type: END_SHARE_ROOM,
|
||||||
roomURL,
|
roomURL,
|
|
@ -1,5 +1,3 @@
|
||||||
// @flow
|
|
||||||
|
|
||||||
import { getLogger } from '../base/logging/functions';
|
import { getLogger } from '../base/logging/functions';
|
||||||
|
|
||||||
export default getLogger('features/share-room');
|
export default getLogger('features/share-room');
|
|
@ -1,9 +1,12 @@
|
||||||
import { getCurrentConference } from '../base/conference';
|
import { IStore } from '../app/types';
|
||||||
|
import { getCurrentConference } from '../base/conference/functions';
|
||||||
import { openDialog } from '../base/dialog/actions';
|
import { openDialog } from '../base/dialog/actions';
|
||||||
import { getLocalParticipant } from '../base/participants';
|
import { getLocalParticipant } from '../base/participants/functions';
|
||||||
import { SharedVideoDialog } from '../shared-video/components';
|
|
||||||
|
|
||||||
import { RESET_SHARED_VIDEO_STATUS, SET_SHARED_VIDEO_STATUS } from './actionTypes';
|
import { RESET_SHARED_VIDEO_STATUS, SET_SHARED_VIDEO_STATUS } from './actionTypes';
|
||||||
|
// eslint-disable-next-line lines-around-comment
|
||||||
|
// @ts-ignore
|
||||||
|
import { SharedVideoDialog } from './components';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets the status of the shared video.
|
* Resets the status of the shared video.
|
||||||
|
@ -37,7 +40,9 @@ export function resetSharedVideoStatus() {
|
||||||
* videoUrl: string,
|
* videoUrl: string,
|
||||||
* }}
|
* }}
|
||||||
*/
|
*/
|
||||||
export function setSharedVideoStatus({ videoUrl, status, time, ownerId, muted }) {
|
export function setSharedVideoStatus({ videoUrl, status, time, ownerId, muted }: {
|
||||||
|
muted?: boolean; ownerId?: string; status: string; time: number; videoUrl: string;
|
||||||
|
}) {
|
||||||
return {
|
return {
|
||||||
type: SET_SHARED_VIDEO_STATUS,
|
type: SET_SHARED_VIDEO_STATUS,
|
||||||
ownerId,
|
ownerId,
|
||||||
|
@ -54,7 +59,7 @@ export function setSharedVideoStatus({ videoUrl, status, time, ownerId, muted })
|
||||||
* @param {Function} onPostSubmit - The function to be invoked when a valid link is entered.
|
* @param {Function} onPostSubmit - The function to be invoked when a valid link is entered.
|
||||||
* @returns {Function}
|
* @returns {Function}
|
||||||
*/
|
*/
|
||||||
export function showSharedVideoDialog(onPostSubmit) {
|
export function showSharedVideoDialog(onPostSubmit: Function) {
|
||||||
return openDialog(SharedVideoDialog, { onPostSubmit });
|
return openDialog(SharedVideoDialog, { onPostSubmit });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,12 +70,12 @@ export function showSharedVideoDialog(onPostSubmit) {
|
||||||
* @returns {Function}
|
* @returns {Function}
|
||||||
*/
|
*/
|
||||||
export function stopSharedVideo() {
|
export function stopSharedVideo() {
|
||||||
return (dispatch, getState) => {
|
return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const { ownerId } = state['features/shared-video'];
|
const { ownerId } = state['features/shared-video'];
|
||||||
const localParticipant = getLocalParticipant(state);
|
const localParticipant = getLocalParticipant(state);
|
||||||
|
|
||||||
if (ownerId === localParticipant.id) {
|
if (ownerId === localParticipant?.id) {
|
||||||
dispatch(resetSharedVideoStatus());
|
dispatch(resetSharedVideoStatus());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -84,8 +89,8 @@ export function stopSharedVideo() {
|
||||||
*
|
*
|
||||||
* @returns {Function}
|
* @returns {Function}
|
||||||
*/
|
*/
|
||||||
export function playSharedVideo(videoUrl) {
|
export function playSharedVideo(videoUrl: string) {
|
||||||
return (dispatch, getState) => {
|
return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
|
||||||
const conference = getCurrentConference(getState());
|
const conference = getCurrentConference(getState());
|
||||||
|
|
||||||
if (conference) {
|
if (conference) {
|
||||||
|
@ -95,7 +100,7 @@ export function playSharedVideo(videoUrl) {
|
||||||
videoUrl,
|
videoUrl,
|
||||||
status: 'start',
|
status: 'start',
|
||||||
time: 0,
|
time: 0,
|
||||||
ownerId: localParticipant.id
|
ownerId: localParticipant?.id
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -108,14 +113,14 @@ export function playSharedVideo(videoUrl) {
|
||||||
* @returns {Function}
|
* @returns {Function}
|
||||||
*/
|
*/
|
||||||
export function toggleSharedVideo() {
|
export function toggleSharedVideo() {
|
||||||
return (dispatch, getState) => {
|
return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const { status } = state['features/shared-video'];
|
const { status = '' } = state['features/shared-video'];
|
||||||
|
|
||||||
if ([ 'playing', 'start', 'pause' ].includes(status)) {
|
if ([ 'playing', 'start', 'pause' ].includes(status)) {
|
||||||
dispatch(stopSharedVideo());
|
dispatch(stopSharedVideo());
|
||||||
} else {
|
} else {
|
||||||
dispatch(showSharedVideoDialog(id => dispatch(playSharedVideo(id))));
|
dispatch(showSharedVideoDialog((id: string) => dispatch(playSharedVideo(id))));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
|
@ -1,5 +1,3 @@
|
||||||
// @flow
|
|
||||||
|
|
||||||
import { SET_DISABLE_BUTTON } from './actionTypes';
|
import { SET_DISABLE_BUTTON } from './actionTypes';
|
||||||
|
|
||||||
export * from './actions.any';
|
export * from './actions.any';
|
|
@ -1,20 +1,15 @@
|
||||||
// @flow
|
|
||||||
|
|
||||||
import { batch } from 'react-redux';
|
import { batch } from 'react-redux';
|
||||||
|
|
||||||
|
import { IStore } from '../app/types';
|
||||||
import { CONFERENCE_JOIN_IN_PROGRESS, CONFERENCE_LEFT } from '../base/conference/actionTypes';
|
import { CONFERENCE_JOIN_IN_PROGRESS, CONFERENCE_LEFT } from '../base/conference/actionTypes';
|
||||||
import { getCurrentConference } from '../base/conference/functions';
|
import { getCurrentConference } from '../base/conference/functions';
|
||||||
import { MEDIA_TYPE } from '../base/media';
|
import { IJitsiConference } from '../base/conference/reducer';
|
||||||
import {
|
import { MEDIA_TYPE } from '../base/media/constants';
|
||||||
PARTICIPANT_LEFT,
|
import { PARTICIPANT_LEFT } from '../base/participants/actionTypes';
|
||||||
getLocalParticipant,
|
import { participantJoined, participantLeft, pinParticipant } from '../base/participants/actions';
|
||||||
getParticipantById,
|
import { getLocalParticipant, getParticipantById } from '../base/participants/functions';
|
||||||
participantJoined,
|
|
||||||
participantLeft,
|
|
||||||
pinParticipant
|
|
||||||
} from '../base/participants';
|
|
||||||
import { FakeParticipant } from '../base/participants/types';
|
import { FakeParticipant } from '../base/participants/types';
|
||||||
import { MiddlewareRegistry } from '../base/redux';
|
import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
|
||||||
|
|
||||||
import { RESET_SHARED_VIDEO_STATUS, SET_SHARED_VIDEO_STATUS } from './actionTypes';
|
import { RESET_SHARED_VIDEO_STATUS, SET_SHARED_VIDEO_STATUS } from './actionTypes';
|
||||||
import {
|
import {
|
||||||
|
@ -26,8 +21,6 @@ import { isSharingStatus } from './functions';
|
||||||
import logger from './logger';
|
import logger from './logger';
|
||||||
|
|
||||||
|
|
||||||
declare var APP: Object;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Middleware that captures actions related to video sharing and updates
|
* Middleware that captures actions related to video sharing and updates
|
||||||
* components not hooked into redux.
|
* components not hooked into redux.
|
||||||
|
@ -45,7 +38,8 @@ MiddlewareRegistry.register(store => next => action => {
|
||||||
const localParticipantId = getLocalParticipant(state)?.id;
|
const localParticipantId = getLocalParticipant(state)?.id;
|
||||||
|
|
||||||
conference.addCommandListener(SHARED_VIDEO,
|
conference.addCommandListener(SHARED_VIDEO,
|
||||||
({ value, attributes }) => {
|
({ value, attributes }: { attributes: {
|
||||||
|
from: string; muted: string; state: string; time: string; }; value: string; }) => {
|
||||||
|
|
||||||
const { from } = attributes;
|
const { from } = attributes;
|
||||||
const sharedVideoStatus = attributes.state;
|
const sharedVideoStatus = attributes.state;
|
||||||
|
@ -77,7 +71,7 @@ MiddlewareRegistry.register(store => next => action => {
|
||||||
if (action.participant.id === stateOwnerId) {
|
if (action.participant.id === stateOwnerId) {
|
||||||
batch(() => {
|
batch(() => {
|
||||||
dispatch(resetSharedVideoStatus());
|
dispatch(resetSharedVideoStatus());
|
||||||
dispatch(participantLeft(statevideoUrl, conference));
|
dispatch(participantLeft(statevideoUrl ?? '', conference));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -126,7 +120,7 @@ MiddlewareRegistry.register(store => next => action => {
|
||||||
|
|
||||||
sendShareVideoCommand({
|
sendShareVideoCommand({
|
||||||
conference,
|
conference,
|
||||||
id: statevideoUrl,
|
id: statevideoUrl ?? '',
|
||||||
localParticipantId,
|
localParticipantId,
|
||||||
muted: true,
|
muted: true,
|
||||||
status: 'stop',
|
status: 'stop',
|
||||||
|
@ -152,10 +146,12 @@ MiddlewareRegistry.register(store => next => action => {
|
||||||
* @param {JitsiConference} conference - The current conference.
|
* @param {JitsiConference} conference - The current conference.
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
function handleSharingVideoStatus(store, videoUrl, { state, time, from, muted }, conference) {
|
function handleSharingVideoStatus(store: IStore, videoUrl: string,
|
||||||
|
{ state, time, from, muted }: { from: string; muted: string; state: string; time: string; },
|
||||||
|
conference: IJitsiConference) {
|
||||||
const { dispatch, getState } = store;
|
const { dispatch, getState } = store;
|
||||||
const localParticipantId = getLocalParticipant(getState()).id;
|
const localParticipantId = getLocalParticipant(getState())?.id;
|
||||||
const oldStatus = getState()['features/shared-video']?.status;
|
const oldStatus = getState()['features/shared-video']?.status ?? '';
|
||||||
|
|
||||||
if (state === 'start' || ![ 'playing', 'pause', 'start' ].includes(oldStatus)) {
|
if (state === 'start' || ![ 'playing', 'pause', 'start' ].includes(oldStatus)) {
|
||||||
const youtubeId = videoUrl.match(/http/) ? false : videoUrl;
|
const youtubeId = videoUrl.match(/http/) ? false : videoUrl;
|
||||||
|
@ -195,7 +191,10 @@ function handleSharingVideoStatus(store, videoUrl, { state, time, from, muted },
|
||||||
* @param {string} time - The seek position of the video.
|
* @param {string} time - The seek position of the video.
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
function sendShareVideoCommand({ id, status, conference, localParticipantId, time, muted, volume }) {
|
function sendShareVideoCommand({ id, status, conference, localParticipantId = '', time, muted, volume }: {
|
||||||
|
conference: IJitsiConference; id: string; localParticipantId?: string; muted: boolean;
|
||||||
|
status: string; time: number; volume: number;
|
||||||
|
}) {
|
||||||
conference.sendCommandOnce(SHARED_VIDEO, {
|
conference.sendCommandOnce(SHARED_VIDEO, {
|
||||||
value: id,
|
value: id,
|
||||||
attributes: {
|
attributes: {
|
|
@ -1,8 +1,6 @@
|
||||||
// @flow
|
|
||||||
|
|
||||||
import { CONFERENCE_JOIN_IN_PROGRESS } from '../base/conference/actionTypes';
|
import { CONFERENCE_JOIN_IN_PROGRESS } from '../base/conference/actionTypes';
|
||||||
import { getLocalParticipant } from '../base/participants';
|
import { getLocalParticipant } from '../base/participants/functions';
|
||||||
import { MiddlewareRegistry } from '../base/redux';
|
import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
|
||||||
|
|
||||||
import { setDisableButton } from './actions.web';
|
import { setDisableButton } from './actions.web';
|
||||||
import { SHARED_VIDEO } from './constants';
|
import { SHARED_VIDEO } from './constants';
|
||||||
|
@ -17,7 +15,8 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
|
||||||
case CONFERENCE_JOIN_IN_PROGRESS: {
|
case CONFERENCE_JOIN_IN_PROGRESS: {
|
||||||
const { conference } = action;
|
const { conference } = action;
|
||||||
|
|
||||||
conference.addCommandListener(SHARED_VIDEO, ({ attributes }) => {
|
conference.addCommandListener(SHARED_VIDEO, ({ attributes }: { attributes:
|
||||||
|
{ from: string; state: string; }; }) => {
|
||||||
const { from } = attributes;
|
const { from } = attributes;
|
||||||
const status = attributes.state;
|
const status = attributes.state;
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
// @flow
|
|
||||||
|
|
||||||
import { SET_CURRENT_NOTIFICATION_UID } from './actionTypes';
|
import { SET_CURRENT_NOTIFICATION_UID } from './actionTypes';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,7 +11,7 @@ import { SET_CURRENT_NOTIFICATION_UID } from './actionTypes';
|
||||||
* uid: number
|
* uid: number
|
||||||
* }}
|
* }}
|
||||||
*/
|
*/
|
||||||
export function setCurrentNotificationUid(uid: ?number) {
|
export function setCurrentNotificationUid(uid?: string) {
|
||||||
return {
|
return {
|
||||||
type: SET_CURRENT_NOTIFICATION_UID,
|
type: SET_CURRENT_NOTIFICATION_UID,
|
||||||
uid
|
uid
|
|
@ -1,17 +1,14 @@
|
||||||
// @flow
|
import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../base/app/actionTypes';
|
||||||
|
import { CONFERENCE_JOINED } from '../base/conference/actionTypes';
|
||||||
import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../base/app';
|
|
||||||
import { CONFERENCE_JOINED } from '../base/conference';
|
|
||||||
import { JitsiConferenceEvents } from '../base/lib-jitsi-meet';
|
import { JitsiConferenceEvents } from '../base/lib-jitsi-meet';
|
||||||
import { MEDIA_TYPE, setAudioMuted } from '../base/media';
|
import { setAudioMuted } from '../base/media/actions';
|
||||||
import { getLocalParticipant, raiseHand } from '../base/participants';
|
import { MEDIA_TYPE } from '../base/media/constants';
|
||||||
import { MiddlewareRegistry } from '../base/redux';
|
import { raiseHand } from '../base/participants/actions';
|
||||||
import { playSound, registerSound, unregisterSound } from '../base/sounds';
|
import { getLocalParticipant } from '../base/participants/functions';
|
||||||
import {
|
import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
|
||||||
NOTIFICATION_TIMEOUT_TYPE,
|
import { playSound, registerSound, unregisterSound } from '../base/sounds/actions';
|
||||||
hideNotification,
|
import { hideNotification, showNotification } from '../notifications/actions';
|
||||||
showNotification
|
import { NOTIFICATION_TIMEOUT_TYPE } from '../notifications/constants';
|
||||||
} from '../notifications';
|
|
||||||
import { isForceMuted } from '../participants-pane/functions';
|
import { isForceMuted } from '../participants-pane/functions';
|
||||||
import { isAudioMuteButtonDisabled } from '../toolbox/functions.any';
|
import { isAudioMuteButtonDisabled } from '../toolbox/functions.any';
|
||||||
|
|
||||||
|
@ -35,7 +32,7 @@ MiddlewareRegistry.register(store => next => action => {
|
||||||
case CONFERENCE_JOINED: {
|
case CONFERENCE_JOINED: {
|
||||||
conference.on(
|
conference.on(
|
||||||
JitsiConferenceEvents.TRACK_MUTE_CHANGED,
|
JitsiConferenceEvents.TRACK_MUTE_CHANGED,
|
||||||
track => {
|
(track: any) => {
|
||||||
const { currentNotificationUid } = getState()['features/talk-while-muted'];
|
const { currentNotificationUid } = getState()['features/talk-while-muted'];
|
||||||
|
|
||||||
if (currentNotificationUid && track.isAudioTrack() && track.isLocal() && !track.isMuted()) {
|
if (currentNotificationUid && track.isAudioTrack() && track.isLocal() && !track.isMuted()) {
|
|
@ -4,7 +4,7 @@ import { set } from '../base/redux/functions';
|
||||||
import { SET_CURRENT_NOTIFICATION_UID } from './actionTypes';
|
import { SET_CURRENT_NOTIFICATION_UID } from './actionTypes';
|
||||||
|
|
||||||
export interface ITalkWhileMutedState {
|
export interface ITalkWhileMutedState {
|
||||||
currentNotificationUid?: number;
|
currentNotificationUid?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue