Skip to content

Commit ebea1d5

Browse files
committed
switch evaluator url source based on if language directory is enabled
1 parent 678c1da commit ebea1d5

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/commons/sagas/WorkspaceSaga/helpers/evalCode.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import { EventType } from '../../../../features/achievement/AchievementTypes';
1818
import type { BrowserHostPlugin } from '../../../../features/conductor/BrowserHostPlugin';
1919
import { createConductor } from '../../../../features/conductor/createConductor';
2020
import { selectConductorEnable } from '../../../../features/conductor/flagConductorEnable';
21+
import { selectConductorEvaluatorUrl } from '../../../../features/conductor/flagConductorEvaluatorUrl';
22+
import { selectDirectoryLanguageEnable } from '../../../../features/directory/flagDirectoryLanguageEnable';
2123
import StoriesActions from '../../../../features/stories/StoriesActions';
2224
import { isSchemeLanguage, type OverallState } from '../../../application/ApplicationTypes';
2325
import { SideContentType } from '../../../sideContent/SideContentTypes';
@@ -463,12 +465,15 @@ export function* evalCodeConductorSaga(
463465
actionType: string,
464466
storyEnv?: string
465467
): SagaIterator {
466-
const evaluator: IEvaluatorDefinition | undefined = yield call(getEvaluatorDefinitionSaga);
467-
if (!evaluator?.path) throw Error('no evaluator');
468-
const evaluatorResponse: Response = yield call(
469-
fetch,
470-
evaluator.path // temporary evaluator
471-
);
468+
let path: string;
469+
if (yield select(selectDirectoryLanguageEnable)) {
470+
const evaluator: IEvaluatorDefinition | undefined = yield call(getEvaluatorDefinitionSaga);
471+
if (!evaluator?.path) throw Error('no evaluator');
472+
path = evaluator.path;
473+
} else {
474+
path = yield select(selectConductorEvaluatorUrl);
475+
}
476+
const evaluatorResponse: Response = yield call(fetch, path);
472477
if (!evaluatorResponse.ok) throw Error("can't get evaluator");
473478
const evaluatorBlob: Blob = yield call([evaluatorResponse, 'blob']);
474479
const url: string = yield call(URL.createObjectURL, evaluatorBlob);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { createFeatureFlag } from '../../commons/featureFlags';
2+
import { featureSelector } from '../../commons/featureFlags/featureSelector';
23

34
export const flagConductorEvaluatorUrl = createFeatureFlag(
45
'conductor.evaluator.url',
56
'https://fyp.tsammeow.dev/evaluator/0.2.1/worker.js',
67
'The URL where Conductor may find the Runner to be used for running user programs.'
78
);
9+
10+
export const selectConductorEvaluatorUrl = featureSelector(flagConductorEvaluatorUrl);

0 commit comments

Comments
 (0)