Fix json selected container by saving its id
This commit is contained in:
parent
7b704fa33d
commit
f524e8f7b9
2 changed files with 42 additions and 25 deletions
13
src/App.tsx
13
src/App.tsx
|
@ -9,6 +9,7 @@ import { Configuration } from './Interfaces/Configuration';
|
|||
export interface IHistoryState {
|
||||
MainContainer: IContainerModel | null,
|
||||
SelectedContainer: IContainerModel | null,
|
||||
SelectedContainerId: string,
|
||||
TypeCounters: Record<string, number>
|
||||
}
|
||||
|
||||
|
@ -157,12 +158,11 @@ export async function fetchConfiguration(): Promise<Configuration> {
|
|||
function Revive(editorState: IEditorState): void {
|
||||
const history = editorState.history;
|
||||
for (const state of history) {
|
||||
if (state.MainContainer === null) {
|
||||
if (state.MainContainer === null || state.MainContainer === undefined) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const it = MakeIterator(state.MainContainer);
|
||||
state.SelectedContainer = state.MainContainer;
|
||||
for (const container of it) {
|
||||
const parentId = container.properties.parentId;
|
||||
if (parentId === null) {
|
||||
|
@ -175,5 +175,12 @@ function Revive(editorState: IEditorState): void {
|
|||
}
|
||||
container.parent = parent;
|
||||
}
|
||||
|
||||
const selected = findContainerById(state.MainContainer, state.SelectedContainerId);
|
||||
if (selected === undefined) {
|
||||
state.SelectedContainer = null;
|
||||
continue;
|
||||
}
|
||||
state.SelectedContainer = selected;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue