Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

ref: Convert some reducers to TS (#12002)

Robert Pintilii00221b748280
diff --git a/react/features/app/types.ts b/react/features/app/types.ts
index eca11d08eb..8ff940e5d9 100644
--- a/react/features/app/types.ts
+++ b/react/features/app/types.ts
@@ -36,6 +36,10 @@ import { IFilmstripState } from '../filmstrip/reducer';
import { IFollowMeState } from '../follow-me/reducer';
import { IGifsState } from '../gifs/reducer';
import { IGoogleApiState } from '../google-api/reducer';
+import { IInviteState } from '../invite/reducer';
+import { IJaaSState } from '../jaas/reducer';
+import { ILargeVideoState } from '../large-video/reducer';
+import { ILobbyState } from '../lobby/reducer';
import { INoiseSuppressionState } from '../noise-suppression/reducer';
export interface IStore {
@@ -83,6 +87,10 @@ export interface IState {
'features/follow-me': IFollowMeState,
'features/gifs': IGifsState,
'features/google-api': IGoogleApiState,
+ 'features/invite': IInviteState,
+ 'features/jaas': IJaaSState,
+ 'features/large-video': ILargeVideoState,
+ 'features/lobby': ILobbyState,
'features/noise-suppression': INoiseSuppressionState,
'features/testing': ITestingState
}
diff --git a/react/features/invite/logger.js b/react/features/invite/logger.ts
similarity index 90%
rename from react/features/invite/logger.js
rename to react/features/invite/logger.ts
index 4e9e3106fc..d57552b8e5 100644
--- a/react/features/invite/logger.js
+++ b/react/features/invite/logger.ts
@@ -1,5 +1,3 @@
-// @flow
-
import { getLogger } from '../base/logging/functions';
export default getLogger('features/invite');
diff --git a/react/features/invite/reducer.js b/react/features/invite/reducer.ts
similarity index 79%
rename from react/features/invite/reducer.js
rename to react/features/invite/reducer.ts
index 73be613bb1..2efc4080e4 100644
--- a/react/features/invite/reducer.js
+++ b/react/features/invite/reducer.ts
@@ -1,6 +1,4 @@
-// @flow
-
-import { ReducerRegistry } from '../base/redux';
+import ReducerRegistry from '../base/redux/ReducerRegistry';
import {
ADD_PENDING_INVITE_REQUEST,
@@ -24,7 +22,22 @@ const DEFAULT_STATE = {
pendingInviteRequests: []
};
-ReducerRegistry.register('features/invite', (state = DEFAULT_STATE, action) => {
+export interface IInviteState {
+ calleeInfoVisible?: boolean;
+ conferenceID?: string;
+ error?: Error;
+ initialCalleeInfo?: Object;
+ numbers?: string;
+ numbersEnabled: boolean;
+ numbersFetched: boolean;
+ pendingInviteRequests: Array<{
+ callback: Function;
+ invitees: Array<Object>;
+ }>;
+ sipUri?: string;
+}
+
+ReducerRegistry.register('features/invite', (state: IInviteState = DEFAULT_STATE, action) => {
switch (action.type) {
case ADD_PENDING_INVITE_REQUEST:
return {
diff --git a/react/features/jaas/constants.js b/react/features/jaas/constants.ts
similarity index 100%
rename from react/features/jaas/constants.js
rename to react/features/jaas/constants.ts
diff --git a/react/features/jaas/reducer.js b/react/features/jaas/reducer.ts
similarity index 69%
rename from react/features/jaas/reducer.js
rename to react/features/jaas/reducer.ts
index b15cdd3560..af82206b8f 100644
--- a/react/features/jaas/reducer.js
+++ b/react/features/jaas/reducer.ts
@@ -1,4 +1,4 @@
-import { ReducerRegistry } from '../base/redux';
+import ReducerRegistry from '../base/redux/ReducerRegistry';
import {
SET_DETAILS
@@ -10,11 +10,15 @@ const DEFAULT_STATE = {
status: STATUSES.ACTIVE
};
+export interface IJaaSState {
+ [key: string]: any
+}
+
/**
* Listen for actions that mutate the billing-counter state.
*/
ReducerRegistry.register(
- 'features/jaas', (state = DEFAULT_STATE, action) => {
+ 'features/jaas', (state: IJaaSState = DEFAULT_STATE, action) => {
switch (action.type) {
case SET_DETAILS: {
diff --git a/react/features/large-video/reducer.js b/react/features/large-video/reducer.ts
similarity index 78%
rename from react/features/large-video/reducer.js
rename to react/features/large-video/reducer.ts
index 5266c97b20..a1f542f171 100644
--- a/react/features/large-video/reducer.js
+++ b/react/features/large-video/reducer.ts
@@ -1,7 +1,5 @@
-// @flow
-
-import { PARTICIPANT_ID_CHANGED } from '../base/participants';
-import { ReducerRegistry } from '../base/redux';
+import { PARTICIPANT_ID_CHANGED } from '../base/participants/actionTypes';
+import ReducerRegistry from '../base/redux/ReducerRegistry';
import {
SELECT_LARGE_VIDEO_PARTICIPANT,
@@ -10,7 +8,14 @@ import {
SET_SEE_WHAT_IS_BEING_SHARED
} from './actionTypes';
-ReducerRegistry.register('features/large-video', (state = {}, action) => {
+export interface ILargeVideoState {
+ lastMediaEvent?: string;
+ participantId?: string;
+ resolution?: number;
+ seeWhatIsBeingShared?: boolean;
+}
+
+ReducerRegistry.register('features/large-video', (state: ILargeVideoState = {}, action) => {
switch (action.type) {
// When conference is joined, we update ID of local participant from default
diff --git a/react/features/lobby/reducer.js b/react/features/lobby/reducer.ts
similarity index 85%
rename from react/features/lobby/reducer.js
rename to react/features/lobby/reducer.ts
index 5f9c3d62f0..ac4fad5211 100644
--- a/react/features/lobby/reducer.js
+++ b/react/features/lobby/reducer.ts
@@ -1,7 +1,7 @@
-// @flow
-
+// @ts-ignore
import { CONFERENCE_JOINED, CONFERENCE_LEFT, SET_PASSWORD } from '../base/conference';
-import { ReducerRegistry } from '../base/redux';
+import { Participant } from '../base/participants/reducer';
+import ReducerRegistry from '../base/redux/ReducerRegistry';
import {
KNOCKING_PARTICIPANT_ARRIVED_OR_UPDATED,
@@ -22,6 +22,18 @@ const DEFAULT_STATE = {
passwordJoinFailed: false
};
+interface KnockingParticipant extends Participant {
+ chattingWithModerator?: string;
+}
+
+export interface ILobbyState {
+ knocking: boolean;
+ knockingParticipants: KnockingParticipant[];
+ lobbyEnabled: boolean;
+ lobbyVisible: boolean;
+ passwordJoinFailed: boolean;
+}
+
/**
* Reduces redux actions which affect the display of notifications.
*
@@ -30,7 +42,7 @@ const DEFAULT_STATE = {
* @returns {Object} The next redux state which is the result of reducing the
* specified {@code action}.
*/
-ReducerRegistry.register('features/lobby', (state = DEFAULT_STATE, action) => {
+ReducerRegistry.register('features/lobby', (state: ILobbyState = DEFAULT_STATE, action) => {
switch (action.type) {
case CONFERENCE_JOINED:
case CONFERENCE_LEFT:
@@ -112,7 +124,7 @@ ReducerRegistry.register('features/lobby', (state = DEFAULT_STATE, action) => {
* @param {Object} state - The current Redux state of the feature.
* @returns {Object}
*/
-function _knockingParticipantArrivedOrUpdated(participant, state) {
+function _knockingParticipantArrivedOrUpdated(participant: KnockingParticipant, state: ILobbyState) {
let existingParticipant = state.knockingParticipants.find(p => p.id === participant.id);
existingParticipant = {