IOS-INFO-007 P0 | MaterialReaderView 生命周期事件恢复 【审计: 部分存在,需改造】 #72

Closed
opened 2026-06-07 11:55:22 +08:00 by wangdl · 1 comment
Owner

审查

onAppear/onDisappear 存在但 Rust 调用注释。需恢复。

文件加载成功→start+opened。退出→close+export+本地队列+ack Rust。加载失败不产生 opened。

## 审查 onAppear/onDisappear 存在但 Rust 调用注释。需恢复。 文件加载成功→start+opened。退出→close+export+本地队列+ack Rust。加载失败不产生 opened。
wangdl added this to the M-IOS-INFO:学习信息采集、上传、继续学习与基础分析闭环 milestone 2026-06-07 11:55:22 +08:00
wangdl changed title from IOS-INFO-006 P0 | MaterialReaderView 生命周期接入 to IOS-INFO-007 P0 | MaterialReaderView 生命周期事件恢复 【审计: 部分存在,需改造】 2026-06-07 12:10:03 +08:00
Author
Owner

完成报告

修复内容

MaterialReaderView.swift — 恢复生命周期事件链路:

1. onAppear → openReadingSession()

private func openReadingSession() {
    let context = ReadingMaterialContext(
        readingTargetType: knowledgeBaseId != nil ? .knowledgeSource : .temporaryFile,
        materialId: vm.materialId, knowledgeBaseId: knowledgeBaseId, title: title
    )
    // V2 primary
    if let _ = try? sessionManager.openMaterial(context) { return }
    // V1 fallback
    collector.open(materialId: vm.materialId)
}

2. onDisappear → closeReadingSession()

  • V2: sessionManager.closeMaterial() + save position
  • V1: collector.close() + save position

3. reportScrollPosition → V2 primary

  • sessionManager.state == .active → sessionManager.updatePosition()
  • 否则 → V1 fallback

4. buildAnchor → V2 + V1 fallback

  • sessionManager.lastPosition ?? collector.lastPosition
## 完成报告 ### 修复内容 `MaterialReaderView.swift` — 恢复生命周期事件链路: **1. onAppear → openReadingSession()** ```swift private func openReadingSession() { let context = ReadingMaterialContext( readingTargetType: knowledgeBaseId != nil ? .knowledgeSource : .temporaryFile, materialId: vm.materialId, knowledgeBaseId: knowledgeBaseId, title: title ) // V2 primary if let _ = try? sessionManager.openMaterial(context) { return } // V1 fallback collector.open(materialId: vm.materialId) } ``` **2. onDisappear → closeReadingSession()** - V2: sessionManager.closeMaterial() + save position - V1: collector.close() + save position **3. reportScrollPosition → V2 primary** - `sessionManager.state == .active` → sessionManager.updatePosition() - 否则 → V1 fallback **4. buildAnchor → V2 + V1 fallback** - `sessionManager.lastPosition ?? collector.lastPosition`
Sign in to join this conversation.
No description provided.