Skip to content

Commit

Permalink
idk try fixing guestbook
Browse files Browse the repository at this point in the history
  • Loading branch information
spencerc99 committed Aug 16, 2024
1 parent 7e1d050 commit 07eca32
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions website/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ import { playhtml } from "../packages/playhtml/src/main";
import confetti from "canvas-confetti";

interface FormData {
id: string;
name: string;
message: string;
timestamp: number;
}

function getFormDataId(formData: FormData) {
return `${formData.name}-${formData.timestamp}`;
}

playhtml.init({
events: {
confetti: {
Expand All @@ -38,7 +41,7 @@ playhtml.init({
setLocalData,
}) => {
const entriesToAdd = entries.filter(
(entry) => !addedEntries.has(entry.id)
(entry) => !addedEntries.has(getFormDataId(entry))
);

const guestbookDiv = document.getElementById("guestbookMessages")!;
Expand Down Expand Up @@ -83,7 +86,7 @@ playhtml.init({
newEntry.querySelector(".guestbook-entry-message")!.innerText =
entry.message;
}
addedEntries.add(entry.id);
addedEntries.add(getFormDataId(entry));
});

setLocalData({ addedEntries });
Expand Down Expand Up @@ -135,7 +138,6 @@ playhtml.init({
message: "something",
...inputData,
timestamp,
id: `${timestamp}-${inputData.name}`,
};
setData([...entries, newEntry]);
clearMessage();
Expand Down

0 comments on commit 07eca32

Please sign in to comment.