Skip to content

Commit 2ec3355

Browse files
committed
address copilot review feedback
1 parent 7681239 commit 2ec3355

6 files changed

Lines changed: 19 additions & 16 deletions

File tree

e2e/chat.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ test("chat loads the seeded thread and composer for a signed-in donor", async ({
88
email: DONOR_EMAIL,
99
redirectTo: `/chats/${SEEDED_THREAD_ID}`,
1010
});
11-
await page.waitForTimeout(1_000);
1211

1312
await expect(page).toHaveURL(new RegExp(`/chats/${SEEDED_THREAD_ID}$`));
1413
await expect(page.getByTestId("chat-window")).toBeVisible();

e2e/profile.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ test("profile account actions show pending feedback and update the read view", a
66
}) => {
77
await signIn(page, { email: HOST_EMAIL, redirectTo: "/profile" });
88
await delayProfileActionRequests(page);
9-
await page.waitForTimeout(3_000);
9+
10+
const profileAccountSettings = page.getByTestId("profile-account-settings");
11+
await expect(profileAccountSettings).toBeVisible();
12+
await expect(profileAccountSettings).toHaveAttribute("data-hydrated", "true");
1013

1114
await page.getByTestId("profile-account-first-name-edit").click();
1215
const firstNameInput = page.getByTestId("profile-account-first-name-input");

src/app/(core)/(interact)/(stretched)/chats/[[...threadId]]/page.tsx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,6 @@ export default async function ChatsPage({ params }: ChatsPageProps) {
4949
redirect("/chats");
5050
}
5151

52-
const totalUnreadMessages = typedThreads.reduce((count, thread) => {
53-
const unreadMessages =
54-
thread.chat_messages_with_senders?.filter(
55-
(message) => !message.read_at && message.sender_id !== user.id
56-
).length ?? 0;
57-
58-
return count + unreadMessages;
59-
}, 0);
60-
6152
return (
6253
<ChatPageClient
6354
user={user}

src/app/(forms)/profile/listings/new/[type]/page.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { createClient } from "@/utils/supabase/server";
22
import ListingWrite from "@/components/ListingWrite";
33
import FormHeader from "@/components/FormHeader";
4+
import { redirect } from "next/navigation";
45
import type { Metadata } from "next";
56

67
type ListingType = "residential" | "community" | "business";
@@ -49,10 +50,14 @@ export default async function NewListingFormContent({
4950
data: { user },
5051
} = await supabase.auth.getUser();
5152

53+
if (!user) {
54+
redirect(`/sign-in?redirect_to=/profile/listings/new/${type}`);
55+
}
56+
5257
const { data: profile } = await supabase
5358
.from("profiles")
5459
.select()
55-
.eq("id", user?.id ?? "")
60+
.eq("id", user.id)
5661
.single();
5762

5863
return (

src/components/AvatarUploadManager/AvatarUploadManager.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ import AvatarUploadView from "@/components/AvatarUploadView";
55
import { uploadAvatar, deleteAvatar, getAvatarUrl } from "@/utils/mediaUtils";
66
import Compressor from "compressorjs";
77
import { useTranslations } from "next-intl";
8+
import type { AvatarBucket } from "@/utils/mediaUtils";
89

910
const MAX_MB = 10;
1011
const MAX_FILE_SIZE = MAX_MB * 1024 * 1024; // 10MB in bytes
1112
const MAX_DIMENSION = 1024; // Consider going down to 512 for avatars
1213

1314
type AvatarUploadManagerProps = {
1415
initialAvatar?: string;
15-
bucket: string;
16+
bucket: AvatarBucket;
1617
entityId: string;
1718
onAvatarChange?: (filename: string) => void;
1819
inputHintShown?: boolean;

src/utils/mediaUtils.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createClient } from "@/utils/supabase/client";
22
import { getStoragePublicUrl } from "@/utils/storage";
33

4-
type AvatarBucket = string;
4+
export type AvatarBucket = "avatars" | "listing_avatars";
55

66
type ListingPhotoRecord = {
77
photos: string[] | null;
@@ -37,7 +37,9 @@ export async function uploadAvatar(
3737
.eq("id", id);
3838

3939
if (updateError) throw updateError;
40-
} else {
40+
}
41+
42+
if (bucket === "listing_avatars" && id) {
4143
const { error: updateError } = await supabase
4244
.from("listings")
4345
.update({ avatar: fileName })
@@ -65,7 +67,9 @@ export async function deleteAvatar(
6567
.eq("id", id);
6668

6769
if (updateError) throw updateError;
68-
} else {
70+
}
71+
72+
if (bucket === "listing_avatars" && id) {
6973
const { error: updateError } = await supabase
7074
.from("listings")
7175
.update({ avatar: null })

0 commit comments

Comments
 (0)