debug: add logging to LibraryDetailPage loadSources + appear

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
wangdl 2026-06-18 22:32:40 +08:00
parent c5ce70fa5a
commit c0b7dda8c6

View File

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