Fix json selected container by saving its id
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing

This commit is contained in:
Siklos 2022-08-04 19:30:48 +02:00
parent 7b704fa33d
commit f524e8f7b9
2 changed files with 42 additions and 25 deletions

View file

@ -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;
}
}
}