@@ -566,10 +566,21 @@ public function process() {
566566 $ mailbox = Hm_IMAP_List::get_mailbox_without_connection ($ details );
567567 $ label = $ mailbox ->get_folder_name ($ folder );
568568 if (!$ label ) {
569- $ paths = explode ("_ " , $ path );
570- $ short_path = $ paths [0 ] . "_ " . $ paths [1 ] . "_ " ;
571- $ cached_folders = $ this ->cache ->get ('imap_folders_ ' .$ short_path , true );
572- $ label = !empty ($ cached_folders [$ folder ]['name ' ]) ? $ cached_folders [$ folder ]['name ' ] : '' ;
569+ if ($ this ->config ->get ('allow_session_cache ' , false )) {
570+ $ paths = explode ("_ " , $ path );
571+ $ short_path = $ paths [0 ] . "_ " . $ paths [1 ] . "_ " ;
572+ $ cached_folders = $ this ->cache ->get ('imap_folders_ ' .$ short_path , true );
573+ $ label = !empty ($ cached_folders [$ folder ]['name ' ]) ? $ cached_folders [$ folder ]['name ' ] : '' ;
574+ } else {
575+ Hm_Msgs::add ('Folder name loaded directly from the server. This may be slower. Enable session caching for better performance. ' , 'warning ' );
576+ if (isset ($ details ['type ' ]) && $ details ['type ' ] === 'ews ' ) {
577+ $ connected_mailbox = Hm_IMAP_List::get_connected_mailbox ($ parts [1 ], $ this ->cache );
578+ if ($ connected_mailbox && $ connected_mailbox ->authed ()) {
579+ $ folder_status = $ connected_mailbox ->get_folder_status ($ folder , false );
580+ $ label = $ folder_status ['name ' ] ?? null ;
581+ }
582+ }
583+ }
573584 }
574585 $ title = array (strtoupper ($ details ['type ' ] ?? 'IMAP ' ), $ details ['name ' ], $ label );
575586 if ($ this ->get ('list_page ' , 0 )) {
0 commit comments