@@ -42,6 +42,7 @@ define(function (require, exports, module) {
4242
4343 // state manager key, to save the download location of the image
4444 const IMAGE_DOWNLOAD_FOLDER_KEY = "imageGallery.downloadFolder" ;
45+ const IMAGE_DOWNLOAD_PERSIST_FOLDER_KEY = "imageGallery.persistFolder" ;
4546
4647 const DOWNLOAD_EVENTS = {
4748 STARTED : 'downloadStarted' ,
@@ -1157,6 +1158,10 @@ define(function (require, exports, module) {
11571158 let rootFolders = [ ] ;
11581159 let stringMatcher = null ;
11591160
1161+ const persistFolder = StateManager . get ( IMAGE_DOWNLOAD_PERSIST_FOLDER_KEY , StateManager . PROJECT_CONTEXT ) ;
1162+ const shouldBeChecked = persistFolder !== false ;
1163+ $rememberCheckbox . prop ( 'checked' , shouldBeChecked ) ;
1164+
11601165 _scanRootDirectoriesOnly ( projectRoot , rootFolders ) . then ( ( ) => {
11611166 stringMatcher = new StringMatch . StringMatcher ( { segmentedSearch : true } ) ;
11621167 _renderFolderSuggestions ( rootFolders . slice ( 0 , 15 ) , $suggestions , $input ) ;
@@ -1182,8 +1187,12 @@ define(function (require, exports, module) {
11821187 const folderPath = $input . val ( ) . trim ( ) ;
11831188
11841189 // if the checkbox is checked, we save the folder preference for this project
1185- if ( $rememberCheckbox . is ( ':checked' ) ) {
1190+ const isChecked = $rememberCheckbox . is ( ':checked' ) ;
1191+ StateManager . set ( IMAGE_DOWNLOAD_PERSIST_FOLDER_KEY , isChecked , StateManager . PROJECT_CONTEXT ) ;
1192+ if ( isChecked ) {
11861193 StateManager . set ( IMAGE_DOWNLOAD_FOLDER_KEY , folderPath , StateManager . PROJECT_CONTEXT ) ;
1194+ } else {
1195+ StateManager . set ( IMAGE_DOWNLOAD_FOLDER_KEY , undefined , StateManager . PROJECT_CONTEXT ) ;
11871196 }
11881197
11891198 // if message is provided, download the image
0 commit comments