Skip to content

Commit b0ed26a

Browse files
committed
fix: Missing or invalid navigation title in home page
1 parent 5f14207 commit b0ed26a

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

FileBrowserClient/FileBrowserClient/FileListView.swift

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ struct FileListView: View {
161161
.padding(.trailing, 20)
162162
.padding(.bottom, 30)
163163
}
164-
.navigationTitle(pathStack.last?.components(separatedBy: "/").last ?? "Home")
164+
.navigationTitle(getNavigationTitle())
165165
.toolbar {
166166
// Left: Refresh button
167167
ToolbarItem(placement: .navigationBarLeading) {
@@ -390,6 +390,23 @@ struct FileListView: View {
390390
)
391391
}
392392

393+
private func getNavigationTitle() -> String {
394+
// If we have a pathStack, use the last path component
395+
if let lastPath = pathStack.last, !lastPath.isEmpty {
396+
let components = lastPath.components(separatedBy: "/")
397+
return components.last ?? "Home"
398+
}
399+
400+
// If pathStack is empty or path is empty, we're at root
401+
if pathStack.isEmpty || path == "/" {
402+
return "Home"
403+
}
404+
405+
// Fallback: use the current path
406+
let components = path.components(separatedBy: "/")
407+
return components.last ?? "Home"
408+
}
409+
393410
func fetchClientStorageInfo() {
394411
fileCacheSize = FileCache.shared.diskCacheSize()
395412
}

0 commit comments

Comments
 (0)