* Open a (new) directory and replaces the old one.
(pathname: string)
| 368 | * Open a (new) directory and replaces the old one. |
| 369 | */ |
| 370 | openFolder(pathname: string): void { |
| 371 | // TODO: Don't allow new files if quitting. |
| 372 | if ( |
| 373 | !pathname || |
| 374 | this.lifecycle === WindowLifecycle.QUITTED || |
| 375 | isSamePathSync(pathname, this._openedRootDirectory ?? '') |
| 376 | ) { |
| 377 | return |
| 378 | } |
| 379 | |
| 380 | if (this.lifecycle === WindowLifecycle.READY) { |
| 381 | const { browserWindow } = this |
| 382 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 383 | const _accessor = this._accessor as any |
| 384 | const { menu: appMenu, preferences } = _accessor |
| 385 | |
| 386 | if (this._openedRootDirectory) { |
| 387 | ipcMain.emit('watcher-unwatch-directory', browserWindow, this._openedRootDirectory) |
| 388 | } |
| 389 | |
| 390 | preferences.setItems({ lastOpenedFolder: pathname }) |
| 391 | appMenu.addRecentlyUsedDocument(pathname) |
| 392 | this._openedRootDirectory = pathname |
| 393 | ipcMain.emit('watcher-watch-directory', browserWindow, pathname) |
| 394 | browserWindow!.webContents.send('mt::open-directory', pathname) |
| 395 | } else { |
| 396 | this._directoryToOpen = pathname |
| 397 | } |
| 398 | } |
| 399 | |
| 400 | /** |
| 401 | * Add a new path to the file list and watch the given path. |
no test coverage detected