ref: Convert some reducers to TS (#12002)

This commit is contained in:
Robert Pintilii 2022-08-10 12:56:24 +03:00 committed by GitHub
parent 8266d55cb9
commit 00221b7482
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 58 additions and 18 deletions

View File

@ -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
}

View File

@ -1,5 +1,3 @@
// @flow
import { getLogger } from '../base/logging/functions';
export default getLogger('features/invite');

View File

@ -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 {

View File

@ -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: {

View File

@ -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

View File

@ -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 = {