mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-02-03 09:04:13 -05:00
feat: replace code lock epic with saga (#50088)
This commit is contained in:
@@ -22,8 +22,6 @@ export const actionTypes = createTypes(
|
||||
|
||||
'logsToConsole',
|
||||
|
||||
'lockCode',
|
||||
'unlockCode',
|
||||
'disableBuildOnError',
|
||||
'storedCodeFound',
|
||||
'noStoredCodeFound',
|
||||
|
||||
@@ -43,8 +43,6 @@ export const setShowPreviewPane = createAction(actionTypes.setShowPreviewPane);
|
||||
|
||||
export const logsToConsole = createAction(actionTypes.logsToConsole);
|
||||
|
||||
export const lockCode = createAction(actionTypes.lockCode);
|
||||
export const unlockCode = createAction(actionTypes.unlockCode);
|
||||
export const disableBuildOnError = createAction(
|
||||
actionTypes.disableBuildOnError
|
||||
);
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
import { ofType } from 'redux-observable';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
import { actionTypes } from './action-types';
|
||||
import { unlockCode } from './actions';
|
||||
|
||||
function codeLockEpic(action$) {
|
||||
return action$.pipe(ofType(actionTypes.updateFile), map(unlockCode));
|
||||
}
|
||||
|
||||
export default codeLockEpic;
|
||||
@@ -10,11 +10,7 @@ import { savedChallengesSelector } from '../../../redux/selectors';
|
||||
import { actionTypes as appTypes } from '../../../redux/action-types';
|
||||
import { actionTypes } from './action-types';
|
||||
import { noStoredCodeFound, storedCodeFound } from './actions';
|
||||
import {
|
||||
challengeFilesSelector,
|
||||
challengeMetaSelector,
|
||||
isCodeLockedSelector
|
||||
} from './selectors';
|
||||
import { challengeFilesSelector, challengeMetaSelector } from './selectors';
|
||||
|
||||
const legacyPrefixes = [
|
||||
'Bonfire: ',
|
||||
@@ -86,7 +82,6 @@ function saveCodeEpic(action$, state$) {
|
||||
return action$.pipe(
|
||||
ofType(actionTypes.executeChallenge, actionTypes.saveEditorContent),
|
||||
// do not save challenge if code is locked
|
||||
filter(() => !isCodeLockedSelector(state$.value)),
|
||||
map(action => {
|
||||
const state = state$.value;
|
||||
const { id } = challengeMetaSelector(state);
|
||||
|
||||
@@ -4,7 +4,6 @@ import { handleActions } from 'redux-actions';
|
||||
import { getLines } from '../../../../../utils/get-lines';
|
||||
import { getTargetEditor } from '../utils/get-target-editor';
|
||||
import { actionTypes, ns } from './action-types';
|
||||
import codeLockEpic from './code-lock-epic';
|
||||
import codeStorageEpic from './code-storage-epic';
|
||||
import completionEpic from './completion-epic';
|
||||
import createQuestionEpic from './create-question-epic';
|
||||
@@ -29,7 +28,6 @@ const initialState = {
|
||||
challengeTests: [],
|
||||
consoleOut: [],
|
||||
hasCompletedBlock: false,
|
||||
isCodeLocked: false,
|
||||
isBuildEnabled: true,
|
||||
isResetting: false,
|
||||
logsOut: [],
|
||||
@@ -49,12 +47,7 @@ const initialState = {
|
||||
isAdvancing: false
|
||||
};
|
||||
|
||||
export const epics = [
|
||||
codeLockEpic,
|
||||
completionEpic,
|
||||
createQuestionEpic,
|
||||
codeStorageEpic
|
||||
];
|
||||
export const epics = [completionEpic, createQuestionEpic, codeStorageEpic];
|
||||
|
||||
export const sagas = [
|
||||
...createExecuteChallengeSaga(actionTypes),
|
||||
@@ -167,16 +160,6 @@ export const reducer = handleActions(
|
||||
...state,
|
||||
projectFormValues: payload
|
||||
}),
|
||||
|
||||
[actionTypes.lockCode]: state => ({
|
||||
...state,
|
||||
isCodeLocked: true
|
||||
}),
|
||||
[actionTypes.unlockCode]: state => ({
|
||||
...state,
|
||||
isBuildEnabled: true,
|
||||
isCodeLocked: false
|
||||
}),
|
||||
[actionTypes.disableBuildOnError]: state => ({
|
||||
...state,
|
||||
isBuildEnabled: false
|
||||
|
||||
Reference in New Issue
Block a user