@@ -772,6 +772,7 @@ export class MailDatabase {
772772 attachments_json : string ;
773773 } ;
774774 const attachments = JSON . parse ( message . attachments_json ) as AttachmentMetadata [ ] ;
775+ const mailboxIds = this . listMailboxIdsForMessage ( message . id ) ;
775776
776777 return {
777778 accountId : resolvedAccountId ,
@@ -785,8 +786,8 @@ export class MailDatabase {
785786 bccRecipients : JSON . parse ( message . bcc_recipients_json ) as MessageParticipant [ ] ,
786787 receivedAt : message . received_at ,
787788 unread : Boolean ( message . unread ) ,
788- starred : Boolean ( message . starred ) ,
789- mailboxIds : this . listMailboxIdsForMessage ( message . id ) ,
789+ starred : starredFromState ( Boolean ( message . starred ) , mailboxIds ) ,
790+ mailboxIds,
790791 snippet : message . snippet ,
791792 attachmentCount : attachments . length ,
792793 updatedAt : message . updated_at || message . received_at ,
@@ -851,6 +852,7 @@ export class MailDatabase {
851852 }
852853
853854 const attachments = JSON . parse ( row . attachments_json ) as AttachmentMetadata [ ] ;
855+ const mailboxIds = this . listMailboxIdsForMessage ( row . id ) ;
854856
855857 return {
856858 accountId : resolvedAccountId ,
@@ -864,8 +866,8 @@ export class MailDatabase {
864866 bccRecipients : JSON . parse ( row . bcc_recipients_json ) as MessageParticipant [ ] ,
865867 receivedAt : row . received_at ,
866868 unread : Boolean ( row . unread ) ,
867- starred : Boolean ( row . starred ) ,
868- mailboxIds : this . listMailboxIdsForMessage ( row . id ) ,
869+ starred : starredFromState ( Boolean ( row . starred ) , mailboxIds ) ,
870+ mailboxIds,
869871 snippet : row . snippet ,
870872 attachmentCount : attachments . length ,
871873 updatedAt : row . updated_at || row . received_at ,
@@ -906,6 +908,7 @@ export class MailDatabase {
906908 attachments_json : string ;
907909 } ;
908910 const attachments = JSON . parse ( message . attachments_json ) as AttachmentMetadata [ ] ;
911+ const mailboxIds = this . listMailboxIdsForMessage ( message . id ) ;
909912
910913 return {
911914 accountId : mailAccountId ,
@@ -919,8 +922,8 @@ export class MailDatabase {
919922 bccRecipients : JSON . parse ( message . bcc_recipients_json ) as MessageParticipant [ ] ,
920923 receivedAt : message . received_at ,
921924 unread : Boolean ( message . unread ) ,
922- starred : Boolean ( message . starred ) ,
923- mailboxIds : this . listMailboxIdsForMessage ( message . id ) ,
925+ starred : starredFromState ( Boolean ( message . starred ) , mailboxIds ) ,
926+ mailboxIds,
924927 snippet : message . snippet ,
925928 attachmentCount : attachments . length ,
926929 updatedAt : message . updated_at || message . received_at ,
@@ -962,6 +965,7 @@ export class MailDatabase {
962965 attachments_json : string ;
963966 } ;
964967 const attachments = JSON . parse ( message . attachments_json ) as AttachmentMetadata [ ] ;
968+ const mailboxIds = this . listMailboxIdsForMessage ( message . id ) ;
965969
966970 return {
967971 accountId : mailAccountId ,
@@ -975,8 +979,8 @@ export class MailDatabase {
975979 bccRecipients : JSON . parse ( message . bcc_recipients_json ) as MessageParticipant [ ] ,
976980 receivedAt : message . received_at ,
977981 unread : Boolean ( message . unread ) ,
978- starred : Boolean ( message . starred ) ,
979- mailboxIds : this . listMailboxIdsForMessage ( message . id ) ,
982+ starred : starredFromState ( Boolean ( message . starred ) , mailboxIds ) ,
983+ mailboxIds,
980984 snippet : message . snippet ,
981985 attachmentCount : attachments . length ,
982986 updatedAt : message . updated_at || message . received_at ,
@@ -1024,6 +1028,7 @@ export class MailDatabase {
10241028 }
10251029
10261030 const attachments = JSON . parse ( row . attachments_json ) as AttachmentMetadata [ ] ;
1031+ const mailboxIds = this . listMailboxIdsForMessage ( row . id ) ;
10271032
10281033 return {
10291034 accountId : mailAccountId ,
@@ -1037,8 +1042,8 @@ export class MailDatabase {
10371042 bccRecipients : JSON . parse ( row . bcc_recipients_json ) as MessageParticipant [ ] ,
10381043 receivedAt : row . received_at ,
10391044 unread : Boolean ( row . unread ) ,
1040- starred : Boolean ( row . starred ) ,
1041- mailboxIds : this . listMailboxIdsForMessage ( row . id ) ,
1045+ starred : starredFromState ( Boolean ( row . starred ) , mailboxIds ) ,
1046+ mailboxIds,
10421047 snippet : row . snippet ,
10431048 attachmentCount : attachments . length ,
10441049 updatedAt : row . updated_at || row . received_at ,
@@ -1135,6 +1140,16 @@ function encodeMessageCursor(receivedAt: string, id: string): string {
11351140 return Buffer . from ( JSON . stringify ( { receivedAt, id } ) , "utf8" ) . toString ( "base64url" ) ;
11361141}
11371142
1143+ function starredFromState ( starred : boolean , mailboxIds : string [ ] ) : boolean {
1144+ return starred || mailboxIds . some ( ( mailboxId ) => isStarredLikeMailboxId ( mailboxId ) ) ;
1145+ }
1146+
1147+ function isStarredLikeMailboxId ( mailboxId : string ) : boolean {
1148+ const normalized = mailboxId . toLowerCase ( ) ;
1149+
1150+ return normalized === "starred" || normalized . endsWith ( "/starred" ) ;
1151+ }
1152+
11381153function isTrashLikeMailboxId ( mailboxId : string ) : boolean {
11391154 const normalized = mailboxId . toLowerCase ( ) ;
11401155
0 commit comments