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:
2025-06-10 18:09:53 +02:00
parent 0a541f658d
commit 3d3a712ed2
2 changed files with 12 additions and 9 deletions

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();