Skip to content

Commit 4fb2223

Browse files
committed
refactor: remove waffleFlags from state management and related selectors
1 parent bac374a commit 4fb2223

File tree

6 files changed

+3
-30
lines changed

6 files changed

+3
-30
lines changed

src/editors/containers/VideoEditor/components/VideoEditorModal.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import React, { useEffect } from 'react';
22
import { useDispatch, useSelector } from 'react-redux';
33
import { useLocation } from 'react-router-dom';
4+
import { useWaffleFlags } from '@src/data/apiHooks';
45
import * as appHooks from '../../../hooks';
56
import { thunkActions, selectors } from '../../../data/redux';
67
import VideoSettingsModal from './VideoSettingsModal';
78
import { RequestKeys } from '../../../data/constants/requests';
8-
import { getWaffleFlags } from '../../../data/redux/app/selectors';
99

1010
interface Props {
1111
onReturn?: (() => void);
@@ -42,7 +42,7 @@ const VideoEditorModal: React.FC<Props> = ({
4242
const isLoaded = useSelector(
4343
(state) => selectors.requests.isFinished(state, { requestKey: RequestKeys.fetchVideos }),
4444
);
45-
const waffleFlags = useSelector(getWaffleFlags);
45+
const { useNewVideoUploadsPage } = useWaffleFlags();
4646

4747
useEffect(() => {
4848
hooks.initialize(dispatch, selectedVideoId, selectedVideoUrl);
@@ -53,7 +53,7 @@ const VideoEditorModal: React.FC<Props> = ({
5353
onReturn: onSettingsReturn,
5454
isLibrary,
5555
onClose,
56-
useNewVideoUploadsPage: waffleFlags?.useNewVideoUploadsPage || false,
56+
useNewVideoUploadsPage,
5757
}}
5858
/>
5959
);

src/editors/data/redux/app/reducer.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ const initialState: EditorState['app'] = {
2222
courseDetails: {},
2323
showRawEditor: false,
2424
isMarkdownEditorEnabledForCourse: false,
25-
waffleFlags: {},
2625
};
2726

2827
// eslint-disable-next-line no-unused-vars
@@ -63,10 +62,6 @@ const app = createSlice({
6362
...state,
6463
showRawEditor: payload.data?.metadata?.editor === 'raw',
6564
}),
66-
setWaffleFlags: (state, { payload }) => ({
67-
...state,
68-
waffleFlags: payload,
69-
}),
7065
},
7166
});
7267

src/editors/data/redux/app/selectors.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export const simpleSelectors = {
2727
videos: mkSimpleSelector(app => app.videos),
2828
showRawEditor: mkSimpleSelector(app => app.showRawEditor),
2929
isMarkdownEditorEnabledForCourse: mkSimpleSelector(app => app.isMarkdownEditorEnabledForCourse),
30-
waffleFlags: mkSimpleSelector(app => app.waffleFlags),
3130
};
3231

3332
export const returnUrl = createSelector(
@@ -117,11 +116,6 @@ export const analytics = createSelector(
117116
),
118117
);
119118

120-
export const getWaffleFlags = createSelector(
121-
[simpleSelectors.waffleFlags],
122-
(waffleFlags) => waffleFlags,
123-
);
124-
125119
export default {
126120
...simpleSelectors,
127121
isInitialized,

src/editors/data/redux/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ export interface EditorState {
108108
courseDetails: Record<string, any>;
109109
showRawEditor: boolean;
110110
isMarkdownEditorEnabledForCourse: boolean;
111-
waffleFlags: Record<string, boolean>;
112111
},
113112
requests: Record<keyof typeof RequestKeys, {
114113
status: keyof typeof RequestStates;

src/editors/data/redux/thunkActions/app.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import * as module from './app';
88
import { actions as appActions, selectors } from '../app';
99
import { actions as requestsActions } from '../requests';
1010
import { RequestKeys } from '../../constants/requests';
11-
import { getWaffleFlags } from '../../../../data/api';
1211

1312
// Similar to `import { actions } from '..';` but avoid circular imports:
1413
const actions = {
@@ -80,13 +79,6 @@ export const fetchCourseDetails = () => (dispatch) => {
8079
}));
8180
};
8281

83-
export function fetchWaffleFlags(courseId) {
84-
return async (dispatch) => {
85-
const waffleFlags = await getWaffleFlags(courseId);
86-
dispatch(appActions.setWaffleFlags(waffleFlags));
87-
};
88-
}
89-
9082
/**
9183
* @param {string} studioEndpointUrl
9284
* @param {string} blockId
@@ -112,7 +104,6 @@ export const initialize = (data) => (dispatch) => {
112104
dispatch(module.fetchImages({ pageNumber: 0 }));
113105
break;
114106
case 'video':
115-
dispatch(module.fetchWaffleFlags(data.courseId));
116107
dispatch(module.fetchVideos());
117108
dispatch(module.fetchStudioView());
118109
dispatch(module.fetchCourseDetails());

src/editors/data/redux/thunkActions/app.test.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -303,16 +303,13 @@ describe('app thunkActions', () => {
303303
fetchImages,
304304
fetchVideos,
305305
fetchCourseDetails,
306-
fetchWaffleFlags,
307306
} = thunkActions;
308-
const waffleFlagsThunk = jest.fn(() => 'fetchWaffleFlags');
309307
thunkActions.fetchBlock = () => 'fetchBlock';
310308
thunkActions.fetchUnit = () => 'fetchUnit';
311309
thunkActions.fetchStudioView = () => 'fetchStudioView';
312310
thunkActions.fetchImages = () => 'fetchImages';
313311
thunkActions.fetchVideos = () => 'fetchVideos';
314312
thunkActions.fetchCourseDetails = () => 'fetchCourseDetails';
315-
thunkActions.fetchWaffleFlags = jest.fn().mockImplementation(() => waffleFlagsThunk);
316313
const data = {
317314
...testValue,
318315
blockType: 'video',
@@ -326,19 +323,16 @@ describe('app thunkActions', () => {
326323
[actions.app.initialize(data)],
327324
[thunkActions.fetchBlock()],
328325
[thunkActions.fetchUnit()],
329-
[waffleFlagsThunk],
330326
[thunkActions.fetchVideos()],
331327
[thunkActions.fetchStudioView()],
332328
[thunkActions.fetchCourseDetails()],
333329
]);
334-
expect(thunkActions.fetchWaffleFlags).toHaveBeenCalledWith(data.courseId);
335330
thunkActions.fetchBlock = fetchBlock;
336331
thunkActions.fetchUnit = fetchUnit;
337332
thunkActions.fetchStudioView = fetchStudioView;
338333
thunkActions.fetchImages = fetchImages;
339334
thunkActions.fetchVideos = fetchVideos;
340335
thunkActions.fetchCourseDetails = fetchCourseDetails;
341-
thunkActions.fetchWaffleFlags = fetchWaffleFlags;
342336
});
343337
});
344338
describe('saveBlock', () => {

0 commit comments

Comments
 (0)