v1.0.4: вкладка 'Общий доступ' — быстрый скан корня + глубокий в фоне

This commit is contained in:
2026-09-15 22:34:27 +03:00
parent f2160a7768
commit 73afb23842
2 changed files with 18 additions and 6 deletions
+17 -5
View File
@@ -19,7 +19,7 @@ final class AppStore {
var title: String {
switch self {
case .disk: return "YanDisk"
case .files: return "Доступные мне"
case .files: return "Общий доступ"
case .recents: return "Недавние"
case .favorites: return "Избранное"
case .screenshots: return "Скриншоты"
@@ -251,18 +251,30 @@ final class AppStore {
// MARK: - Shared with me (field `share`, is_owned == false)
/// Сначала показываем общие папки корня (быстро), затем углубляем скан в фоне.
func loadPublicItems() async {
guard let api else { return }
isLoading = true
defer { isLoading = false }
do {
let shared = try await api.sharedWithMe()
publicItems = shared.sorted { a, b in
a.displayName.localizedCaseInsensitiveCompare(b.displayName) == .orderedAscending
}
let shallow = try await api.sharedWithMe(maxDepth: 0)
publicItems = Self.sorted(shallow)
errorMessage = nil
} catch {
handleError(error)
return
}
// Глубокий скан — в фоне, чтобы не блокировать вкладку.
Task { [weak self] in
guard let full = try? await api.sharedWithMe(maxDepth: 3) else { return }
guard let self, self.isAuthorized else { return }
self.publicItems = Self.sorted(full)
}
}
private static func sorted(_ items: [DiskResource]) -> [DiskResource] {
items.sorted {
$0.displayName.localizedCaseInsensitiveCompare($1.displayName) == .orderedAscending
}
}
+1 -1
View File
@@ -171,7 +171,7 @@ struct MainSplitView: View {
case .recents: return "Недавние"
case .favorites: return "Избранное"
case .screenshots: return "Скриншоты"
case .files: return "Доступные мне"
case .files: return "Общий доступ"
default:
if store.currentPath == "/" { return "YanDisk" }
return store.currentPath