Skip to content

Commit

Permalink
Fixed a bug where the webapp would error out in case there were no pr…
Browse files Browse the repository at this point in the history
…evious tasks and the user tried to add one
  • Loading branch information
SteveGremory committed Aug 28, 2023
1 parent 8dc3248 commit 04aeba0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,17 @@ export default function Home() {
onClose={() => {
if (itemType === "task")
setTasks((prevTasks) => {
currentItem.key = prevTasks.at(-1)!.key + 1;
currentItem.key = prevTasks.at(-1)
? prevTasks.at(-1)!.key + 1
: 0;
prevTasks.push(currentItem);
return prevTasks;
});
else
setNotes((prevTasks) => {
currentItem.key = prevTasks.at(-1)!.key + 1;
currentItem.key = prevTasks.at(-1)
? prevTasks.at(-1)!.key + 1
: 0;
prevTasks.push(currentItem);
return prevTasks;
});
Expand Down

0 comments on commit 04aeba0

Please sign in to comment.