Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 29 additions & 5 deletions components/waves/ChatItemHrefButtons.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
"use client";

import Link from "next/link";
import { useState } from "react";
import {
useState,
type MouseEvent,
type PointerEvent,
type TouchEvent,
} from "react";

type StopEvent =
| MouseEvent<HTMLElement>
| PointerEvent<HTMLElement>
| TouchEvent<HTMLElement>;

const stopPropagation = (event: StopEvent) => {
event.stopPropagation();
event.nativeEvent.stopImmediatePropagation?.();
};

export default function ChatItemHrefButtons({
href,
Expand All @@ -14,7 +29,8 @@ export default function ChatItemHrefButtons({
}) {
const [copied, setCopied] = useState(false);

const copyToClipboard = () => {
const copyToClipboard = (event: MouseEvent<HTMLButtonElement>) => {
stopPropagation(event);
navigator.clipboard.writeText(href).then(() => {
setCopied(true);
setTimeout(() => setCopied(false), 500);
Expand All @@ -24,8 +40,12 @@ export default function ChatItemHrefButtons({
return (
<div className="tw-mt-1 tw-h-full tw-flex tw-flex-col tw-gap-y-2 tw-justify-start">
<button
type="button"
className={`tw-border-0 tw-flex tw-items-center tw-gap-x-2 tw-p-2 tw-bg-iron-900 tw-rounded-xl hover:tw-text-iron-400`}
onClick={copyToClipboard}>
onClick={copyToClipboard}
onPointerDown={stopPropagation}
onMouseDown={stopPropagation}
onTouchStart={stopPropagation}>
<svg
className={`tw-flex-shrink-0 tw-w-4 tw-h-4 tw-transition tw-ease-out tw-duration-300`}
xmlns="http://www.w3.org/2000/svg"
Expand All @@ -44,7 +64,11 @@ export default function ChatItemHrefButtons({
<Link
href={relativeHref ?? href}
target={relativeHref ? undefined : "_blank"}
className={`tw-border-0 tw-flex tw-items-center tw-gap-x-2 tw-p-2 tw-bg-iron-900 tw-rounded-xl`}>
className={`tw-border-0 tw-flex tw-items-center tw-gap-x-2 tw-p-2 tw-bg-iron-900 tw-rounded-xl`}
onClick={stopPropagation}
onPointerDown={stopPropagation}
onMouseDown={stopPropagation}
onTouchStart={stopPropagation}>
<svg
className={`tw-flex-shrink-0 tw-w-4 tw-h-4 tw-transition tw-ease-out tw-duration-300`}
viewBox="0 0 64 64"
Expand All @@ -67,4 +91,4 @@ export default function ChatItemHrefButtons({
)}
</div>
);
}
}
7 changes: 7 additions & 0 deletions helpers/SeizeLinkParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ export function parseSeizeQuoteLink(href: string): SeizeQuoteLinkInfo | null {
return null;
}

// If the URL has a drop parameter, it should be handled by the drop handler
// instead of the quote handler to prevent recursion when ensureStableSeizeLink
// combines the current page's serialNo with a drop preview link
if (url.searchParams.has("drop")) {
return null;
}

const waveId = sanitizeQueryValue(url.searchParams.get("wave"));

if (
Expand Down