Skip to content

Commit c1e4d02

Browse files
committed
Migrate files with compatibility issues
1 parent 3932358 commit c1e4d02

File tree

9 files changed

+20
-19
lines changed

9 files changed

+20
-19
lines changed

src/commons/editor/EditorContainer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import _ from 'lodash';
1+
import { pick } from 'es-toolkit';
22
import React from 'react';
33

44
import SourcecastEditor, {
@@ -40,7 +40,7 @@ export const convertEditorTabStateToProps = (
4040
return {
4141
editorTabIndex,
4242
editorValue: editorTab.value,
43-
..._.pick(editorTab, 'filePath', 'highlightedLines', 'breakpoints', 'newCursorPosition')
43+
...pick(editorTab, ['filePath', 'highlightedLines', 'breakpoints', 'newCursorPosition'])
4444
};
4545
};
4646

src/commons/mocks/StoreMocks.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Store } from '@reduxjs/toolkit';
2-
import _ from 'lodash';
2+
import { isObject, mergeWith } from 'es-toolkit/compat';
33
import mockStore from 'redux-mock-store';
44

55
import {
@@ -40,13 +40,13 @@ export function mockInitialStore(
4040
};
4141

4242
const lodashMergeCustomizer = (objValue: any, srcValue: any) => {
43-
if (_.isObject(objValue)) {
43+
if (isObject(objValue)) {
4444
return {
4545
...objValue, // destination object
4646
...srcValue // overrides
4747
};
4848
}
4949
};
5050

51-
return createStore(_.mergeWith(state, overrides, lodashMergeCustomizer));
51+
return createStore(mergeWith(state, overrides, lodashMergeCustomizer));
5252
}

src/commons/sagas/BackendSaga.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ const newBackendSagaOne = combineSagaHandlers({
151151
},
152152
[SessionActions.handleSamlRedirect.type]: function* (action) {
153153
const { jwtCookie } = action.payload;
154-
const tokens = _.mapKeys(JSON.parse(jwtCookie), (v, k) => _.camelCase(k)) as Tokens;
154+
const tokens = mapKeys(JSON.parse(jwtCookie), (v, k) => camelCase(k)) as Tokens;
155155

156156
yield put(actions.setTokens(tokens));
157157
yield put(actions.fetchUserAndCourse());

src/commons/sagas/RemoteExecutionSaga.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { SlingClient } from '@sourceacademy/sling-client';
2+
import { pickBy } from 'es-toolkit/compat';
23
import { assemble, compileFiles, type Context } from 'js-slang';
34
import { ExceptionError } from 'js-slang/dist/errors/errors';
45
import { Chapter, Variant } from 'js-slang/dist/types';
5-
import _ from 'lodash';
66
import { call, put, race, select, take } from 'redux-saga/effects';
77
import RemoteExecutionActions from 'src/features/remoteExecution/RemoteExecutionActions';
88
import {
@@ -126,7 +126,7 @@ const RemoteExecutionSaga = combineSagaHandlers({
126126
device: {
127127
...currentSession.device,
128128
peripherals: {
129-
..._.pickBy(
129+
...pickBy(
130130
currentSession.device.peripherals,
131131
p => Date.now() - p.lastUpdated < 3000
132132
),

src/commons/utils/RequestHelper.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Button } from '@blueprintjs/core';
2-
import _ from 'lodash';
2+
import { cloneDeep } from 'es-toolkit';
33
import { assessmentFullPathRegex } from 'src/features/academy/AcademyTypes';
44
import { store } from 'src/pages/createStore';
55

@@ -87,7 +87,7 @@ export const request = async (
8787
}
8888

8989
store.dispatch(actions.setTokens(newTokens));
90-
const updatedFetchOptions = _.cloneDeep(fetchOptions);
90+
const updatedFetchOptions = cloneDeep(fetchOptions);
9191
updatedFetchOptions.headers.set('Authorization', `Bearer ${newTokens.accessToken}`);
9292

9393
const retriedResp = await fetch(`${Constants.backendUrl}/v2/${path}`, updatedFetchOptions);

src/features/game/chapter/GameChapterHelpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import _ from 'lodash';
1+
import { sortBy } from 'es-toolkit/compat';
22
import { request } from 'src/commons/utils/RequestHelper';
33

44
import { store } from '../../../pages/createStore';
@@ -19,7 +19,7 @@ export async function fetchGameChapters(): Promise<GameChapter[]> {
1919
});
2020
if (!response) return [];
2121
const chapterDetails = response.status === 200 ? await response.json() : [];
22-
const sortedChapters = _.sortBy(chapterDetails, chapterDetail => new Date(chapterDetail.openAt));
22+
const sortedChapters = sortBy(chapterDetails, chapterDetail => new Date(chapterDetail.openAt));
2323
sortedChapters.forEach(chapter => (chapter.filenames = chapter.filenames.map(toTxtPath)));
2424
return sortedChapters;
2525
}

src/features/game/save/GameSaveRequests.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import _ from 'lodash';
1+
import { isEmpty } from 'es-toolkit/compat';
22
import Constants from 'src/commons/utils/Constants';
33

44
import SourceAcademyGame from '../SourceAcademyGame';
@@ -44,7 +44,7 @@ export async function loadData(): Promise<FullSaveState> {
4444
const message = await resp.text();
4545

4646
const json = JSON.parse(message).courseRegistration?.gameStates;
47-
return _.isEmpty(json) ? createEmptySaveState() : json;
47+
return isEmpty(json) ? createEmptySaveState() : json;
4848
}
4949

5050
/**

src/features/game/utils/StyleUtils.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import _ from 'lodash';
1+
import { mapValues } from 'es-toolkit';
2+
import { times } from 'es-toolkit/compat';
23

34
import { screenSize } from '../commons/CommonConstants';
45

@@ -21,7 +22,7 @@ export const Color = {
2122
};
2223

2324
const hex = (str: string) => parseInt(str.slice(1), 16);
24-
export const HexColor = _.mapValues(Color, hex);
25+
export const HexColor = mapValues(Color, hex);
2526

2627
type TableFormatPosConfig = {
2728
direction?: Direction;
@@ -64,7 +65,7 @@ export function calcTableFormatPos({
6465
let itemsPerList = numItemLimit || numOfItems;
6566
const numOfLists = Math.ceil(numOfItems / itemsPerList);
6667

67-
return _.times(numOfItems, itemNumber => {
68+
return times(numOfItems, itemNumber => {
6869
const itemIndexInList = itemNumber % itemsPerList;
6970
const listIndex = Math.floor(itemNumber / itemsPerList);
7071

src/features/gameSimulator/GameSimulatorService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import _ from 'lodash';
1+
import { sortBy } from 'es-toolkit/compat';
22

33
import { sendAdminStoryRequest, sendAssetRequest, sendStoryRequest } from './GameSimulatorRequest';
44
import { ChapterDetail } from './GameSimulatorTypes';
@@ -114,7 +114,7 @@ export async function uploadAssetToS3(file: File, folderName: string) {
114114
export async function fetchChapters(): Promise<ChapterDetail[]> {
115115
const response = await sendStoryRequest('', 'GET');
116116
const chapterDetails = response.status === 200 ? await response.json() : [];
117-
return _.sortBy(chapterDetails, (chapterDetail: ChapterDetail) => new Date(chapterDetail.openAt));
117+
return sortBy(chapterDetails, (chapterDetail: ChapterDetail) => new Date(chapterDetail.openAt));
118118
}
119119

120120
/**

0 commit comments

Comments
 (0)