Skip to content

Commit

Permalink
Merge pull request #615 from amelioro/fix-can-save-view-with-no-order
Browse files Browse the repository at this point in the history
fix: can save view with no order
  • Loading branch information
keyserj authored Dec 19, 2024
2 parents f2701b0 + dc1d897 commit 8f7925c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/common/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const savedViewSchema = z.object({
"Title may only contain alphanumeric characters, spaces, and dashes, and cannot begin or end with a space or dash.",
)
.optional(),
order: z.number().optional(),
order: z.number().safe().optional(),
viewState: z.object({}).passthrough(), // TODO: extract view options from web/ so we can have type safety here
});

Expand Down
3 changes: 2 additions & 1 deletion src/web/view/quickViewStore/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ export const createView = () => {
id: newViewId,
type: "quick",
title: newTitle,
order: Math.max(...state.views.map((view) => view.order)) + 1,
// provide -1 by default to `Math.max` because otherwise it returns -Infinity with no arguments
order: Math.max(-1, ...state.views.map((view) => view.order)) + 1,
viewState: currentView,
};

Expand Down

0 comments on commit 8f7925c

Please sign in to comment.