@@ -15,6 +15,7 @@ import {Download, Paperclip} from "lucide-react"
1515import { EmailAddress , EmailAttachment , EmailDetail , EmailViewerProps } from "@/types" ;
1616import { Cache } from "@/lib/cache"
1717import { formatPlainText } from "@/lib/text-formatter"
18+ import { CacheSettings , EmailDisplaySettings } from "@/lib/settings"
1819
1920export function EmailViewer ( { accountId, folder, uid} : EmailViewerProps ) {
2021 const [ email , setEmail ] = useState < EmailDetail | null > ( null )
@@ -57,7 +58,7 @@ export function EmailViewer({accountId, folder, uid}: EmailViewerProps) {
5758 }
5859
5960 // Cache for 10 minutes (emails don't change often)
60- Cache . set ( cacheKey , data . email , 10 * 60 * 1000 )
61+ Cache . set ( cacheKey , data . email , CacheSettings . client . email )
6162
6263 setEmail ( data . email )
6364 setLoading ( false )
@@ -73,7 +74,7 @@ export function EmailViewer({accountId, folder, uid}: EmailViewerProps) {
7374
7475 // Auto-detect best view mode
7576 const defaultTab = useMemo ( ( ) => {
76- if ( ! email ) return "text"
77+ if ( ! email ) return EmailDisplaySettings . defaultView
7778
7879 // If only text exists, use text
7980 if ( email . text && ! email . html ) return "text"
@@ -101,7 +102,7 @@ export function EmailViewer({accountId, folder, uid}: EmailViewerProps) {
101102 return hasFormatting ? "html" : "text"
102103 }
103104
104- return "text"
105+ return EmailDisplaySettings . defaultView
105106 } , [ email ] )
106107
107108 async function downloadAttachment ( att : EmailAttachment ) {
@@ -162,7 +163,12 @@ export function EmailViewer({accountId, folder, uid}: EmailViewerProps) {
162163
163164 function formatAddress ( addr ?: EmailAddress [ ] ) : string {
164165 if ( ! addr || addr . length === 0 ) return "Unknown"
165- return addr . map ( ( a ) => a . name || a . address ) . join ( ", " )
166+ return addr . map ( ( a ) => {
167+ if ( EmailDisplaySettings . showEmailAddresses && a . name && a . address ) {
168+ return `${ a . name } <${ a . address } >`
169+ }
170+ return a . name || a . address || "Unknown"
171+ } ) . join ( ", " )
166172 }
167173
168174 return (
@@ -187,7 +193,7 @@ export function EmailViewer({accountId, folder, uid}: EmailViewerProps) {
187193 ) }
188194 < div className = "flex gap-2" >
189195 < span className = "text-muted-foreground w-16" > Date:</ span >
190- < span > { email . date ? format ( new Date ( email . date ) , "PPpp" ) : "Unknown" } </ span >
196+ < span > { email . date ? format ( new Date ( email . date ) , EmailDisplaySettings . dateFormat ) : "Unknown" } </ span >
191197 </ div >
192198 </ div >
193199
0 commit comments