Skip to content

Commit

Permalink
Migrate to Lens v3
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoginth committed Dec 9, 2024
1 parent 0d0ad14 commit 8ff497e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 39 deletions.
23 changes: 0 additions & 23 deletions apps/web/src/components/Shared/Markup/MarkupLink/Group.tsx

This file was deleted.

30 changes: 19 additions & 11 deletions apps/web/src/components/Shared/Markup/MarkupLink/Mention.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Link from "next/link";
import type { FC } from "react";

const Mention: FC<MarkupLinkProps> = ({ mentions, title }) => {
const handle = title?.slice(1);
const handle = title;

if (!handle) {
return null;
Expand All @@ -26,29 +26,37 @@ const Mention: FC<MarkupLinkProps> = ({ mentions, title }) => {
return Boolean(foundMention?.account);
};

const getLocalNameFromFullHandle = (handle: string) => {
const getNameFromMention = (handle: string): string => {
const foundMention = mentions?.find(
(mention) => mention.replace.from === handle
);
return foundMention?.replace.from;

return foundMention?.replace.from.split("/")[1] || "";
};

const getAddressFromMention = (handle: string): string => {
const foundMention = mentions?.find(
(mention) => mention.replace.from === handle
);

return foundMention?.account;
};

return canShowUserPreview(handle) ? (
<Link
className="outline-none focus:underline"
href={`/u/${getLocalNameFromFullHandle(handle)}`}
href={`/u/${getNameFromMention(handle)}`}
onClick={stopEventPropagation}
>
<AccountPreview handle={handle}>
<Slug
prefix="@"
slug={getLocalNameFromFullHandle(handle)}
useBrandColor
/>
<AccountPreview
handle={getNameFromMention(handle)}
address={getAddressFromMention(handle)}
>
<Slug prefix="@" slug={getNameFromMention(handle)} useBrandColor />
</AccountPreview>
</Link>
) : (
<Slug prefix="@" slug={getLocalNameFromFullHandle(handle)} useBrandColor />
<Slug prefix="@" slug={getNameFromMention(handle)} useBrandColor />
);
};

Expand Down
5 changes: 0 additions & 5 deletions apps/web/src/components/Shared/Markup/MarkupLink/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { MarkupLinkProps } from "@hey/types/misc";
import Cashtag from "./Cashtag";
import ExternalLink from "./ExternalLink";
import Group from "./Group";
import Hashtag from "./Hashtag";
import Mention from "./Mention";

Expand All @@ -11,10 +10,6 @@ const MarkupLink = ({ mentions, title }: MarkupLinkProps) => {
}

if (title.startsWith("@")) {
if (title.startsWith("@club/")) {
return <Group title={title} />;
}

return <Mention mentions={mentions} title={title} />;
}

Expand Down

0 comments on commit 8ff497e

Please sign in to comment.