@@ -36,6 +36,9 @@ export class InboxView extends View {
3636 public readonly threadId : string | undefined ;
3737 public readonly showOriginal : boolean ;
3838 public readonly debug : boolean ;
39+ public readonly useFullScreenSecureCompose : boolean ;
40+ public readonly thunderbirdMsgId : number | undefined ;
41+ public readonly composeMethod : 'reply' | 'forward' | undefined ;
3942 public readonly S : SelCache ;
4043 public readonly gmail : Gmail ;
4144
@@ -49,12 +52,24 @@ export class InboxView extends View {
4952
5053 public constructor ( ) {
5154 super ( ) ;
52- const uncheckedUrlParams = Url . parse ( [ 'acctEmail' , 'labelId' , 'threadId' , 'showOriginal' , 'debug' ] ) ;
55+ const uncheckedUrlParams = Url . parse ( [
56+ 'acctEmail' ,
57+ 'labelId' ,
58+ 'threadId' ,
59+ 'showOriginal' ,
60+ 'debug' ,
61+ 'useFullScreenSecureCompose' ,
62+ 'composeMethod' ,
63+ 'thunderbirdMsgId' ,
64+ ] ) ;
5365 this . acctEmail = Assert . urlParamRequire . string ( uncheckedUrlParams , 'acctEmail' ) ;
5466 this . labelId = uncheckedUrlParams . labelId ? String ( uncheckedUrlParams . labelId ) : 'INBOX' ;
5567 this . threadId = Assert . urlParamRequire . optionalString ( uncheckedUrlParams , 'threadId' ) ;
5668 this . showOriginal = uncheckedUrlParams . showOriginal === true ;
5769 this . debug = uncheckedUrlParams . debug === true ;
70+ this . useFullScreenSecureCompose = uncheckedUrlParams . useFullScreenSecureCompose === true ;
71+ this . composeMethod = ( Assert . urlParamRequire . optionalString ( uncheckedUrlParams , 'composeMethod' ) as 'reply' ) || 'forward' ;
72+ this . thunderbirdMsgId = Number ( Assert . urlParamRequire . optionalString ( uncheckedUrlParams , 'thunderbirdMsgId' ) ) ;
5873 this . S = Ui . buildJquerySels ( { threads : '.threads' , thread : '.thread' , body : 'body' } ) ;
5974 this . gmail = new Gmail ( this . acctEmail ) ;
6075 this . inboxMenuModule = new InboxMenuModule ( this ) ;
@@ -72,6 +87,11 @@ export class InboxView extends View {
7287 ( { email_provider : emailProvider , picture : this . picture } = await AcctStore . get ( this . acctEmail , [ 'email_provider' , 'picture' ] ) ) ;
7388 this . messageRenderer = await MessageRenderer . newInstance ( this . acctEmail , this . gmail , this . relayManager , this . factory , this . debug ) ;
7489 this . inboxNotificationModule . render ( ) ;
90+ const parsedThreadId = await this . parseThreadIdFromHeaderMessageId ( ) ;
91+ this . preRenderSecureComposeInFullScreen ( parsedThreadId ) ;
92+ if ( Catch . isThunderbirdMail ( ) ) {
93+ $ ( '#container-gmail-banner' ) . hide ( ) ;
94+ }
7595 try {
7696 await Settings . populateAccountsMenu ( 'inbox.htm' ) ;
7797 if ( emailProvider && emailProvider !== 'gmail' ) {
@@ -81,7 +101,11 @@ export class InboxView extends View {
81101 if ( this . threadId ) {
82102 await this . inboxActiveThreadModule . render ( this . threadId ) ;
83103 } else {
84- await this . inboxListThreadsModule . render ( this . labelId ) ;
104+ if ( parsedThreadId && ! this . useFullScreenSecureCompose ) {
105+ await this . inboxActiveThreadModule . render ( parsedThreadId ) ;
106+ } else {
107+ await this . inboxListThreadsModule . render ( this . labelId ) ;
108+ }
85109 }
86110 }
87111 } catch ( e ) {
@@ -99,6 +123,7 @@ export class InboxView extends View {
99123 public setHandlers = ( ) => {
100124 this . addBrowserMsgListeners ( ) ;
101125 BrowserMsg . listen ( this . tabId ) ;
126+ BrowserMsg . send . setHandlerReadyForPGPBlock ( 'broadcast' ) ;
102127 Catch . setHandledInterval ( this . webmailCommon . addOrRemoveEndSessionBtnIfNeeded , 30000 ) ;
103128 $ ( '.action_open_settings' ) . on (
104129 'click' ,
@@ -132,6 +157,31 @@ export class InboxView extends View {
132157 Xss . sanitizeRender ( 'h1' , title ) ;
133158 } ;
134159
160+ private preRenderSecureComposeInFullScreen = ( replyMsgId ?: string ) => {
161+ if ( this . useFullScreenSecureCompose && this . composeMethod ) {
162+ const replyOption = this . composeMethod === 'reply' ? 'a_reply' : 'a_forward' ;
163+ this . injector . openComposeWin ( undefined , true , this . thunderbirdMsgId , replyOption , replyMsgId ) ;
164+ }
165+ } ;
166+
167+ private parseThreadIdFromHeaderMessageId = async ( ) => {
168+ let threadId ;
169+ if ( Catch . isThunderbirdMail ( ) && this . thunderbirdMsgId ) {
170+ const { headers } = await messenger . messages . getFull ( this . thunderbirdMsgId ) ;
171+ if ( headers ) {
172+ const messageId = headers [ 'message-id' ] [ 0 ] ;
173+ if ( messageId ) {
174+ const query = `rfc822msgid:${ messageId } ` ;
175+ const gmailRes = await this . gmail . msgList ( query ) ;
176+ if ( gmailRes . messages ) {
177+ threadId = gmailRes . messages [ 0 ] . threadId ;
178+ }
179+ }
180+ }
181+ }
182+ return threadId ;
183+ } ;
184+
135185 private addBrowserMsgListeners = ( ) => {
136186 BrowserMsg . addListener ( 'add_end_session_btn' , ( ) => this . injector . insertEndSessionBtn ( this . acctEmail ) ) ;
137187 BrowserMsg . addListener ( 'set_active_window' , async ( { frameId } : Bm . ComposeWindow ) => {
0 commit comments