Skip to content

Commit efb0f60

Browse files
committed
added old comments and removed new comments
1 parent 41324c2 commit efb0f60

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

Diff for: apps/web/app/(app)/compose/ComposeEmailForm.tsx

+6-5
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export const ComposeEmailForm = ({
6666
replyToEmail: replyingToEmail,
6767
subject: replyingToEmail?.subject,
6868
to: replyingToEmail?.to,
69-
cc: replyingToEmail?.cc, // Initialize cc field
69+
cc: replyingToEmail?.cc,
7070
messageHtml: replyingToEmail?.draftHtml,
7171
},
7272
});
@@ -116,7 +116,7 @@ export const ComposeEmailForm = ({
116116
);
117117

118118
const [searchQuery, setSearchQuery] = React.useState("");
119-
const [searchQueryCc, setSearchQueryCc] = React.useState(""); // New state for CC search
119+
const [searchQueryCc, setSearchQueryCc] = React.useState("");
120120
const { data } = useSWR<ContactsResponse, { error: string }>(
121121
env.NEXT_PUBLIC_CONTACTS_ENABLED
122122
? `/api/google/contacts?query=${searchQuery}`
@@ -126,8 +126,9 @@ export const ComposeEmailForm = ({
126126
},
127127
);
128128

129+
// TODO not in love with how this was implemented
129130
const selectedEmailAddresses = watch("to", "").split(",").filter(Boolean);
130-
const selectedCcAddresses = (watch("cc") || "").split(",").filter(Boolean); // Watch CC field
131+
const selectedCcAddresses = (watch("cc") || "").split(",").filter(Boolean);
131132

132133
const onRemoveSelectedEmail = (emailAddress: string, field: "to" | "cc") => {
133134
const filteredEmailAddresses = (
@@ -136,6 +137,7 @@ export const ComposeEmailForm = ({
136137
setValue(field, filteredEmailAddresses.join(","));
137138
};
138139

140+
// this assumes last value given by combobox is user typed value
139141
const handleComboboxOnChange = (values: string[], field: "to" | "cc") => {
140142
const lastValue = values[values.length - 1];
141143

@@ -170,7 +172,7 @@ export const ComposeEmailForm = ({
170172
} catch (error) {
171173
console.error("Failed to append content:", error);
172174
toastError({ description: "Failed to show full content" });
173-
return;
175+
return; // Don't set showFullContent to true if append failed
174176
}
175177
}
176178
setShowFullContent(true);
@@ -314,7 +316,6 @@ export const ComposeEmailForm = ({
314316
</Combobox>
315317
</div>
316318

317-
{/* Add CC Combobox */}
318319
<div className="flex space-x-2">
319320
<div className="mt-2">
320321
<Label name="cc" label="CC" />

Diff for: apps/web/components/email-list/EmailMessage.tsx

+16-17
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@ export function EmailMessage({
4949
generateNudge?: boolean;
5050
}) {
5151
const [showReply, setShowReply] = useState(defaultShowReply || false);
52-
const [showReplyAll, setShowReplyAll] = useState(false); // New state for "Reply to All"
52+
const [showReplyAll, setShowReplyAll] = useState(false);
5353
const [showDetails, setShowDetails] = useState(false);
5454

5555
const onReply = useCallback(() => setShowReply(true), []);
56-
const onReplyAll = useCallback(() => setShowReplyAll(true), []); // New callback for "Reply to All"
56+
const onReplyAll = useCallback(() => setShowReplyAll(true), []);
5757
const [showForward, setShowForward] = useState(false);
5858
const onForward = useCallback(() => setShowForward(true), []);
5959

6060
const onCloseCompose = useCallback(() => {
6161
setShowReply(false);
62-
setShowReplyAll(false); // Reset "Reply to All" state
62+
setShowReplyAll(false);
6363
setShowForward(false);
6464
}, []);
6565

@@ -84,7 +84,7 @@ export function EmailMessage({
8484
toggleDetails={toggleDetails}
8585
showReplyButton={showReplyButton}
8686
onReply={onReply}
87-
onReplyAll={onReplyAll} // Pass the "Reply to All" callback
87+
onReplyAll={onReplyAll}
8888
onForward={onForward}
8989
/>
9090

@@ -107,10 +107,10 @@ export function EmailMessage({
107107
onSendSuccess={onSendSuccess}
108108
onCloseCompose={onCloseCompose}
109109
defaultShowReply={defaultShowReply}
110-
showReply={showReply || showReplyAll} // Pass the combined state
110+
showReply={showReply || showReplyAll}
111111
draftMessage={draftMessage}
112112
generateNudge={generateNudge}
113-
replyToAll={showReplyAll} // Pass the "Reply to All" state
113+
replyToAll={showReplyAll}
114114
/>
115115
)}
116116
</>
@@ -127,7 +127,7 @@ function TopBar({
127127
showReplyButton,
128128
onReply,
129129
onForward,
130-
onReplyAll, // New prop for handling "Reply to All"
130+
onReplyAll,
131131
}: {
132132
message: ParsedMessage;
133133
expanded: boolean;
@@ -136,7 +136,7 @@ function TopBar({
136136
showReplyButton: boolean;
137137
onReply: () => void;
138138
onForward: () => void;
139-
onReplyAll: () => void; // New prop for handling "Reply to All"
139+
onReplyAll: () => void;
140140
}) {
141141
return (
142142
<div className="sm:flex sm:items-center sm:justify-between">
@@ -208,7 +208,7 @@ function ReplyPanel({
208208
showReply,
209209
draftMessage,
210210
generateNudge,
211-
replyToAll, // New prop for "Reply to All"
211+
replyToAll,
212212
}: {
213213
message: ParsedMessage;
214214
refetch: () => void;
@@ -218,23 +218,23 @@ function ReplyPanel({
218218
showReply: boolean;
219219
draftMessage?: ThreadMessage;
220220
generateNudge?: boolean;
221-
replyToAll?: boolean; // New prop for "Reply to All"
221+
replyToAll?: boolean;
222222
}) {
223223
const replyRef = useRef<HTMLDivElement>(null);
224224

225225
const [isGeneratingNudge, setIsGeneratingNudge] = useState(false);
226226
const [nudge, setNudge] = useState<string | null>(null);
227227

228-
// Scroll to the reply panel when it first opens
228+
// scroll to the reply panel when it first opens
229229
useEffect(() => {
230230
if (defaultShowReply && replyRef.current) {
231+
// hacky using setTimeout
231232
setTimeout(() => {
232233
replyRef.current?.scrollIntoView({ behavior: "smooth", block: "end" });
233234
}, 500);
234235
}
235236
}, [defaultShowReply]);
236237

237-
// Generate nudge if enabled
238238
useEffect(() => {
239239
async function loadNudge() {
240240
setIsGeneratingNudge(true);
@@ -267,12 +267,11 @@ function ReplyPanel({
267267
if (generateNudge) loadNudge();
268268
}, [generateNudge, message]);
269269

270-
// Prepare the email for replying or forwarding
271270
const replyingToEmail: ReplyingToEmail = useMemo(() => {
272271
if (showReply) {
273272
if (draftMessage) return prepareDraftReplyEmail(draftMessage);
274273

275-
// Use nudge if available
274+
// use nudge if available
276275
if (nudge) {
277276
const nudgeHtml = nudge
278277
? nudge
@@ -283,12 +282,12 @@ function ReplyPanel({
283282
: "";
284283

285284
return replyToAll
286-
? prepareReplyToAllEmail(message, nudgeHtml) // Use "Reply to All" logic
285+
? prepareReplyToAllEmail(message, nudgeHtml)
287286
: prepareReplyingToEmail(message, nudgeHtml);
288287
}
289288

290289
return replyToAll
291-
? prepareReplyToAllEmail(message) // Use "Reply to All" logic
290+
? prepareReplyToAllEmail(message)
292291
: prepareReplyingToEmail(message);
293292
}
294293
return prepareForwardingEmail(message);
@@ -333,7 +332,7 @@ function ReplyPanel({
333332
const prepareReplyingToEmail = (
334333
message: ParsedMessage,
335334
content = "",
336-
replyToAll = false, // New parameter to handle "Reply to All"
335+
replyToAll = false,
337336
): ReplyingToEmail => {
338337
const sentFromUser = message.labelIds?.includes("SENT");
339338

0 commit comments

Comments
 (0)