@@ -3,16 +3,15 @@ const { getPreferences, savePreferences, preferencesUtil } = require('../store/p
3
3
const { isDirectory } = require ( '../utils/filesystem' ) ;
4
4
const { openCollection } = require ( '../app/collections' ) ;
5
5
const { globalEnvironmentsStore } = require ( '../store/global-environments' ) ;
6
- `` ;
6
+
7
7
const registerPreferencesIpc = ( mainWindow , watcher , lastOpenedCollections ) => {
8
- ipcMain . handle ( 'renderer:ready' , async ( event ) => {
8
+ ipcMain . handle ( 'renderer:ready' , async ( ) => {
9
9
// load preferences
10
10
const preferences = getPreferences ( ) ;
11
11
mainWindow . webContents . send ( 'main:load-preferences' , preferences ) ;
12
12
13
13
// load system proxy vars
14
- const systemProxyVars = preferencesUtil . getSystemProxyEnvVariables ( ) ;
15
- const { http_proxy, https_proxy, no_proxy } = systemProxyVars || { } ;
14
+ const { http_proxy, https_proxy, no_proxy } = preferencesUtil . getSystemProxyEnvVariables ( ) || { } ;
16
15
mainWindow . webContents . send ( 'main:load-system-proxy-env' , { http_proxy, https_proxy, no_proxy } ) ;
17
16
18
17
// load global environments
@@ -23,16 +22,20 @@ const registerPreferencesIpc = (mainWindow, watcher, lastOpenedCollections) => {
23
22
24
23
// reload last opened collections
25
24
const lastOpened = lastOpenedCollections . getAll ( ) ;
25
+ const invalidDirectories = [ ] ;
26
26
27
27
if ( lastOpened && lastOpened . length ) {
28
- for ( let collectionPath of lastOpened ) {
28
+ for ( const collectionPath of lastOpened ) {
29
29
if ( isDirectory ( collectionPath ) ) {
30
- await openCollection ( mainWindow , watcher , collectionPath , {
31
- dontSendDisplayErrors : true
32
- } ) ;
30
+ await openCollection ( mainWindow , watcher , collectionPath , { dontSendDisplayErrors : true } ) ;
31
+ } else {
32
+ invalidDirectories . push ( collectionPath ) ;
33
33
}
34
34
}
35
35
}
36
+
37
+ const updatedLastOpenedCollections = lastOpened . filter ( coll => ! invalidDirectories . includes ( coll ) ) ;
38
+ lastOpenedCollections . update ( updatedLastOpenedCollections ) ;
36
39
} ) ;
37
40
38
41
ipcMain . on ( 'main:open-preferences' , ( ) => {
@@ -48,4 +51,4 @@ const registerPreferencesIpc = (mainWindow, watcher, lastOpenedCollections) => {
48
51
} ) ;
49
52
} ;
50
53
51
- module . exports = registerPreferencesIpc ;
54
+ module . exports = registerPreferencesIpc ;
0 commit comments