Skip to content

Commit

Permalink
absolutely just NUKE broken cookies
Browse files Browse the repository at this point in the history
  • Loading branch information
bwmp committed Jun 29, 2024
1 parent ce0c840 commit 57c24a0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/components/util/SharedUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ function deepclone(obj: any) {
}

export function getCookies(cookie: Cookie, preset: names, urlParams: URLSearchParams) {
let json = JSON.parse(cookie.get(preset)?.value || '{}');
let json = deepclone(defaults);
try {
json = JSON.parse(cookie.get(preset)?.value || '{}');
} catch (e) {
console.error(e);
}
const newrgbDefaults = deepclone(rgbDefaults);
const newanimTABDefaults = deepclone(animTABDefaults);
// migrate
Expand All @@ -26,7 +31,7 @@ export function getCookies(cookie: Cookie, preset: names, urlParams: URLSearchPa
console.log('Migrating', name);
try {
if (name == 'colors') json[name] = cookieValue.split(',');
else if (name == 'format' ) json[name] = JSON.parse(cookieValue);
else if (name == 'format') json[name] = JSON.parse(cookieValue);
else if (cookieValue === 'true' || cookieValue === 'false') json[name] = cookieValue === 'true';
else if (!isNaN(Number(cookieValue))) json[name] = Number(cookieValue);
else json[name] = cookieValue;
Expand Down

0 comments on commit 57c24a0

Please sign in to comment.