Skip to content

fix: speed up mobile reader TOC#588

Open
codedogQBY wants to merge 1 commit into
mainfrom
codex/fix-android-toc-performance
Open

fix: speed up mobile reader TOC#588
codedogQBY wants to merge 1 commit into
mainfrom
codex/fix-android-toc-performance

Conversation

@codedogQBY

Copy link
Copy Markdown
Owner

Summary

  • replace the mobile reader TOC recursive ScrollView with a virtualized FlatList so large books do not mount thousands of chapter rows at once
  • track the current TOC href from relocate events and use it to identify the active chapter more reliably than title-only matching
  • expand active ancestors and scroll the TOC list near the current chapter when the sheet opens
  • keep TOC row height stable so scrollToIndex can jump directly into long 1000+ chapter lists

Fixes #576
Fixes #168

Analysis

The Android report in #576 points to two related problems: opening/closing a 2000-chapter TOC takes seconds, and the sheet always starts from chapter one even when the reader is around chapter 1200. The old panel recursively rendered the entire visible TOC tree inside ScrollView, so simple flat TOCs created all rows at once and closing the modal also had to unmount them. It also only highlighted by chapter title and never scrolled to the active item.

This PR virtualizes the list and uses the reader relocate href to find the active TOC row, then scrolls there on open.

Verification

  • PASS: biome check packages/app-expo/src/screens/reader/ReaderTOCPanel.tsx
  • PASS: git diff --check
  • BLOCKED: packages/app-expo/node_modules/.bin/tsc -p packages/app-expo/tsconfig.json --noEmit, existing missing packages: base64-js, @smithy/protocol-http, @smithy/querystring-builder
  • BLOCKED: biome check packages/app-expo/src/screens/ReaderScreen.tsx packages/app-expo/src/screens/reader/ReaderTOCPanel.tsx, existing ReaderScreen lint backlog remains

@codedogQBY

Copy link
Copy Markdown
Owner Author

补充一份更细的验证 checklist,方便合并前复核:

已执行:

  • PASS biome check packages/app-expo/src/screens/reader/ReaderTOCPanel.tsx:TOC 面板 touched file 检查通过。
  • PASS git diff --check:无空白/补丁格式问题。

已知阻塞,不归这个 PR:

  • BLOCKED packages/app-expo/node_modules/.bin/tsc -p packages/app-expo/tsconfig.json --noEmit:仓库当前缺 base64-js@smithy/protocol-http@smithy/querystring-builder
  • BLOCKED biome check packages/app-expo/src/screens/ReaderScreen.tsx packages/app-expo/src/screens/reader/ReaderTOCPanel.tsxReaderScreen.tsx 仍有既有 lint backlog;ReaderTOCPanel.tsx 本身通过。

建议真机回归:

  • Android 打开 1000-2000 章书籍目录,确认打开/关闭不再明显等待 2-4s。
  • 在第 1200/2000 章附近打开目录,确认自动定位到当前章节附近,而不是从第一章开始。
  • 验证折叠/展开、多级目录、书签 tab 切换、点击目录跳转后当前章节高亮仍正确。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 安卓客户端-打开目录 [Suggestion] 定位目录

1 participant