@@ -642,34 +642,27 @@ var get_message_content = function(msg_part, uid, list_path, listParent, detail,
642642 window . scrollTo ( 0 , 0 ) ;
643643 }
644644 const onSuccess = function ( res ) {
645- if ( ! noupdate ) {
646- $ ( '.msg_text' ) . html ( '' ) ;
647- $ ( '.msg_text' ) . append ( res . msg_headers ) ;
648- $ ( '.msg_text' ) . append ( res . msg_text ) ;
649- $ ( '.msg_text' ) . append ( res . msg_parts ) ;
650- document . title = $ ( '.header_subject th' ) . text ( ) ;
651- imap_message_view_finished ( uid , detail , listParent ) ;
652- }
653- else {
654- $ ( '.reply_link, .reply_all_link, .forward_link' ) . each ( function ( ) {
655- $ ( this ) . attr ( "href" , $ ( this ) . data ( "href" ) ) ;
656- $ ( this ) . removeClass ( 'disabled_link' ) ;
657- } ) ;
658- }
645+ $ ( '.msg_text' ) . html ( '' ) ;
646+ $ ( '.msg_text' ) . append ( res . msg_headers ) ;
647+ $ ( '.msg_text' ) . append ( res . msg_text ) ;
648+ $ ( '.msg_text' ) . append ( res . msg_parts ) ;
649+
650+ document . title = $ ( '.header_subject th' ) . text ( ) ;
651+ imap_message_view_finished ( uid , detail , listParent ) ;
652+
659653 if ( ! res . show_pagination_links ) {
660654 $ ( '.prev, .next' ) . hide ( ) ;
661655 }
662656 globals . auto_advance_email_enabled = Boolean ( res . auto_advance_email_enabled ) ;
663657 } ;
664658
665659 if ( ! msg_part ) {
666- const msgContent = get_local_message_content ( uid , list_path ) ;
660+ var msgContent = get_local_message_content ( uid , list_path ) ;
667661 if ( msgContent ) {
668662 onSuccess ( msgContent ) ;
669663 if ( callback ) {
670664 callback ( msgContent )
671665 }
672- return ;
673666 }
674667 }
675668
@@ -680,7 +673,23 @@ var get_message_content = function(msg_part, uid, list_path, listParent, detail,
680673 { 'name' : 'imap_server_id' , 'value' : detail . server_id } ,
681674 { 'name' : 'folder' , 'value' : detail . folder } ] ,
682675 function ( res ) {
683- onSuccess ( res ) ;
676+ if ( res . msg_text === '<div class="msg_text_inner"></div>' && noupdate ) {
677+ const modal = new Hm_Modal ( {
678+ title : 'Message not found' ,
679+ modalId : 'messageNotFoundModal' ,
680+ } )
681+ modal . setContent ( "The email you're looking for isn't here.<br>It may have been deleted, moved." ) ;
682+ modal . addFooterBtn ( 'Go to message list' , 'btn-success' , function ( ) {
683+ Hm_Utils . redirect ( "?page=message_list&list_path=" + listParent ) ;
684+ } ) ;
685+ modal . addFooterBtn ( 'Search mail' , 'btn-success' , function ( ) {
686+ Hm_Utils . redirect ( "?page=search" ) ;
687+ } ) ;
688+ modal . open ( ) ;
689+ }
690+ if ( ! noupdate ) {
691+ onSuccess ( res ) ;
692+ }
684693 if ( ! noupdate && ! msg_part ) {
685694 Hm_Utils . save_to_local_storage ( getMessageStorageKey ( uid ) , JSON . stringify ( res ) ) ;
686695 }
@@ -845,27 +854,8 @@ var imap_setup_message_view_page = function(uid, details, list_path, listParent,
845854 }
846855
847856 const msg_content = get_local_message_content ( uid , list_path ) ;
848- if ( ! msg_content ) {
849- get_message_content ( false , uid , list_path , listParent , details , callback ) ;
850- }
851- else {
852- const msgResponse = msg_content ;
853- $ ( '.msg_text' ) . append ( msgResponse . msg_headers )
854- . append ( msgResponse . msg_text )
855- . append ( msgResponse . msg_parts ) ;
856- document . title = $ ( '.header_subject th' ) . text ( ) ;
857- if ( $ ( '.header_subject th' ) . find ( 'i.bi.bi-x-lg.close_inline_msg' ) . length === 0 ) {
858- $ ( '.header_subject th' ) . append ( '<i class="bi bi-x-lg close_inline_msg"></i>' ) ;
859- $ ( '.close_inline_msg' ) . on ( "click" , function ( ) { msg_inline_close ( ) ; } ) ;
860- }
861-
862- $ ( '.reply_link, .reply_all_link, .forward_link' ) . each ( function ( ) {
863- $ ( this ) . data ( "href" , $ ( this ) . attr ( "href" ) ) . removeAttr ( "href" ) ;
864- $ ( this ) . addClass ( 'disabled_link' ) ;
865- } ) ;
866- imap_message_view_finished ( uid , details , listParent ) ;
867- get_message_content ( false , uid , list_path , listParent , details , callback , true ) ;
868- }
857+ const noupdate = Boolean ( msg_content ) ;
858+ get_message_content ( false , uid , list_path , listParent , details , callback , noupdate ) ;
869859} ;
870860
871861var display_reply_content = function ( res ) {
0 commit comments