ref: Convert some reducers to TS (#11988)
This commit is contained in:
parent
8f5eabe1f2
commit
5f04c5ba64
|
@ -22,6 +22,14 @@ 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 { IBreakoutRoomsState } from '../breakout-rooms/reducer';
|
||||
import { ICalendarSyncState } from '../calendar-sync/reducer';
|
||||
import { IChatState } from '../chat/reducer';
|
||||
import { IDeepLinkingState } from '../deep-linking/reducer';
|
||||
import { IDropboxState } from '../dropbox/reducer';
|
||||
import { IDynamicBrandingState } from '../dynamic-branding/reducer';
|
||||
import { IE2EEState } from '../e2ee/reducer';
|
||||
import { IEtherpadState } from '../etherpad/reducer';
|
||||
import { INoiseSuppressionState } from '../noise-suppression/reducer';
|
||||
|
||||
export interface IStore {
|
||||
|
@ -55,6 +63,14 @@ export interface IState {
|
|||
'features/base/sounds': ISoundsState,
|
||||
'features/base/tracks': ITracksState,
|
||||
'features/base/user-interaction': IUserInteractionState,
|
||||
'features/breakout-rooms': IBreakoutRoomsState,
|
||||
'features/calendar-sync': ICalendarSyncState,
|
||||
'features/chat': IChatState,
|
||||
'features/deep-linking': IDeepLinkingState,
|
||||
'features/dropbox': IDropboxState,
|
||||
'features/dynamic-branding': IDynamicBrandingState,
|
||||
'features/e2ee': IE2EEState,
|
||||
'features/etherpad': IEtherpadState,
|
||||
'features/noise-suppression': INoiseSuppressionState,
|
||||
'features/testing': ITestingState
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ export interface Participant {
|
|||
supportsRemoteControl?: boolean;
|
||||
}
|
||||
|
||||
interface LocalParticipant extends Participant {
|
||||
export interface LocalParticipant extends Participant {
|
||||
audioOutputDeviceId?: string;
|
||||
cameraDeviceId?: string;
|
||||
micDeviceId?: string;
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
// @flow
|
||||
|
||||
import { ReducerRegistry } from '../base/redux';
|
||||
import ReducerRegistry from '../base/redux/ReducerRegistry';
|
||||
|
||||
import {
|
||||
_RESET_BREAKOUT_ROOMS,
|
||||
|
@ -14,10 +12,29 @@ const DEFAULT_STATE = {
|
|||
roomCounter: 0
|
||||
};
|
||||
|
||||
export interface IBreakoutRoomsState {
|
||||
roomCounter: number;
|
||||
rooms: {
|
||||
[id: string]: {
|
||||
id: string;
|
||||
isMainRoom?: boolean;
|
||||
jid: string;
|
||||
name: string;
|
||||
participants: {
|
||||
[jid: string]: {
|
||||
displayName: string;
|
||||
jid: string;
|
||||
role: string;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Listen for actions for the breakout-rooms feature.
|
||||
*/
|
||||
ReducerRegistry.register(FEATURE_KEY, (state = DEFAULT_STATE, action) => {
|
||||
ReducerRegistry.register(FEATURE_KEY, (state: IBreakoutRoomsState = DEFAULT_STATE, action: any) => {
|
||||
switch (action.type) {
|
||||
case _UPDATE_ROOM_COUNTER:
|
||||
return {
|
|
@ -1,6 +1,6 @@
|
|||
// @flow
|
||||
|
||||
import { PersistenceRegistry, ReducerRegistry, set } from '../base/redux';
|
||||
import PersistenceRegistry from '../base/redux/PersistenceRegistry';
|
||||
import ReducerRegistry from '../base/redux/ReducerRegistry';
|
||||
import { set } from '../base/redux/functions';
|
||||
|
||||
import {
|
||||
CLEAR_CALENDAR_INTEGRATION,
|
||||
|
@ -26,6 +26,17 @@ const DEFAULT_STATE = {
|
|||
msAuthState: undefined
|
||||
};
|
||||
|
||||
export interface ICalendarSyncState {
|
||||
authorization?: string;
|
||||
error?: Object;
|
||||
events: Array<Object>;
|
||||
integrationReady: boolean;
|
||||
integrationType?: string;
|
||||
isLoadingEvents?: boolean;
|
||||
msAuthState?: Object;
|
||||
profileEmail?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constant for the Redux subtree of the calendar feature.
|
||||
*
|
||||
|
@ -47,7 +58,7 @@ PersistenceRegistry.register(STORE_NAME, {
|
|||
msAuthState: true
|
||||
});
|
||||
|
||||
ReducerRegistry.register(STORE_NAME, (state = DEFAULT_STATE, action) => {
|
||||
ReducerRegistry.register(STORE_NAME, (state: ICalendarSyncState = DEFAULT_STATE, action) => {
|
||||
switch (action.type) {
|
||||
case CLEAR_CALENDAR_INTEGRATION:
|
||||
return DEFAULT_STATE;
|
|
@ -1,8 +1,7 @@
|
|||
// @flow
|
||||
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
import { ReducerRegistry } from '../base/redux';
|
||||
import { LocalParticipant, Participant } from '../base/participants/reducer';
|
||||
import ReducerRegistry from '../base/redux/ReducerRegistry';
|
||||
|
||||
import {
|
||||
ADD_MESSAGE,
|
||||
|
@ -21,7 +20,6 @@ const DEFAULT_STATE = {
|
|||
isOpen: false,
|
||||
isPollsTabFocused: false,
|
||||
lastReadMessage: undefined,
|
||||
lastReadPoll: undefined,
|
||||
messages: [],
|
||||
nbUnreadMessages: 0,
|
||||
privateMessageRecipient: undefined,
|
||||
|
@ -29,10 +27,38 @@ const DEFAULT_STATE = {
|
|||
isLobbyChatActive: false
|
||||
};
|
||||
|
||||
ReducerRegistry.register('features/chat', (state = DEFAULT_STATE, action) => {
|
||||
interface IMessage {
|
||||
displayName: string;
|
||||
error?: Object;
|
||||
id: string;
|
||||
isReaction: boolean;
|
||||
lobbyChat: boolean;
|
||||
message: string;
|
||||
messageId: string;
|
||||
messageType: string;
|
||||
privateMessage: boolean;
|
||||
recipient: string;
|
||||
timestamp: string;
|
||||
}
|
||||
|
||||
export interface IChatState {
|
||||
isLobbyChatActive: boolean;
|
||||
isOpen: boolean;
|
||||
isPollsTabFocused: boolean;
|
||||
lastReadMessage?: IMessage;
|
||||
lobbyMessageRecipient?: {
|
||||
id: string;
|
||||
name: string;
|
||||
} | LocalParticipant,
|
||||
messages: IMessage[];
|
||||
nbUnreadMessages: number;
|
||||
privateMessageRecipient?: Participant;
|
||||
}
|
||||
|
||||
ReducerRegistry.register('features/chat', (state: IChatState = DEFAULT_STATE, action) => {
|
||||
switch (action.type) {
|
||||
case ADD_MESSAGE: {
|
||||
const newMessage = {
|
||||
const newMessage: IMessage = {
|
||||
displayName: action.displayName,
|
||||
error: action.error,
|
||||
id: action.id,
|
|
@ -1,9 +1,11 @@
|
|||
/* @flow */
|
||||
|
||||
import { ReducerRegistry } from '../base/redux';
|
||||
import ReducerRegistry from '../base/redux/ReducerRegistry';
|
||||
|
||||
import { OPEN_WEB_APP } from './actionTypes';
|
||||
|
||||
export interface IDeepLinkingState {
|
||||
launchInWeb?: boolean;
|
||||
}
|
||||
|
||||
ReducerRegistry.register('features/deep-linking', (state = {}, action) => {
|
||||
switch (action.type) {
|
||||
case OPEN_WEB_APP: {
|
|
@ -1,6 +1,5 @@
|
|||
// @flow
|
||||
|
||||
import { PersistenceRegistry, ReducerRegistry } from '../base/redux';
|
||||
import PersistenceRegistry from '../base/redux/PersistenceRegistry';
|
||||
import ReducerRegistry from '../base/redux/ReducerRegistry';
|
||||
|
||||
import { UPDATE_DROPBOX_TOKEN } from './actionTypes';
|
||||
|
||||
|
@ -9,12 +8,18 @@ import { UPDATE_DROPBOX_TOKEN } from './actionTypes';
|
|||
*/
|
||||
const STORE_NAME = 'features/dropbox';
|
||||
|
||||
export interface IDropboxState {
|
||||
expireDate?: number;
|
||||
rToken?: string;
|
||||
token?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the persistence of the feature {@code dropbox}.
|
||||
*/
|
||||
PersistenceRegistry.register(STORE_NAME);
|
||||
|
||||
ReducerRegistry.register(STORE_NAME, (state = {}, action) => {
|
||||
ReducerRegistry.register(STORE_NAME, (state: IDropboxState = {}, action) => {
|
||||
switch (action.type) {
|
||||
case UPDATE_DROPBOX_TOKEN:
|
||||
return {
|
|
@ -1,6 +1,4 @@
|
|||
// @flow
|
||||
|
||||
import { ReducerRegistry } from '../base/redux';
|
||||
import ReducerRegistry from '../base/redux/ReducerRegistry';
|
||||
import { type Image } from '../virtual-background/constants';
|
||||
|
||||
import {
|
||||
|
@ -144,10 +142,28 @@ const DEFAULT_STATE = {
|
|||
virtualBackgrounds: []
|
||||
};
|
||||
|
||||
export interface IDynamicBrandingState {
|
||||
avatarBackgrounds: string[];
|
||||
backgroundColor: string;
|
||||
backgroundImageUrl: string;
|
||||
customizationFailed: boolean;
|
||||
customizationReady: boolean;
|
||||
defaultBranding: boolean;
|
||||
didPageUrl: string;
|
||||
inviteDomain: string;
|
||||
labels: Object|null;
|
||||
logoClickUrl: string;
|
||||
logoImageUrl: string;
|
||||
muiBrandedTheme?: boolean;
|
||||
premeetingBackground: string;
|
||||
useDynamicBrandingData: boolean;
|
||||
virtualBackgrounds: Array<Image>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reduces redux actions for the purposes of the feature {@code dynamic-branding}.
|
||||
*/
|
||||
ReducerRegistry.register(STORE_NAME, (state = DEFAULT_STATE, action) => {
|
||||
ReducerRegistry.register(STORE_NAME, (state: IDynamicBrandingState = DEFAULT_STATE, action) => {
|
||||
switch (action.type) {
|
||||
case SET_DYNAMIC_BRANDING_DATA: {
|
||||
const {
|
||||
|
@ -212,7 +228,7 @@ ReducerRegistry.register(STORE_NAME, (state = DEFAULT_STATE, action) => {
|
|||
* @private
|
||||
* @returns {{Props}}
|
||||
*/
|
||||
function formatImages(images: Array<string> | Array<Object>): Array<Image> {
|
||||
function formatImages(images: Array<string> | Array<{src: string; tooltip?: string}>): Array<Image> {
|
||||
return images.map((img, i) => {
|
||||
let src;
|
||||
let tooltip;
|
|
@ -1,5 +1,3 @@
|
|||
// @flow
|
||||
|
||||
/**
|
||||
* The identifier of the sound to be played when e2ee is disabled.
|
||||
*
|
|
@ -1,6 +1,4 @@
|
|||
// @flow
|
||||
|
||||
import { ReducerRegistry } from '../base/redux';
|
||||
import ReducerRegistry from '../base/redux/ReducerRegistry';
|
||||
|
||||
import {
|
||||
SET_EVERYONE_ENABLED_E2EE,
|
||||
|
@ -15,10 +13,17 @@ const DEFAULT_STATE = {
|
|||
maxMode: MAX_MODE.DISABLED
|
||||
};
|
||||
|
||||
export interface IE2EEState {
|
||||
enabled: boolean;
|
||||
everyoneEnabledE2EE?: boolean;
|
||||
everyoneSupportE2EE?: boolean;
|
||||
maxMode: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reduces the Redux actions of the feature features/e2ee.
|
||||
*/
|
||||
ReducerRegistry.register('features/e2ee', (state = DEFAULT_STATE, action) => {
|
||||
ReducerRegistry.register('features/e2ee', (state: IE2EEState = DEFAULT_STATE, action) => {
|
||||
switch (action.type) {
|
||||
case TOGGLE_E2EE:
|
||||
return {
|
|
@ -1,6 +1,4 @@
|
|||
// @flow
|
||||
|
||||
import { ReducerRegistry } from '../base/redux';
|
||||
import ReducerRegistry from '../base/redux/ReducerRegistry';
|
||||
|
||||
import { SET_DOCUMENT_EDITING_STATUS, SET_DOCUMENT_URL } from './actionTypes';
|
||||
|
||||
|
@ -20,12 +18,17 @@ const DEFAULT_STATE = {
|
|||
editing: false
|
||||
};
|
||||
|
||||
export interface IEtherpadState {
|
||||
documentUrl?: string;
|
||||
editing: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reduces the Redux actions of the feature features/etherpad.
|
||||
*/
|
||||
ReducerRegistry.register(
|
||||
'features/etherpad',
|
||||
(state = DEFAULT_STATE, action) => {
|
||||
(state: IEtherpadState = DEFAULT_STATE, action) => {
|
||||
switch (action.type) {
|
||||
case SET_DOCUMENT_EDITING_STATUS:
|
||||
return {
|
|
@ -1,5 +1,3 @@
|
|||
// @flow
|
||||
|
||||
/**
|
||||
* An enumeration of the different virtual background types.
|
||||
*
|
||||
|
@ -14,9 +12,9 @@ export const VIRTUAL_BACKGROUND_TYPE = {
|
|||
|
||||
|
||||
export type Image = {
|
||||
tooltip?: string,
|
||||
id: string,
|
||||
src: string
|
||||
src: string,
|
||||
tooltip?: string
|
||||
}
|
||||
|
||||
// The limit of virtual background uploads is 24. When the number
|
Loading…
Reference in New Issue