courrier clean 2
This commit is contained in:
parent
10b08b5043
commit
2c98417f50
@ -4,12 +4,13 @@ import React from 'react';
|
||||
import { useState, useEffect, useRef, useCallback, useMemo } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import {
|
||||
ChevronDown, ChevronUp, Search, Inbox, Trash, Star, Menu, X, Send,
|
||||
Reply, ReplyAll, CornerUpRight, RefreshCw, Check, MoreVertical, Paperclip,
|
||||
Trash2, Archive, Eye, EyeOff, FileDown, FilePlus, Ban, Filter, Mail,
|
||||
MailOpen, AlertCircle, Folder, ChevronLeft, ChevronRight, Edit,
|
||||
Forward, FolderOpen, MessageSquare, Copy, AlertOctagon, MoreHorizontal,
|
||||
Plus as PlusIcon
|
||||
Mail, Search, Plus as PlusIcon, Trash, Check, Forward, FolderOpen,
|
||||
MessageSquare, Copy, AlertOctagon, MoreHorizontal, ChevronDown,
|
||||
ChevronUp, X, RefreshCw, Inbox, Send, Archive, Star, Settings,
|
||||
Menu, Plus, Loader2, MailX, UserPlus, CheckCircle2, XCircle, Filter,
|
||||
Reply, ReplyAll, AlertCircle, Folder, Eye, ChevronLeft, ChevronRight,
|
||||
Paperclip, Trash2, CornerUpRight, Edit, MoreVertical, EyeOff, FileDown,
|
||||
FilePlus, Ban, MailOpen
|
||||
} from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
@ -53,6 +54,7 @@ import ComposeEmail from '@/components/ComposeEmail';
|
||||
import { decodeEmail, cleanHtml } from '@/lib/mail-parser-wrapper';
|
||||
import { Attachment as MailParserAttachment } from 'mailparser';
|
||||
import { LoadingFix } from './loading-fix';
|
||||
import { getEmailContent } from '@/lib/services/email-service';
|
||||
|
||||
export interface Account {
|
||||
id: number;
|
||||
@ -1583,51 +1585,37 @@ export default function CourrierPage() {
|
||||
text: content.text || '',
|
||||
contentFetched: true,
|
||||
// Add proper from/to/cc format for client-side formatters
|
||||
from: content.from,
|
||||
to: content.to,
|
||||
cc: content.cc,
|
||||
bcc: content.bcc,
|
||||
date: content.date
|
||||
from: typeof content.from === 'string' ? content.from : content.from[0]?.address || '',
|
||||
fromName: typeof content.from === 'string' ? '' : content.from[0]?.name || '',
|
||||
to: typeof content.to === 'string' ? content.to : content.to[0]?.address || '',
|
||||
cc: typeof content.cc === 'string' ? content.cc : content.cc?.[0]?.address || '',
|
||||
bcc: typeof content.bcc === 'string' ? content.bcc : content.bcc?.[0]?.address || '',
|
||||
date: typeof content.date === 'string' ? content.date : content.date.toString()
|
||||
};
|
||||
|
||||
setSelectedEmail(updatedEmail);
|
||||
|
||||
// For forwarding, we need to set the forwardFrom prop with the updated content
|
||||
// For forwarding, we need to set the isForwarding flag to true
|
||||
if (type === 'forward') {
|
||||
console.log('[DEBUG] Setting forwardFrom with content for forwarding');
|
||||
setForwardFrom(updatedEmail);
|
||||
console.log('[DEBUG] Setting isForwarding flag for forwarding');
|
||||
setIsForwarding(true);
|
||||
} else {
|
||||
// For replying, we need to set the replyTo prop with the correct reply type
|
||||
console.log('[DEBUG] Setting replyTo with content for replying');
|
||||
setReplyTo({
|
||||
...updatedEmail,
|
||||
replyType: type === 'reply-all' ? 'replyAll' : 'reply' // Convert to format expected by formatter
|
||||
});
|
||||
// For replying, we need to set isReplying to true
|
||||
console.log('[DEBUG] Setting isReplying to true for replying');
|
||||
setIsReplying(true);
|
||||
// Store the reply type in the component state if needed
|
||||
setReplyToEmail(updatedEmail);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Content already loaded, just set the props
|
||||
// Make sure the email has the correct format for client-side formatters
|
||||
const formattedEmail = {
|
||||
...selectedEmail,
|
||||
// Ensure we have proper address objects for the formatters
|
||||
from: selectedEmail.from ?
|
||||
(Array.isArray(selectedEmail.from) ? selectedEmail.from : [{ address: selectedEmail.from, name: selectedEmail.fromName }]) :
|
||||
[{ address: selectedEmail.from || '', name: selectedEmail.fromName }],
|
||||
to: selectedEmail.to ?
|
||||
(Array.isArray(selectedEmail.to) ? selectedEmail.to : [{ address: selectedEmail.to }]) :
|
||||
[{ address: selectedEmail.to || '' }]
|
||||
};
|
||||
|
||||
// Content already loaded, just set the flags
|
||||
if (type === 'forward') {
|
||||
console.log('[DEBUG] Setting forwardFrom for forwarding (content already loaded)');
|
||||
setForwardFrom(formattedEmail);
|
||||
console.log('[DEBUG] Setting isForwarding flag for forwarding (content already loaded)');
|
||||
setIsForwarding(true);
|
||||
} else {
|
||||
console.log('[DEBUG] Setting replyTo for replying (content already loaded)');
|
||||
setReplyTo({
|
||||
...formattedEmail,
|
||||
replyType: type === 'reply-all' ? 'replyAll' : 'reply' // Convert to format expected by formatter
|
||||
});
|
||||
console.log('[DEBUG] Setting isReplying to true (content already loaded)');
|
||||
setIsReplying(true);
|
||||
setReplyToEmail(selectedEmail);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user