Skip to content

Commit

Permalink
handle disappearing presets
Browse files Browse the repository at this point in the history
  • Loading branch information
relsqui committed Nov 3, 2024
1 parent 720c78f commit 1d225b0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- fix filling local storage with editor tempfiles
- error handling
- confirm before deleting config pieces or resetting config
- implement uploading into the editor
Expand Down
7 changes: 5 additions & 2 deletions src/routes/Generator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ReactComponent as DieIcon } from '../static/icons/materialDie.svg';
import { ReactComponent as ExitIcon } from '../static/icons/materialExit.svg';
import { PresetDropdown } from '../components/PresetDropdown';
import { NavButton } from '../components/NavButton';
import { useLoaderData, useNavigate } from 'react-router-dom';
import { redirect, useLoaderData, useNavigate } from 'react-router-dom';
import { presetsBySlug, titleToSlug } from '../presets';
import { matchSlug } from '../matchSlug';

Expand All @@ -22,7 +22,10 @@ type TextTree = {

export async function loader({ params }: any) {
const config = presetsBySlug[params.slug] as TableConfig;
if (!config) throw Error(`Slug ${params.slug} not found.`);
if (!config) {
console.log(`Slug ${params.slug} not found.`);
return redirect("/");
}
return { config };
}

Expand Down

0 comments on commit 1d225b0

Please sign in to comment.