mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-09 01:53:21 +08:00
fix: support current directory picker errors
This commit is contained in:
parent
88ef12ecc8
commit
3c71712962
4 changed files with 118 additions and 44 deletions
|
|
@ -2526,6 +2526,15 @@ var import_react_dom = require("react-dom");
|
|||
function pickerErrorCode(error) {
|
||||
return error?.rpcError?.code ?? error?.code;
|
||||
}
|
||||
var PICKER_ERROR_KINDS = /* @__PURE__ */ new Map([
|
||||
["directory-picker/unavailable", "unavailable"],
|
||||
["directory-picker-unavailable", "unavailable"],
|
||||
["directory-picker/unreadable", "unreadable"],
|
||||
["directory-unreadable", "unreadable"]
|
||||
]);
|
||||
function pickerErrorKind(error) {
|
||||
return PICKER_ERROR_KINDS.get(pickerErrorCode(error));
|
||||
}
|
||||
function pickerErrorDetails(error) {
|
||||
return error?.rpcError?.details ?? error?.details;
|
||||
}
|
||||
|
|
@ -2633,9 +2642,9 @@ function WorkspaceDirectoryPicker({
|
|||
const initialPath = initialPathRef.current;
|
||||
const initial = await loadDirectory(initialPath || void 0, { reportError: false });
|
||||
if (!active || initial.aborted || initial.value) return;
|
||||
const code = pickerErrorCode(initial.error);
|
||||
const kind = pickerErrorKind(initial.error);
|
||||
const details = pickerErrorDetails(initial.error);
|
||||
if (code === "directory-picker-unavailable" && details?.capability === "native" && typeof picker.pickDirectory === "function") {
|
||||
if (kind === "unavailable" && details?.capability === "native" && typeof picker.pickDirectory === "function") {
|
||||
setLoading(true);
|
||||
try {
|
||||
const selected = await picker.pickDirectory();
|
||||
|
|
@ -2649,7 +2658,7 @@ function WorkspaceDirectoryPicker({
|
|||
}
|
||||
return;
|
||||
}
|
||||
if (initialPath && code === "directory-unreadable") {
|
||||
if (initialPath && kind === "unreadable") {
|
||||
const home = await loadDirectory(void 0, { reportError: false });
|
||||
if (!active || home.aborted || home.value) return;
|
||||
setError(pickerErrorMessage(home.error));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue