mirror of
https://github.com/gabehf/Koito.git
synced 2026-03-16 02:45:54 -07:00
fix: hide delete listen button when not logged in
This commit is contained in:
parent
ef064cd9bd
commit
5a8b999f73
2 changed files with 9 additions and 2 deletions
|
|
@ -4,6 +4,7 @@ import { deleteListen, type Listen, type PaginatedResponse } from "api/api";
|
|||
import { timeSince } from "~/utils/utils";
|
||||
import ArtistLinks from "~/components/ArtistLinks";
|
||||
import { useState } from "react";
|
||||
import { useAppContext } from "~/providers/AppProvider";
|
||||
|
||||
export async function clientLoader({ request }: LoaderFunctionArgs) {
|
||||
const url = new URL(request.url);
|
||||
|
|
@ -25,6 +26,7 @@ export default function Listens() {
|
|||
const { listens: initialData } = useLoaderData<{ listens: PaginatedResponse<Listen> }>();
|
||||
|
||||
const [items, setItems] = useState<Listen[] | null>(null)
|
||||
const { user } = useAppContext()
|
||||
|
||||
const handleDelete = async (listen: Listen) => {
|
||||
if (!initialData) return
|
||||
|
|
@ -61,11 +63,12 @@ export default function Listens() {
|
|||
<tbody>
|
||||
{listens.map((item) => (
|
||||
<tr key={`last_listen_${item.time}`} className="group hover:bg-[--color-bg-secondary]">
|
||||
<td className="w-[1px] pr-2 align-middle">
|
||||
<td className="w-[17px] pr-2 align-middle">
|
||||
<button
|
||||
onClick={() => handleDelete(item)}
|
||||
className="opacity-0 group-hover:opacity-100 transition-opacity text-(--color-fg-tertiary) hover:text-(--color-error)"
|
||||
aria-label="Delete"
|
||||
hidden={user === null || user === undefined}
|
||||
>
|
||||
×
|
||||
</button>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue