Deprecate GetCircularReplacer and make GetCircularReplacer dotnet by default. Format of the save is now incompatible with old versions.
This commit is contained in:
parent
6786417349
commit
621dc9b53f
6 changed files with 19 additions and 43 deletions
|
@ -10,11 +10,13 @@ const getCircularReplacer = () => {
|
|||
}
|
||||
|
||||
if (key === 'containers') {
|
||||
return Array.from(value.entries());
|
||||
return [...value.entries()]
|
||||
.map(([Key, Value]) => ({ Key, Value }));
|
||||
}
|
||||
|
||||
if (key === 'symbols') {
|
||||
return Array.from(value.entries());
|
||||
return [...value.entries()]
|
||||
.map(([Key, Value]) => ({ Key, Value }));
|
||||
}
|
||||
|
||||
if (key === 'linkedContainers') {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { IConfiguration } from '../../Interfaces/IConfiguration';
|
||||
import { ISetContainerListRequest } from '../../Interfaces/ISetContainerListRequest';
|
||||
import { ISetContainerListResponse } from '../../Interfaces/ISetContainerListResponse';
|
||||
import { GetCircularReplacerToDotnet } from '../../utils/saveload';
|
||||
import { GetCircularReplacer } from '../../utils/saveload';
|
||||
|
||||
/**
|
||||
* Fetch the configuration from the API
|
||||
|
@ -35,7 +35,7 @@ export async function FetchConfiguration(): Promise<IConfiguration> {
|
|||
|
||||
export async function SetContainerList(request: ISetContainerListRequest, configurationUrl?: string): Promise<ISetContainerListResponse> {
|
||||
const url = configurationUrl ?? import.meta.env.VITE_API_SET_CONTAINER_LIST_URL;
|
||||
const dataParsed = JSON.stringify(request, GetCircularReplacerToDotnet());
|
||||
const dataParsed = JSON.stringify(request, GetCircularReplacer());
|
||||
// The test library cannot use the Fetch API
|
||||
// @ts-expect-error
|
||||
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
||||
|
|
|
@ -5,7 +5,7 @@ import { MessageType } from '../../Enums/MessageType';
|
|||
import { IHistoryState } from '../../Interfaces/IHistoryState';
|
||||
import { IMessage } from '../../Interfaces/IMessage';
|
||||
import { DISABLE_API } from '../../utils/default';
|
||||
import { GetCircularReplacerToDotnet } from '../../utils/saveload';
|
||||
import { GetCircularReplacer } from '../../utils/saveload';
|
||||
import { TITLE_BAR_HEIGHT } from '../Sidebar/Sidebar';
|
||||
|
||||
interface IMessagesProps {
|
||||
|
|
|
@ -3,7 +3,7 @@ import { IHistoryState } from '../../Interfaces/IHistoryState';
|
|||
import { IGetFeedbackRequest } from '../../Interfaces/IGetFeedbackRequest';
|
||||
import { IGetFeedbackResponse } from '../../Interfaces/IGetFeedbackResponse';
|
||||
import { IMessage } from '../../Interfaces/IMessage';
|
||||
import { GetCircularReplacerToDotnet } from '../../utils/saveload';
|
||||
import { GetCircularReplacer } from '../../utils/saveload';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
||||
const myWorker = window.Worker && new Worker('workers/message_worker.js');
|
||||
|
@ -38,7 +38,7 @@ export function UseAsync(
|
|||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
ApplicationState: state
|
||||
};
|
||||
const dataParsed = JSON.stringify(request, GetCircularReplacerToDotnet());
|
||||
const dataParsed = JSON.stringify(request, GetCircularReplacer());
|
||||
fetch(import.meta.env.VITE_API_GET_FEEDBACK_URL, {
|
||||
method: 'POST',
|
||||
headers: new Headers({
|
||||
|
|
|
@ -12,7 +12,7 @@ import { Position } from '../Enums/Position';
|
|||
/// EDITOR DEFAULTS ///
|
||||
|
||||
/** Enable fast boot and disable main menu (default = false) */
|
||||
export const FAST_BOOT = true;
|
||||
export const FAST_BOOT = false;
|
||||
|
||||
/** Disable any call to the API (default = false) */
|
||||
export const DISABLE_API = false;
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { FindContainerById, MakeDFSIterator } from './itertools';
|
||||
import { IEditorState } from '../Interfaces/IEditorState';
|
||||
import { IHistoryState } from '../Interfaces/IHistoryState';
|
||||
import { IContainerModel } from '../Interfaces/IContainerModel';
|
||||
|
||||
/**
|
||||
* Revive the Editor state
|
||||
|
@ -32,7 +34,9 @@ export function ReviveState(state: IHistoryState): void {
|
|||
for (const symbol of state.symbols.values()) {
|
||||
symbol.linkedContainers = new Set(symbol.linkedContainers);
|
||||
}
|
||||
state.containers = new Map(state.containers);
|
||||
|
||||
const containers: Array<{ Key: string, Value: IContainerModel }> = (state.containers) as any;
|
||||
state.containers = new Map(containers.map(({ Key, Value }: {Key: string, Value: IContainerModel}) => [Key, Value]));
|
||||
|
||||
const root = FindContainerById(state.containers, state.mainContainer);
|
||||
|
||||
|
@ -64,43 +68,13 @@ export function GetCircularReplacer(): (key: any, value: object | Map<string, an
|
|||
}
|
||||
|
||||
if (key === 'containers') {
|
||||
return Array.from((value as Map<string, any>).entries());
|
||||
return [...(value as Map<string, any>).entries()]
|
||||
.map(([Key, Value]: [string, any]) => ({ Key, Value }));
|
||||
}
|
||||
|
||||
if (key === 'symbols') {
|
||||
return Array.from((value as Map<string, any>).entries());
|
||||
}
|
||||
|
||||
if (key === 'linkedContainers') {
|
||||
return Array.from(value as Set<string>);
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
}
|
||||
|
||||
export function GetCircularReplacerToDotnet(): (key: any, value: object | Map<string, any> | null) => object | null | undefined {
|
||||
return (key: any, value: object | null) => {
|
||||
if (key === 'parent') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (key === 'containers') {
|
||||
return [...(value as Map<string, any>).entries()].map((keyPair: [string, any]) => {
|
||||
return {
|
||||
Key: keyPair[0],
|
||||
Value: keyPair[1]
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
if (key === 'symbols') {
|
||||
return [...(value as Map<string, any>).entries()].map((keyPair: [string, any]) => {
|
||||
return {
|
||||
Key: keyPair[0],
|
||||
Value: keyPair[1]
|
||||
};
|
||||
});
|
||||
return [...(value as Map<string, any>).entries()]
|
||||
.map(([Key, Value]: [string, any]) => ({ Key, Value }));
|
||||
}
|
||||
|
||||
if (key === 'linkedContainers') {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue