Skip to content

Commit 8c3a891

Browse files
authored
fix(client): avoid redundant updateFile dispatch on load when files are unchanged (freeCodeCamp#66326)
1 parent 0e25761 commit 8c3a891

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

client/src/templates/Challenges/redux/execute-challenge-saga.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,8 @@ export function* previewChallengeSaga(action) {
317317
const logs = results[0].logs?.filter(
318318
log => !LOGS_TO_IGNORE.some(msg => log.msg === msg)
319319
);
320-
yield put(updateConsole(logs?.map(log => log.msg).join('\n')));
320+
const output = logs?.map(log => log.msg).join('\n');
321+
yield put((flushLogs ? initConsole : updateConsole)(output));
321322
}
322323
}
323324
}
@@ -390,10 +391,14 @@ function* previewProjectSolutionSaga({ payload }) {
390391
export function createExecuteChallengeSaga(types) {
391392
return [
392393
takeLatest(types.executeChallenge, executeCancellableChallengeSaga),
393-
takeLatest(types.updateFile, updatePreviewSaga),
394394
takeLatest(
395-
[types.challengeMounted, types.resetChallenge, types.previewMounted],
396-
previewChallengeSaga
395+
[
396+
types.updateFile,
397+
types.challengeMounted,
398+
types.resetChallenge,
399+
types.previewMounted
400+
],
401+
updatePreviewSaga
397402
),
398403
takeLatest(types.projectPreviewMounted, previewProjectSolutionSaga)
399404
];

0 commit comments

Comments
 (0)