Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
ref: Convert some reducers to TS (#11915)
Robert Pintiliie139c6d32dea
diff --git a/react/features/app/types.ts b/react/features/app/types.tsindex b0c3636244..da7ca2f595 100644--- a/react/features/app/types.ts+++ b/react/features/app/types.ts@@ -19,6 +19,8 @@ import { IResponsiveUIState } from '../base/responsive-ui/reducer';import { ISettingsState } from '../base/settings/reducer';import { ISoundsState } from '../base/sounds/reducer';import { ITestingState } from '../base/testing/reducer';+import { INoSrcDataState, ITracksState } from '../base/tracks/reducer';+import { IUserInteractionState } from '../base/user-interaction/reducer';import { INoiseSuppressionState } from '../noise-suppression/reducer';export interface IStore {@@ -45,9 +47,12 @@ export interface IState {'features/base/logging': ILoggingState,'features/base/media': IMediaState,'features/base/net-info': INetInfoState,+ 'features/base/no-src-data': INoSrcDataState,'features/base/responsive-ui': IResponsiveUIState,'features/base/settings': ISettingsState,'features/base/sounds': ISoundsState,+ 'features/base/tracks': ITracksState,+ 'features/base/user-interaction': IUserInteractionState,'features/noise-suppression': INoiseSuppressionState,'features/testing': ITestingState}diff --git a/react/features/base/tracks/reducer.js b/react/features/base/tracks/reducer.tssimilarity index 80%rename from react/features/base/tracks/reducer.jsrename to react/features/base/tracks/reducer.tsindex ad0af451ae..d44b93759c 100644--- a/react/features/base/tracks/reducer.js+++ b/react/features/base/tracks/reducer.ts@@ -1,5 +1,6 @@-import { PARTICIPANT_ID_CHANGED } from '../participants';-import { ReducerRegistry, set } from '../redux';+import { PARTICIPANT_ID_CHANGED } from '../participants/actionTypes';+import ReducerRegistry from '../redux/ReducerRegistry';+import { set } from '../redux/functions';import {SET_NO_SRC_DATA_NOTIFICATION_UID,@@ -13,6 +14,19 @@ import {TRACK_WILL_CREATE} from './actionTypes';+interface ITrack {+ isReceivingData: boolean;+ jitsiTrack: Object;+ lastMediaEvent?: string;+ local: boolean;+ mediaType: string;+ mirror: boolean;+ muted: boolean;+ participantId: string;+ videoStarted: boolean;+ videoType?: string|null;+}+/*** Track type.*@@ -52,7 +66,7 @@ import {* @param {Participant} action.participant - Information about participant.* @returns {Track|undefined}*/-function track(state, action) {+function track(state: ITrack, action: any) {switch (action.type) {case PARTICIPANT_ID_CHANGED:if (state.participantId === action.oldValue) {@@ -70,6 +84,7 @@ function track(state, action) {// Make sure that there's an actual update in order to reduce the// risk of unnecessary React Component renders.for (const p in t) {+ // @ts-ignoreif (state[p] !== t[p]) {// There's an actual update.return {@@ -115,16 +130,18 @@ function track(state, action) {return state;}+export type ITracksState = ITrack[];+/*** Listen for actions that mutate (e.g. Add, remove) local and remote tracks.*/-ReducerRegistry.register('features/base/tracks', (state = [], action) => {+ReducerRegistry.register('features/base/tracks', (state: ITracksState = [], action) => {switch (action.type) {case PARTICIPANT_ID_CHANGED:case TRACK_NO_DATA_FROM_SOURCE:case TRACK_UPDATE_LAST_VIDEO_MEDIA_EVENT:case TRACK_UPDATED:- return state.map(t => track(t, action));+ return state.map((t: ITrack) => track(t, action));case TRACK_ADDED: {let withoutTrackStub = state;@@ -132,7 +149,7 @@ ReducerRegistry.register('features/base/tracks', (state = [], action) => {if (action.track.local) {withoutTrackStub= state.filter(- t => !t.local || t.mediaType !== action.track.mediaType);+ (t: ITrack) => !t.local || t.mediaType !== action.track.mediaType);}return [ ...withoutTrackStub, action.track ];@@ -140,11 +157,11 @@ ReducerRegistry.register('features/base/tracks', (state = [], action) => {case TRACK_CREATE_CANCELED:case TRACK_CREATE_ERROR: {- return state.filter(t => !t.local || t.mediaType !== action.trackType);+ return state.filter((t: ITrack) => !t.local || t.mediaType !== action.trackType);}case TRACK_REMOVED:- return state.filter(t => t.jitsiTrack !== action.track.jitsiTrack);+ return state.filter((t: ITrack) => t.jitsiTrack !== action.track.jitsiTrack);case TRACK_WILL_CREATE:return [ ...state, action.track ];@@ -154,10 +171,14 @@ ReducerRegistry.register('features/base/tracks', (state = [], action) => {}});+export interface INoSrcDataState {+ noSrcDataNotificationUid?: string|number;+}+/*** Listen for actions that mutate the no-src-data state, like the current notification id.*/-ReducerRegistry.register('features/base/no-src-data', (state = {}, action) => {+ReducerRegistry.register('features/base/no-src-data', (state: INoSrcDataState = {}, action) => {switch (action.type) {case SET_NO_SRC_DATA_NOTIFICATION_UID:return set(state, 'noSrcDataNotificationUid', action.uid);diff --git a/react/features/base/user-interaction/reducer.js b/react/features/base/user-interaction/reducer.tssimilarity index 64%rename from react/features/base/user-interaction/reducer.jsrename to react/features/base/user-interaction/reducer.tsindex bb2c8a9247..54c8f28f61 100644--- a/react/features/base/user-interaction/reducer.js+++ b/react/features/base/user-interaction/reducer.ts@@ -1,11 +1,14 @@-// @flow--import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../app';-import { ReducerRegistry } from '../redux';+import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../app/actionTypes';+import ReducerRegistry from '../redux/ReducerRegistry';import { USER_INTERACTION_RECEIVED } from './actionTypes';-ReducerRegistry.register('features/base/user-interaction', (state = {}, action) => {+export interface IUserInteractionState {+ interacted?: boolean;+}+++ReducerRegistry.register('features/base/user-interaction', (state: IUserInteractionState = {}, action) => {switch (action.type) {case APP_WILL_MOUNT:case APP_WILL_UNMOUNT: