Fix email loading issues and improve performance

- Removed limit on cached emails - now loads ALL cached emails from MinIO
- Kept IMAP limit at 50 for reasonable performance
- Added loading indicator showing when emails are being fetched
- Fixed ES module import issue in email-utils.ts
- Improved user experience with visual feedback during loading

This ensures all email threads load completely while maintaining reasonable performance
This commit is contained in:
Matt 2025-06-10 18:09:53 +02:00
parent 0a541f658d
commit 3d3a712ed2
2 changed files with 12 additions and 9 deletions

View File

@ -75,8 +75,14 @@
</div>
</div>
<!-- Loading State -->
<div v-if="isRefreshing && emailThreads.length === 0 && threads.length === 0" class="text-center py-8">
<v-progress-circular indeterminate color="primary" :size="48" />
<div class="text-body-2 mt-3 text-grey">Loading email history...</div>
</div>
<!-- Email Thread List -->
<div v-if="emailThreads.length > 0 || threads.length > 0" class="email-threads">
<div v-else-if="emailThreads.length > 0 || threads.length > 0" class="email-threads">
<div class="text-subtitle-1 mb-3 d-flex align-center">
Email History
<v-spacer />

View File

@ -24,8 +24,8 @@ export default defineEventHandler(async (event) => {
try {
const body = await readBody(event);
// Limit emails to improve performance
const { clientEmail, interestId, sessionId, limit = 20 } = body;
// Limit IMAP emails but load all cached emails
const { clientEmail, interestId, sessionId, limit = 50 } = body;
if (!clientEmail || !sessionId) {
throw createError({
@ -84,13 +84,10 @@ export default defineEventHandler(async (event) => {
console.log('Found cached email files:', files.length);
// Limit cached emails to most recent ones
const sortedFiles = files
.filter(f => f.name.endsWith('.json'))
.sort((a, b) => b.name.localeCompare(a.name)) // Sort by filename (newer files have higher timestamps)
.slice(0, limit); // Only load up to the limit
// Load ALL cached emails (no limit) - just filter JSON files
const jsonFiles = files.filter(f => f.name.endsWith('.json'));
for (const file of sortedFiles) {
for (const file of jsonFiles) {
try {
// Read file directly on server using MinIO client (works with private buckets)
const client = getMinioClient();