You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 11, 2023. It is now read-only.
Currently we have two source fields that are very similar (Sources, RelativeSources). The reason for this is that we want to support project directory roots where we will only show sources below a directory.
We should refactor the redux store so that we do not need to copy the data though.
Here is a quick sketch:
diff --git a/src/reducers/sources.js b/src/reducers/sources.js
index ac6878aec..3317e7624 100644
--- a/src/reducers/sources.js+++ b/src/reducers/sources.js@@ -36,7 +36,7 @@ import type { LoadSourceAction } from "../actions/types/SourceAction";
import { omitBy, mapValues } from "lodash";
export type SourcesMap = { [SourceId]: Source };
-export type SourcesMapByThread = { [ThreadId]: SourcesMap };+export type RelativeSources = { [ThreadId]: SourceId[] };
type SourceActorsMap = { [SourceId]: SourceActor[] };
type UrlsMap = { [string]: SourceId[] };
@@ -58,7 +58,7 @@ export type SourcesState = {
// For each thread, all sources in that thread that are under the project root
// and should be shown in the editor's sources pane.
- relativeSources: SourcesMapByThread,+ relativeSources: RelativeSources,
pendingSelectedLocation?: PendingSelectedLocation,
selectedLocation: ?SourceLocation,
@@ -274,6 +274,11 @@ function updateSource(state: SourcesState, source: Object) {
? { ...existingSource, ...source }
: createSource(source);
+ updatedSource.relativeUrl = getRelativeUrl(+ source,+ state.projectDirectoryRoot+ );+
state.sources[source.id] = updatedSource;
updateSourceUrl(state, source);
@@ -285,21 +290,15 @@ function updateRelativeSource(
source: Object,
sourceActor: SourceActor
) {
- const root = state.projectDirectoryRoot;-- if (!underRoot(source, root)) {+ if (!underRoot(source, state.projectDirectoryRoot)) {
return;
}
- const relativeSource: Source = ({- ...source,- relativeUrl: getRelativeUrl(source, root)- }: any);-
if (!state.relativeSources[sourceActor.thread]) {
- state.relativeSources[sourceActor.thread] = {};+ state.relativeSources[sourceActor.thread] = [];
}
- state.relativeSources[sourceActor.thread][source.id] = relativeSource;++ state.relativeSources[sourceActor.thread].push(source.id);
}
Currently we have two source fields that are very similar (Sources, RelativeSources). The reason for this is that we want to support project directory roots where we will only show sources below a directory.
We should refactor the redux store so that we do not need to copy the data though.
Here is a quick sketch: