mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 09:36:27 +00:00
editor: show error message on fail to activate
When gotoError fails to activate a file, we need to show an error message, otherwise it just appears to the user that the button is broken. Fixes: https://github.com/pybricks/support/issues/924
This commit is contained in:
committed by
David Lechner
parent
8c90854184
commit
0d3447a0b6
+23
-1
@@ -1,5 +1,5 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2022 The Pybricks Authors
|
||||
// Copyright (c) 2022-2023 The Pybricks Authors
|
||||
|
||||
import type { DatabaseChangeType, IDatabaseChange } from 'dexie-observable/api';
|
||||
import * as monaco from 'monaco-editor';
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
take,
|
||||
takeEvery,
|
||||
} from 'typed-redux-saga/macro';
|
||||
import { alertsShowAlert } from '../alerts/actions';
|
||||
import { FileStorageDb, UUID } from '../fileStorage';
|
||||
import {
|
||||
fileStorageDidFailToLoadTextFile,
|
||||
@@ -257,6 +258,27 @@ function* handleEditorGoto(
|
||||
});
|
||||
|
||||
if (didFailToActivate) {
|
||||
if (
|
||||
didFailToActivate.error instanceof EditorError &&
|
||||
didFailToActivate.error.name === 'FileInUse'
|
||||
) {
|
||||
const db = yield* getContext<FileStorageDb>('fileStorage');
|
||||
|
||||
const metadata = yield* call(() => db.metadata.get(action.uuid));
|
||||
|
||||
yield* put(
|
||||
alertsShowAlert('explorer', 'fileInUse', {
|
||||
fileName: metadata?.path ?? '<unknown>',
|
||||
}),
|
||||
);
|
||||
} else {
|
||||
yield* put(
|
||||
alertsShowAlert('alerts', 'unexpectedError', {
|
||||
error: didFailToActivate.error,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user