fix: update backend response for /list route (#186)
* update structure of list directory response * fmt
This commit is contained in:
committed by
GitHub
parent
ed781b552a
commit
d994622a99
@@ -66,7 +66,14 @@ export function FolderPicker({
|
||||
|
||||
try {
|
||||
const result = await fileSystemApi.list(path);
|
||||
setEntries(result.entries || []);
|
||||
|
||||
// Ensure result exists and has the expected structure
|
||||
if (!result || typeof result !== 'object') {
|
||||
throw new Error('Invalid response from file system API');
|
||||
}
|
||||
// Safely access entries, ensuring it's an array
|
||||
const entries = Array.isArray(result.entries) ? result.entries : [];
|
||||
setEntries(entries);
|
||||
const newPath = result.current_path || '';
|
||||
setCurrentPath(newPath);
|
||||
// Update manual path if we have a specific path (not for initial home directory load)
|
||||
@@ -75,6 +82,8 @@ export function FolderPicker({
|
||||
}
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'Failed to load directory');
|
||||
// Reset entries to empty array on error
|
||||
setEntries([]);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user