Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Commit 0308598

Browse files
Łukasz SobekjasonLaster
authored andcommitted
Removes getIn (#5810)
1 parent 97aec24 commit 0308598

File tree

5 files changed

+26
-32
lines changed

5 files changed

+26
-32
lines changed

src/reducers/ast.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export function getSymbols(state: OuterState, source: Source): ?Symbols {
153153
return null;
154154
}
155155

156-
return state.ast.getIn(["symbols", source.id]) || null;
156+
return state.ast.symbols.get(source.id) || null;
157157
}
158158

159159
export function hasSymbols(state: OuterState, source: Source): boolean {
@@ -189,11 +189,11 @@ export function getEmptyLines(state: OuterState, source: Source) {
189189
return null;
190190
}
191191

192-
return state.ast.getIn(["emptyLines", source.id]);
192+
return state.ast.emptyLines.get(source.id);
193193
}
194194

195195
export function getPausePoints(state: OuterState, sourceId: string) {
196-
return state.ast.getIn(["pausePoints", sourceId]);
196+
return state.ast.pausePoints.get(sourceId);
197197
}
198198

199199
export function hasPausePoints(state: OuterState, sourceId: string): boolean {
@@ -211,7 +211,7 @@ export function getPreview(state: OuterState) {
211211

212212
const emptySourceMetaData = {};
213213
export function getSourceMetaData(state: OuterState, sourceId: string) {
214-
return state.ast.getIn(["sourceMetaData", sourceId]) || emptySourceMetaData;
214+
return state.ast.sourceMetaData.get(sourceId) || emptySourceMetaData;
215215
}
216216

217217
export function hasSourceMetaData(state: OuterState, sourceId: string) {

src/reducers/expressions.js

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,20 @@ function update(
4040
if (action.expressionError) {
4141
return state.set("expressionError", !!action.expressionError);
4242
}
43-
return appendToList(state, ["expressions"], {
43+
return appendExpressionToList(state, {
4444
input: action.input,
4545
value: null,
4646
updating: true
4747
});
4848
case "UPDATE_EXPRESSION":
4949
const key = action.expression.input;
50-
return updateItemInList(state, ["expressions"], key, {
50+
return updateExpressionInList(state, key, {
5151
input: action.input,
5252
value: null,
5353
updating: true
5454
}).set("expressionError", !!action.expressionError);
5555
case "EVALUATE_EXPRESSION":
56-
return updateItemInList(state, ["expressions"], action.input, {
56+
return updateExpressionInList(state, action.input, {
5757
input: action.input,
5858
value: action.value,
5959
updating: false
@@ -79,7 +79,7 @@ function travelTo(state, action) {
7979
}
8080
return expressions.reduce(
8181
(finalState, previousState) =>
82-
updateItemInList(finalState, ["expressions"], previousState.input, {
82+
updateExpressionInList(finalState, previousState.input, {
8383
input: previousState.input,
8484
value: previousState.value,
8585
updating: false
@@ -96,38 +96,32 @@ function restoreExpressions() {
9696
return exprs;
9797
}
9898

99-
function storeExpressions(state) {
100-
const expressions = state
101-
.getIn(["expressions"])
99+
function storeExpressions({ expressions }) {
100+
prefs.expressions = expressions
102101
.map(expression => omit(expression, "value"))
103102
.toJS();
104-
105-
prefs.expressions = expressions;
106103
}
107104

108-
function appendToList(
109-
state: Record<ExpressionState>,
110-
path: string[],
111-
value: any
112-
) {
113-
const newState = state.updateIn(path, () => {
114-
return state.getIn(path).push(value);
105+
function appendExpressionToList(state: Record<ExpressionState>, value: any) {
106+
const newState = state.update("expressions", () => {
107+
return state.expressions.push(value);
115108
});
109+
116110
storeExpressions(newState);
117111
return newState;
118112
}
119113

120-
function updateItemInList(
114+
function updateExpressionInList(
121115
state: Record<ExpressionState>,
122-
path: string[],
123116
key: string,
124117
value: any
125118
) {
126-
const newState = state.updateIn(path, () => {
127-
const list = state.getIn(path);
119+
const newState = state.update("expressions", () => {
120+
const list = state.expressions;
128121
const index = list.findIndex(e => e.input == key);
129122
return list.update(index, () => value);
130123
});
124+
131125
storeExpressions(newState);
132126
return newState;
133127
}
@@ -147,7 +141,7 @@ const getExpressionsWrapper = state => state.expressions;
147141

148142
export const getExpressions = createSelector(
149143
getExpressionsWrapper,
150-
expressions => expressions.get("expressions")
144+
expressions => expressions.expressions
151145
);
152146

153147
export function getExpression(state: OuterState, input: string) {
@@ -156,7 +150,7 @@ export function getExpression(state: OuterState, input: string) {
156150

157151
export const getExpressionError = createSelector(
158152
getExpressionsWrapper,
159-
expressions => expressions.get("expressionError")
153+
expressions => expressions.expressionError
160154
);
161155

162156
export default update;

src/reducers/file-search.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function update(
7070
}
7171

7272
case "TOGGLE_FILE_SEARCH_MODIFIER": {
73-
const actionVal = !state.getIn(["modifiers", action.modifier]);
73+
const actionVal = !state.modifiers[action.modifier];
7474

7575
if (action.modifier == "caseSensitive") {
7676
prefs.fileSearchCaseSensitive = actionVal;
@@ -98,15 +98,15 @@ function update(
9898
type OuterState = { fileSearch: Record<FileSearchState> };
9999

100100
export function getFileSearchQuery(state: OuterState): string {
101-
return state.fileSearch.get("query");
101+
return state.fileSearch.query;
102102
}
103103

104104
export function getFileSearchModifiers(state: OuterState): Modifiers {
105-
return state.fileSearch.get("modifiers");
105+
return state.fileSearch.modifiers;
106106
}
107107

108108
export function getFileSearchResults(state: OuterState) {
109-
return state.fileSearch.get("searchResults");
109+
return state.fileSearch.searchResults;
110110
}
111111

112112
export default update;

src/reducers/pending-breakpoints.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ function removeBreakpoint(state, action) {
139139
const { breakpoint } = action;
140140

141141
const locationId = makePendingLocationId(breakpoint.location);
142-
const pendingBp = state.getIn(["pendingBreakpoints", locationId]);
142+
const pendingBp = state.pendingBreakpoints.get(locationId);
143143

144144
if (!pendingBp && action.status == "start") {
145145
return state.set("pendingBreakpoints", I.Map());

src/reducers/sources.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ function updateSource(state: Record<SourcesState>, source: Source | Object) {
192192
return state;
193193
}
194194

195-
const existingSource = state.getIn(["sources", source.id]);
195+
const existingSource = state.sources.get(source.id);
196196

197197
if (existingSource) {
198198
const updatedSource = existingSource.merge(source);

0 commit comments

Comments
 (0)