diff --git a/AIStudyApp/AIStudyApp/Features/Library/LibrarySubpages.swift b/AIStudyApp/AIStudyApp/Features/Library/LibrarySubpages.swift index 984f455..c973d08 100644 --- a/AIStudyApp/AIStudyApp/Features/Library/LibrarySubpages.swift +++ b/AIStudyApp/AIStudyApp/Features/Library/LibrarySubpages.swift @@ -144,9 +144,11 @@ struct LibraryDetailPage: View { @State private var detailTab = 1 private func appear() async { - // Load KB info and sources + print("[LibraryDetail] appear() START, kbId=\(knowledgeBaseId)") viewModel.knowledgeBase = try? await KnowledgeBaseService.shared.detail(id: knowledgeBaseId) + print("[LibraryDetail] KB loaded: \(viewModel.knowledgeBase?.title ?? "nil")") await loadSources() + print("[LibraryDetail] appear() DONE") } @State private var sortOption = 0 @State private var showFolderManager = false @@ -640,16 +642,16 @@ struct LibraryDetailPage: View { private func loadSources() async { isLoadingSources = true - do { sources = try await KnowledgeSourceService.shared.list(kbId: knowledgeBaseId) } catch {} - // Fetch reading status for sources - for src in sources.prefix(20) { - if let progress = try? await ReadingAPIService.shared.getReadingProgress( - materialId: src.id, targetType: "knowledge_source" - ) { - sourceReadingStatus[src.id] = progress.isMarkedRead ? "read" : progress.status - } else if MarkedReadStore.shared.contains(src.id) { - sourceReadingStatus[src.id] = "read" + print("[LibraryDetail] loadSources START, kbId=\(knowledgeBaseId)") + do { + sources = try await KnowledgeSourceService.shared.list(kbId: knowledgeBaseId) + print("[LibraryDetail] loadSources OK, count=\(sources.count)") + for src in sources { + print("[LibraryDetail] source: id=\(src.id), title=\(src.title ?? "-"), parseStatus=\(src.parseStatus ?? "-")") } + } catch { + print("[LibraryDetail] loadSources ERROR: \(error.localizedDescription)") + print("[LibraryDetail] Full error: \(error)") } isLoadingSources = false }