@@ -650,13 +650,25 @@ public function process() {
650650 $ folder = $ this ->request ->post ['folder ' ];
651651 }
652652 $ path = sprintf ("imap_%s_%s " , $ form ['imap_server_id ' ], $ folder );
653- $ page_cache = $ this ->cache ->get ('imap_folders_ ' .$ path );
653+ $ with_subscription = isset ($ this ->request ->post ['subscription_state ' ]) && $ this ->request ->post ['subscription_state ' ];
654+
654655 if (array_key_exists ('imap_prefetch ' , $ this ->request ->post )) {
655656 $ prefetched = $ this ->session ->get ('imap_prefetched_ids ' , array ());
656657 $ prefetched [] = $ form ['imap_server_id ' ];
657658 $ this ->session ->set ('imap_prefetched_ids ' , array_unique ($ prefetched , SORT_STRING ));
658659 }
659- $ with_subscription = isset ($ this ->request ->post ['subscription_state ' ]) && $ this ->request ->post ['subscription_state ' ];
660+
661+ // Check cache FIRST before connecting to IMAP
662+ $ page_cache = $ this ->cache ->get ('imap_folders_ ' .$ path );
663+ if ($ page_cache ) {
664+ $ this ->out ('imap_expanded_folder_data ' , $ page_cache );
665+ $ this ->out ('imap_expanded_folder_id ' , $ form ['imap_server_id ' ]);
666+ $ this ->out ('imap_expanded_folder_path ' , $ path );
667+ $ this ->out ('with_input ' , $ with_subscription );
668+ $ this ->out ('folder ' , $ folder );
669+ return ;
670+ }
671+
660672 $ mailbox = Hm_IMAP_List::get_connected_mailbox ($ form ['imap_server_id ' ], $ this ->cache );
661673 if ($ mailbox && $ mailbox ->authed ()) {
662674 $ this ->out ('can_share_folders ' , stripos ($ mailbox ->get_capability (), 'ACL ' ) !== false );
@@ -673,14 +685,6 @@ public function process() {
673685 }
674686 }
675687 }
676- if ($ page_cache ) {
677- $ this ->out ('imap_expanded_folder_data ' , $ page_cache );
678- $ this ->out ('imap_expanded_folder_id ' , $ form ['imap_server_id ' ]);
679- $ this ->out ('imap_expanded_folder_path ' , $ path );
680- $ this ->out ('with_input ' , $ with_subscription );
681- $ this ->out ('folder ' , $ folder );
682- return ;
683- }
684688 if ($ mailbox && $ mailbox ->authed ()) {
685689 $ only_subscribed = $ this ->user_config ->get ('only_subscribed_folders_setting ' , false );
686690 if ($ with_subscription ) {
0 commit comments