-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add warning if user is creating scratch with the same name as an exis… #1426
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,15 +2,18 @@ | |
|
||
import { type ReactNode, useState } from "react"; | ||
|
||
import Image from "next/image"; | ||
import Link from "next/link"; | ||
|
||
import classNames from "classnames"; | ||
|
||
import TimeAgo from "@/components/TimeAgo"; | ||
import * as api from "@/lib/api"; | ||
import { presetUrl, scratchUrl } from "@/lib/api/urls"; | ||
import { presetUrl, scratchUrl, userAvatarUrl } from "@/lib/api/urls"; | ||
|
||
import getTranslation from "@/lib/i18n/translate"; | ||
|
||
import AnonymousFrogAvatar from "./user/AnonymousFrog"; | ||
import AsyncButton from "./AsyncButton"; | ||
import Button from "./Button"; | ||
import LoadingSpinner from "./loading.svg"; | ||
|
@@ -281,9 +284,34 @@ export function ScratchItemPresetList({ | |
); | ||
} | ||
|
||
export function ScratchOwnerAvatar({ scratch }: { scratch: api.TerseScratch }) { | ||
return ( | ||
scratch.owner && | ||
(!api.isAnonUser(scratch.owner) ? ( | ||
userAvatarUrl(scratch.owner) && ( | ||
Comment on lines
+288
to
+291
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could be more clearly written without ternaries: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just lifted this code verbatim from the Search code, but yeh that makes sense There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't appease the linter so gonna leave this as-is. |
||
<Image | ||
src={userAvatarUrl(scratch.owner)} | ||
alt={scratch.owner.username} | ||
width={16} | ||
height={16} | ||
className={styles.scratchOwnerAvatar} | ||
/> | ||
) | ||
) : ( | ||
<AnonymousFrogAvatar | ||
user={scratch.owner} | ||
width={16} | ||
height={16} | ||
className={styles.scratchOwnerAvatar} | ||
/> | ||
)) | ||
); | ||
} | ||
|
||
export function SingleLineScratchItem({ | ||
scratch, | ||
}: { scratch: api.TerseScratch }) { | ||
showOwner = false, | ||
}: { scratch: api.TerseScratch; showOwner?: boolean }) { | ||
const matchPercentString = getMatchPercentString(scratch); | ||
|
||
return ( | ||
|
@@ -296,6 +324,7 @@ export function SingleLineScratchItem({ | |
{scratch.name} | ||
</Link> | ||
<div className={styles.metadata}>{matchPercentString}</div> | ||
{showOwner && <ScratchOwnerAvatar scratch={scratch} />} | ||
</li> | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably use tailwind instead given #1394