Reubencf commited on
Commit
56c692f
·
1 Parent(s): 3ed6d7f

quiz master

Browse files
Files changed (1) hide show
  1. app/components/FileManager.tsx +12 -8
app/components/FileManager.tsx CHANGED
@@ -127,6 +127,12 @@ export function FileManager({ currentPath, onNavigate, onClose, onOpenFlutterApp
127
  return
128
  }
129
 
 
 
 
 
 
 
130
  // Add public folder to root directory if in root
131
  if (currentPath === '') {
132
  const publicFolder = {
@@ -137,16 +143,12 @@ export function FileManager({ currentPath, onNavigate, onClose, onOpenFlutterApp
137
  }
138
 
139
  // Add public folder if it doesn't exist
140
- if (data.files && Array.isArray(data.files)) {
141
- if (!data.files.some((f: FileItem) => f.path === 'public')) {
142
- data.files.unshift(publicFolder)
143
- }
144
- } else {
145
- data.files = [publicFolder]
146
  }
147
  }
148
 
149
- setFiles(data.files || [])
150
  } catch (error) {
151
  console.error('Error loading files:', error)
152
  setFiles([])
@@ -325,7 +327,9 @@ export function FileManager({ currentPath, onNavigate, onClose, onOpenFlutterApp
325
 
326
  // Group files by current directory level
327
  const currentLevelFiles = filteredFiles.filter(file => {
328
- const relativePath = currentPath ? file.path.replace(currentPath + '/', '') : file.path
 
 
329
  return !relativePath.includes('/')
330
  })
331
 
 
127
  return
128
  }
129
 
130
+ // Normalize files to ensure they have a path property
131
+ let normalizedFiles = (data.files || []).map((file: any) => ({
132
+ ...file,
133
+ path: file.path || file.name || '',
134
+ }))
135
+
136
  // Add public folder to root directory if in root
137
  if (currentPath === '') {
138
  const publicFolder = {
 
143
  }
144
 
145
  // Add public folder if it doesn't exist
146
+ if (!normalizedFiles.some((f: FileItem) => f.path === 'public')) {
147
+ normalizedFiles.unshift(publicFolder)
 
 
 
 
148
  }
149
  }
150
 
151
+ setFiles(normalizedFiles)
152
  } catch (error) {
153
  console.error('Error loading files:', error)
154
  setFiles([])
 
327
 
328
  // Group files by current directory level
329
  const currentLevelFiles = filteredFiles.filter(file => {
330
+ // Handle case where path might be undefined (use name as fallback)
331
+ const filePath = file.path || file.name || ''
332
+ const relativePath = currentPath ? filePath.replace(currentPath + '/', '') : filePath
333
  return !relativePath.includes('/')
334
  })
335