Fix applicationStateModel serialization

This commit is contained in:
Eric NGUYEN 2022-10-12 16:03:03 +02:00
parent d1881ae8fa
commit aa15425dbc
5 changed files with 17 additions and 138 deletions

View file

@ -9,7 +9,7 @@ onmessage = async(e) => {
const request = {
ApplicationState: state
};
const dataParsed = JSON.stringify(request, GetCircularReplacerKeepDataStructure());
const dataParsed = JSON.stringify(request, GetCircularReplacer());
fetch(url, {
method: 'POST',
headers: new Headers({
@ -26,13 +26,25 @@ onmessage = async(e) => {
});
};
function GetCircularReplacerKeepDataStructure()
function GetCircularReplacer()
{
return (key, value) => {
if (key === 'parent') {
return;
}
if (key === 'containers') {
return Array.from(value.entries());
}
if (key === 'symbols') {
return Array.from(value.entries());
}
if (key === 'linkedContainers') {
return Array.from(value);
}
return value;
};
}