Skip to content

Commit

Permalink
fix errors?
Browse files Browse the repository at this point in the history
  • Loading branch information
bwmp committed Jun 21, 2024
1 parent 92641ba commit 43ee7af
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"qwik-speak": "^0.23.0",
"tailwindcss": "^3.4.4",
"typescript": "5.4.5",
"undici": "^6.19.0",
"undici": "^6.19.2",
"vite": "5.3.0",
"vite-tsconfig-paths": "4.3.2",
"wrangler": "latest",
Expand Down
13 changes: 9 additions & 4 deletions src/components/util/SharedUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@ import { defaults, loadPreset } from './PresetUtils';

type names = 'rgb' | 'animtab' | 'parsed' | 'animpreview';

function deepclone(obj: any) {
return JSON.parse(JSON.stringify(obj));
}

export function getCookies(cookie: Cookie, preset: names, urlParams: URLSearchParams) {
let json = JSON.parse(cookie.get(preset)?.value || '{}');

const newrgbDefaults = deepclone(rgbDefaults);
const newanimTABDefaults = deepclone(animTABDefaults);
// migrate
let migrated = false;
if (preset == 'rgb' || preset == 'animtab') {
const names = preset == 'rgb' ? Object.keys(rgbDefaults) : Object.keys(animTABDefaults);
const names = preset == 'rgb' ? Object.keys(newrgbDefaults) : Object.keys(newanimTABDefaults);
if (preset == 'animtab') names.push('version');
names.forEach(name => {
let cookieValue = cookie.get(name)?.value;
Expand All @@ -35,7 +40,6 @@ export function getCookies(cookie: Cookie, preset: names, urlParams: URLSearchPa
});
json = loadPreset(JSON.stringify(json));
}

if (migrated) cookie.set(preset, JSON.stringify(json), { path: '/' });
return json;
}
Expand All @@ -51,8 +55,9 @@ export function setCookies(name: names, json: { [key: string]: any; }) {
if (cookie.optout === 'true') return;

const cookieValue = { ...json };
const test = deepclone(defaults);
Object.keys(cookieValue).forEach(key => {
if (key != 'version' && JSON.stringify(cookieValue[key]) === JSON.stringify(defaults[key as keyof typeof defaults])) delete cookieValue[key];
if (key != 'version' && JSON.stringify(cookieValue[key]) === JSON.stringify(test[key as keyof typeof defaults])) delete cookieValue[key];
});

const existingCookie = cookie[name];
Expand Down
2 changes: 1 addition & 1 deletion src/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default component$(() => {
useQwikSpeak({ config, translationFn });

useOnDocument('load', $(() => {
let platform = navigator.platform || 'unknown';
const platform = navigator.platform || 'unknown';
if (platform.toUpperCase().indexOf('MAC') >= 0) {
document.querySelectorAll('.scale-for-mac').forEach(function(element) {
element.classList.add('macos-zoom-fix');
Expand Down
2 changes: 1 addition & 1 deletion src/routes/api/v2/docs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export const useEndpoints = routeLoader$(async ({ url }) => {

export default component$(() => {
const { endpoints } = useEndpoints().value;

return <>
<section class="flex flex-col gap-3 mx-auto max-w-7xl px-6 py-16 min-h-svh">
<div>
Expand Down Expand Up @@ -107,6 +106,7 @@ export default component$(() => {
<p class="text-gray-500">example: {v3formats.find(format => format.color == 'MiniMessage')?.strikethrough}</p>
</div>
</Card>
<br/>
<Card>
<Header id="color" anchor>
Color
Expand Down
1 change: 0 additions & 1 deletion src/routes/api/v2/rgb/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export const onGet: RequestHandler = async ({ json, query }) => {
else if (queryjson[key] == 'false') queryjson[key] = false;
else if (queryjson[key].startsWith('{') && queryjson[key].endsWith('}')) queryjson[key] = JSON.parse(queryjson[key]);
}

output = await getOutput(queryjson);
}
catch (e: any) {
Expand Down

0 comments on commit 43ee7af

Please sign in to comment.