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 (#11988)

Robert Pintilii5f04c5ba6450
diff --git a/react/features/app/types.ts b/react/features/app/types.ts
index 6e35279870..f8af433fc3 100644
--- a/react/features/app/types.ts
+++ b/react/features/app/types.ts
@@ -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
}
diff --git a/react/features/base/participants/reducer.ts b/react/features/base/participants/reducer.ts
index de311daa1b..8ae007bf64 100644
--- a/react/features/base/participants/reducer.ts
+++ b/react/features/base/participants/reducer.ts
@@ -67,7 +67,7 @@ export interface Participant {
supportsRemoteControl?: boolean;
}
-interface LocalParticipant extends Participant {
+export interface LocalParticipant extends Participant {
audioOutputDeviceId?: string;
cameraDeviceId?: string;
micDeviceId?: string;
diff --git a/react/features/breakout-rooms/constants.js b/react/features/breakout-rooms/constants.ts
similarity index 100%
rename from react/features/breakout-rooms/constants.js
rename to react/features/breakout-rooms/constants.ts
diff --git a/react/features/breakout-rooms/reducer.js b/react/features/breakout-rooms/reducer.ts
similarity index 54%
rename from react/features/breakout-rooms/reducer.js
rename to react/features/breakout-rooms/reducer.ts
index abc2aeb206..f08cab01c2 100644
--- a/react/features/breakout-rooms/reducer.js
+++ b/react/features/breakout-rooms/reducer.ts
@@ -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 {
diff --git a/react/features/calendar-sync/reducer.js b/react/features/calendar-sync/reducer.tsx
similarity index 81%
rename from react/features/calendar-sync/reducer.js
rename to react/features/calendar-sync/reducer.tsx
index c243c0ae97..dfbf4b1749 100644
--- a/react/features/calendar-sync/reducer.js
+++ b/react/features/calendar-sync/reducer.tsx
@@ -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;
diff --git a/react/features/chat/reducer.js b/react/features/chat/reducer.ts
similarity index 82%
rename from react/features/chat/reducer.js
rename to react/features/chat/reducer.ts
index 54ae0e0487..e53514618a 100644
--- a/react/features/chat/reducer.js
+++ b/react/features/chat/reducer.ts
@@ -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,
diff --git a/react/features/deep-linking/reducer.js b/react/features/deep-linking/reducer.ts
similarity index 69%
rename from react/features/deep-linking/reducer.js
rename to react/features/deep-linking/reducer.ts
index 2ef34a041c..c44319cf01 100644
--- a/react/features/deep-linking/reducer.js
+++ b/react/features/deep-linking/reducer.ts
@@ -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: {
diff --git a/react/features/dropbox/reducer.js b/react/features/dropbox/reducer.ts
similarity index 62%
rename from react/features/dropbox/reducer.js
rename to react/features/dropbox/reducer.ts
index 60362e79f8..dcc504e3d0 100644
--- a/react/features/dropbox/reducer.js
+++ b/react/features/dropbox/reducer.ts
@@ -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 {
diff --git a/react/features/dynamic-branding/reducer.js b/react/features/dynamic-branding/reducer.ts
similarity index 86%
rename from react/features/dynamic-branding/reducer.js
rename to react/features/dynamic-branding/reducer.ts
index 5f6558e6d5..95a04b4995 100644
--- a/react/features/dynamic-branding/reducer.js
+++ b/react/features/dynamic-branding/reducer.ts
@@ -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;
diff --git a/react/features/e2ee/constants.js b/react/features/e2ee/constants.ts
similarity index 99%
rename from react/features/e2ee/constants.js
rename to react/features/e2ee/constants.ts
index f09cdc2686..4e0313def2 100644
--- a/react/features/e2ee/constants.js
+++ b/react/features/e2ee/constants.ts
@@ -1,5 +1,3 @@
-// @flow
-
/**
* The identifier of the sound to be played when e2ee is disabled.
*
diff --git a/react/features/e2ee/reducer.js b/react/features/e2ee/reducer.ts
similarity index 75%
rename from react/features/e2ee/reducer.js
rename to react/features/e2ee/reducer.ts
index ed757de908..d31377675e 100644
--- a/react/features/e2ee/reducer.js
+++ b/react/features/e2ee/reducer.ts
@@ -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 {
diff --git a/react/features/etherpad/reducer.js b/react/features/etherpad/reducer.ts
similarity index 80%
rename from react/features/etherpad/reducer.js
rename to react/features/etherpad/reducer.ts
index e9bacb9c13..12406ee300 100644
--- a/react/features/etherpad/reducer.js
+++ b/react/features/etherpad/reducer.ts
@@ -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 {
diff --git a/react/features/virtual-background/constants.js b/react/features/virtual-background/constants.ts
similarity index 96%
rename from react/features/virtual-background/constants.js
rename to react/features/virtual-background/constants.ts
index bfd7dcaf9c..cda33f3916 100644
--- a/react/features/virtual-background/constants.js
+++ b/react/features/virtual-background/constants.ts
@@ -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