@@ -361,22 +361,6 @@ export default {
361
361
}
362
362
return topic ;
363
363
} ,
364
- processEmails ( messageDetails ) {
365
- // Process and structure the email data
366
- return messageDetails . map ( ( msg ) => {
367
- const headers = msg . payload . headers ;
368
- return {
369
- "id" : msg . id ,
370
- "threadId" : msg . threadId ,
371
- "subject" : headers . find ( ( h ) => h . name . toLowerCase ( ) === "subject" ) ?. value ,
372
- "from" : headers . find ( ( h ) => h . name . toLowerCase ( ) === "from" ) ?. value ,
373
- "to" : headers . find ( ( h ) => h . name . toLowerCase ( ) === "to" ) ?. value ,
374
- "reply-to" : headers . find ( ( h ) => h . name . toLowerCase ( ) === "reply-to" ) ?. value ,
375
- "date" : headers . find ( ( h ) => h . name . toLowerCase ( ) === "date" ) ?. value ,
376
- "snippet" : msg . snippet ,
377
- } ;
378
- } ) ;
379
- } ,
380
364
getHistoryTypes ( ) {
381
365
return [
382
366
"messageAdded" ,
@@ -386,7 +370,7 @@ export default {
386
370
return {
387
371
id : message . id ,
388
372
summary : message . snippet ,
389
- ts : message . internalDate ,
373
+ ts : + message . internalDate ,
390
374
} ;
391
375
} ,
392
376
filterHistory ( history ) {
@@ -488,23 +472,12 @@ export default {
488
472
489
473
console . log ( "Fetched message details count:" , messageDetails . length ) ;
490
474
491
- const processedEmails = this . processEmails ( messageDetails ) ;
492
-
493
475
// Store the latest historyId in the db
494
476
const latestHistoryId = historyResponse . historyId || receivedHistoryId ;
495
477
this . _setLastProcessedHistoryId ( latestHistoryId ) ;
496
478
console . log ( "Updated lastProcessedHistoryId:" , latestHistoryId ) ;
497
479
498
- for ( let i = 0 ; i < messageDetails . length ; i ++ ) {
499
- this . $emit ( {
500
- ...messageDetails [ i ] ,
501
- "parsed-headers" : processedEmails [ i ] ,
502
- } , {
503
- id : processedEmails [ i ] . id ,
504
- summary : processedEmails [ i ] . subject ,
505
- ts : Date . now ( ) ,
506
- } ) ;
507
- }
480
+ messageDetails . forEach ( ( message ) => this . emitEvent ( message ) ) ;
508
481
}
509
482
} ,
510
483
} ;
0 commit comments