Skip to content

Commit 5c3b608

Browse files
authored
FileState: attempt to fix error status when opening a non valid directory (#333)
1 parent 5ded022 commit 5c3b608

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-explorer",
3-
"version": "2.3.1",
3+
"version": "3.0.0-beta.1",
44
"description": "Plugin-based file explorer written with React",
55
"main": "build/main.js",
66
"build": {
@@ -36,9 +36,9 @@
3636
"server": "pm2 start \"npx ws -d ./build-e2e -p 8080\" --name cy-server",
3737
"server:stop": "pm2 --silent stop cy-server || true",
3838
"dist": "webpack --config webpack.config.production.ts && electron-builder -mwl",
39-
"dist-win": "webpack --config webpack.config.production.ts && electron-builder -w",
40-
"dist-mac": "webpack --config webpack.config.production.ts && electron-builder -m",
41-
"dist-linux": "webpack --config webpack.config.production.ts && electron-builder -l",
39+
"dist-win": "webpack --config webpack.config.production.ts && electron-builder -w --x64 --arm64",
40+
"dist-mac": "webpack --config webpack.config.production.ts && electron-builder -m --universal",
41+
"dist-linux": "webpack --config webpack.config.production.ts && electron-builder -l --x64 --arm64",
4242
"postinstall": "electron-builder install-app-deps && npm run install:e2e",
4343
"install:e2e": "cd e2e && npm install"
4444
},

src/state/fileState.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export class FileState {
4141
status: TStatus = 'ok'
4242

4343
error = false
44+
previousError = false
4445

4546
cmd = ''
4647

@@ -81,7 +82,16 @@ export class FileState {
8182

8283
setStatus(status: TStatus, error = false): void {
8384
this.status = status
84-
this.error = error
85+
if (!error) {
86+
this.previousError = this.error
87+
this.error = false
88+
} else {
89+
if (this.history.length === 0 || this.previousError) {
90+
this.error = true
91+
}
92+
}
93+
// this.error = error
94+
// this.history.length === 0 || this.error
8595
}
8696

8797
addPathToHistory(path: string): void {
@@ -393,7 +403,7 @@ export class FileState {
393403
console.log('handleError', error)
394404
// we want to show the error on first nav
395405
// otherwise we keep previous
396-
this.setStatus('ok', this.history.length === 0 || this.error)
406+
this.setStatus('ok', true)
397407
const niceError = getLocalizedError(error)
398408
console.log('orignalCode', error.code, 'newCode', niceError.code)
399409
AppAlert.show(i18n.i18next.t('ERRORS.GENERIC', { error }), {

0 commit comments

Comments
 (0)