Skip to content

Commit

Permalink
fix pages breaking when no preset cookie is present
Browse files Browse the repository at this point in the history
  • Loading branch information
bwmp committed Dec 26, 2024
1 parent 1472bf1 commit ee6c654
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/components/util/PresetUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ export interface format {
strikethrough?: string;
}

export const defaultPresets = {
savedPresets: [],
}

export const presets = [
{
version: 4,
Expand Down
4 changes: 3 additions & 1 deletion src/components/util/SharedUtils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Cookie } from '@builder.io/qwik-city';
import { rgbDefaults } from '~/routes/resources/rgb';
import { animTABDefaults } from '~/routes/resources/animtab';
import { defaults, loadPreset } from './PresetUtils';
import { defaults, loadPreset, defaultPresets } from './PresetUtils';

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

Expand All @@ -17,6 +17,8 @@ export function getCookies(cookie: Cookie, preset: names, urlParams?: URLSearchP
json = JSON.parse(decodeURIComponent(cookieVal)); // Decode the cookie value
} else if (preset == 'rgb' || preset == 'animtab') {
json = preset == 'rgb' ? deepclone(rgbDefaults) : deepclone(animTABDefaults);
} else if (preset == 'presets') {
json = deepclone(defaultPresets);
} else {
json = {};
}
Expand Down

0 comments on commit ee6c654

Please sign in to comment.