зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1547115 - Memoize breakableLines to avoid resetting in editor often. r=jlast
Differential Revision: https://phabricator.services.mozilla.com/D29245 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
3ba7bef4b0
Коммит
9d48e224c0
|
@ -6,7 +6,7 @@
|
|||
|
||||
import { connect } from "../../utils/connect";
|
||||
import { Component } from "react";
|
||||
import { getSelectedSource, getBreakableLines } from "../../selectors";
|
||||
import { getSelectedSource, getSelectedBreakableLines } from "../../selectors";
|
||||
import type { Source } from "../../types";
|
||||
import { fromEditorLine } from "../../utils/editor";
|
||||
|
||||
|
@ -64,9 +64,7 @@ const mapStateToProps = state => {
|
|||
if (!selectedSource) {
|
||||
throw new Error("no selectedSource");
|
||||
}
|
||||
const breakableLines = new Set(
|
||||
getBreakableLines(state, selectedSource.id) || []
|
||||
);
|
||||
const breakableLines = getSelectedBreakableLines(state);
|
||||
|
||||
return {
|
||||
selectedSource,
|
||||
|
|
|
@ -881,4 +881,12 @@ export function getBreakableLines(state: OuterState, sourceId: string) {
|
|||
return state.sources.breakableLines[sourceId];
|
||||
}
|
||||
|
||||
export const getSelectedBreakableLines: Selector<Set<number>> = createSelector(
|
||||
state => {
|
||||
const sourceId = getSelectedSourceId(state);
|
||||
return sourceId && state.sources.breakableLines[sourceId];
|
||||
},
|
||||
breakableLines => new Set(breakableLines || [])
|
||||
);
|
||||
|
||||
export default update;
|
||||
|
|
Загрузка…
Ссылка в новой задаче