Skip to content

Commit

Permalink
fix: resolve invalid selector for saving image (#222)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshxfi committed Jul 17, 2024
1 parent 043ae47 commit ee48ff9
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
4 changes: 2 additions & 2 deletions apps/www/src/app/(profile)/inbox/components/received/card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ export function ReceivedMessageCard({

const isDeleted = useMemo(
() => deletedMessages.includes(msg.id),
[deletedMessages, msg.id],
[deletedMessages, msg.id]
);

return (
<div id={msg.id} className="container">
<div id={`umamin-${msg.id}`} className="container">
<Card
className={cn("min-w-2 w-full group relative", {
"opacity-50": isDeleted,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export function ReceivedMessageMenu(props: ReceivedMenuProps) {
{
title: "Save Image",
onClick: () => {
onSaveImage(id);
onSaveImage(`umamin-${id}`);
logEvent(analytics, "save_image_message");
},
},
Expand Down
6 changes: 3 additions & 3 deletions apps/www/src/app/notes/components/card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function NoteCard({ note, menuItems, currentUserId }: Props) {
const [open, setOpen] = useState(false);

return (
<div id={note.id} className="container">
<div id={`umamin-${note.id}`} className="container">
<ReplyDrawer
open={open}
setOpen={setOpen}
Expand Down Expand Up @@ -80,7 +80,7 @@ export function NoteCard({ note, menuItems, currentUserId }: Props) {
</span>
{username &&
process.env.NEXT_PUBLIC_VERIFIED_USERS?.split(
",",
","
).includes(username) && (
<BadgeCheck className="w-4 h-4 text-pink-500" />
)}
Expand Down Expand Up @@ -115,7 +115,7 @@ export function NoteCard({ note, menuItems, currentUserId }: Props) {
title: "Save Image",
onClick: () => {
if (note.id) {
onSaveImage(note.id);
onSaveImage(`umamin-${note.id}`);
logEvent(analytics, "save_image_note");
}
},
Expand Down
6 changes: 3 additions & 3 deletions apps/www/src/app/notes/components/display-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function NoteCard({ note, user, menuItems, currentUserId }: Props) {
const username = user?.username;

return (
<div id={note.id} className="container">
<div id={`umamin-${note.id}`} className="container">
<Card className="flex flex-col items-start justify-between">
<CardHeader className="w-full pb-4 text-sm">
<div className="flex justify-between items-start">
Expand Down Expand Up @@ -76,7 +76,7 @@ export function NoteCard({ note, user, menuItems, currentUserId }: Props) {
</span>
{username &&
process.env.NEXT_PUBLIC_VERIFIED_USERS?.split(
",",
","
).includes(username) && (
<BadgeCheck className="w-4 h-4 text-pink-500" />
)}
Expand Down Expand Up @@ -111,7 +111,7 @@ export function NoteCard({ note, user, menuItems, currentUserId }: Props) {
title: "Save Image",
onClick: () => {
if (note.id) {
onSaveImage(note.id);
onSaveImage(`umamin-${note.id}`);
logEvent(analytics, "save_image_note");
}
},
Expand Down
5 changes: 2 additions & 3 deletions apps/www/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const onSaveImage = (id: string) => {
})
.then((dataUrl) => {
const link = document.createElement("a");
link.download = `umamin-${id}.png`;
link.download = `${id}.png`;
link.href = dataUrl;
link.click();
})
Expand All @@ -34,7 +34,7 @@ export const onSaveImage = (id: string) => {
loading: "Saving...",
success: "Download ready",
error: "An error occured!",
},
}
);
};

Expand All @@ -59,7 +59,6 @@ export function shortTimeAgo(epoch: number) {
return `${hoursMatch[1]}h`;
}


const daysMatch = distance.match(/(\d+)\s+day/);
if (daysMatch) {
return `${daysMatch[1]}d`;
Expand Down

0 comments on commit ee48ff9

Please sign in to comment.