Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
guicurcio committed Nov 27, 2023
1 parent 070f6a0 commit d00fb17
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 33 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"@tanstack/react-table": "^8.9.1",
"@tremor/react": "^3.6.6",
"@types/jsonwebtoken": "^9.0.5",
"@uidotdev/usehooks": "^2.4.1",
"@vercel/analytics": "^1.0.1",
"@vercel/og": "^0.0.21",
"@vercel/postgres": "^0.5.1",
Expand Down
14 changes: 14 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 45 additions & 33 deletions src/components/home/ContentInteraction/ContentInteraction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import mergeClasses from "utils/mergeClasses";
import { nhost } from "lib/setupBackendConfig";
import useSWR from "swr";
// eslint-disable-next-line no-restricted-imports
import triggerInteraction from "../../../../utils/triggerInteraction";
import { isArray } from "@apollo/client/utilities";
import { useLongPress } from "@uidotdev/usehooks";
import { useState } from "react";
/**
* Props for the ContentInteraction component.
*/
Expand Down Expand Up @@ -92,7 +92,18 @@ export default function ContentInteraction({
const user = nhost.auth.getUser();

const [isToggled] = useToggle(false);

const [isOpen, setIsOpen] = useState(false);
const attrs = useLongPress(
() => {
setIsOpen(true);
},
{
onStart: (event) => console.log("Press started"),
onFinish: (event) => console.log("Press Finished"),
onCancel: (event) => console.log("Press cancelled"),
threshold: 500,
},
);
return (
<div>
<Tooltip>
Expand All @@ -104,30 +115,31 @@ export default function ContentInteraction({
)}
variant="subtle"
size="none"
onClick={async () => {
try {
const res = await fetch(
"http://localhost:8080/api/rest/insertlike/",
{
headers: {
Authorization: `Bearer ${accessToken}`,
},
{...attrs}
// onClick={async () => {
// try {
// const res = await fetch(
// "http://localhost:8080/api/rest/insertlike/",
// {
// headers: {
// Authorization: `Bearer ${accessToken}`,
// },

body: JSON.stringify({
object: {
podcast_id: podcastID,
user_id: user.id,
},
}),
method: "POST",
},
);
triggerInteraction("The Joe Rogan Podcast", "tracklist");
return res.json();
} catch (err) {
console.log(err);
}
}}
// body: JSON.stringify({
// object: {
// podcast_id: podcastID,
// user_id: user.id,
// },
// }),
// method: "POST",
// },
// );
// triggerInteraction("The Joe Rogan Podcast", "tracklist");
// return res.json();
// } catch (err) {
// console.log(err);
// }
// }}
>
{Icon && (
<Icon
Expand All @@ -143,11 +155,11 @@ export default function ContentInteraction({
className={mergeClasses(
iconClasses,
"h-4 w-4 text-white/40 transition-colors duration-1000 ease-in-out hover:text-white/70",
isArray(followingPodcasts?.data) &&
followingPodcasts?.data
.map((follow) => follow.id)
.includes(podcastID) &&
"scale-150 fill-white brightness-[140%]",
// isArray(followingPodcasts?.data) &&
// followingPodcasts?.data
// .map((follow) => follow.id)
// .includes(podcastID) &&
isOpen && "fill-white/70 brightness-[120%]",
)}
></Heart>
)}
Expand All @@ -156,7 +168,7 @@ export default function ContentInteraction({
className={mergeClasses(
iconClasses,
"h-4 w-4 text-white/40 transition-colors duration-1000 ease-in-out hover:text-white/70",
isToggled && "fill-white/60 brightness-[100%]",
isOpen && "fill-white/70 brightness-[120%]",
)}
></BellPlus>
)}
Expand All @@ -165,7 +177,7 @@ export default function ContentInteraction({
className={mergeClasses(
iconClasses,
"h-4 w-4 text-white/40 transition-colors duration-1000 ease-in-out hover:text-white/70",
isToggled && "fill-white/60 brightness-[100%]",
isOpen && "fill-white/70 brightness-[120%]",
)}
></MessageCircle>
)}
Expand Down

1 comment on commit d00fb17

@vercel
Copy link

@vercel vercel bot commented on d00fb17 Nov 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.