Skip to content

fix(reader): save reading progress with 0.5s debounce on page change - #368

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
add-uos:fix-375997-debounce-reading-progress-save
Sep 7, 2026
Merged

fix(reader): save reading progress with 0.5s debounce on page change#368
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
add-uos:fix-375997-debounce-reading-progress-save

Conversation

@add-uos

@add-uos add-uos commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Page changes only updated m_operation.currentPage in memory; progress was persisted only on bookmark/annotation ops, every 30s auto-save or clean close, so killall lost the last page position while bookmarks survived. Start a single-shot debounce timer (500ms, restarted on each page change so bursts coalesce) that calls saveProgressToDb(); the database runs in WAL with synchronous=FULL, so the save survives abnormal termination.

页面切换仅在内存更新当前页,阅读进度此前只在书签/注释操作、30秒自动
保存、正常关闭时落盘,killall 杀进程会丢失最新进度而书签已保存。
新增 0.5 秒防抖定时器(每次页面切换重启计时,连续变化自动合并),
超时后经 saveProgressToDb() 落盘;数据库为 WAL+synchronous=FULL, 异常退出后进度不丢。

Log: 页面切换后防抖保存阅读进度,异常退出进度不丢
PMS: BUG-375997
Influence: 翻页后 0.5 秒自动落盘阅读进度,killall 等异常退出进度可恢复;正常关闭流程行为不变。

Summary by Sourcery

Persist reading progress after page changes to prevent the latest position from being lost on abnormal exit.

Bug Fixes:

  • Persist reading progress shortly after page changes so the latest position survives abnormal process termination.

Enhancements:

  • Coalesce rapid page changes with a single-shot debounce while preserving immediate saves during normal shutdown.

Page changes only updated m_operation.currentPage in memory; progress
was persisted only on bookmark/annotation ops, every 30s auto-save or
clean close, so killall lost the last page position while bookmarks
survived. Start a single-shot debounce timer (500ms, restarted on each
page change so bursts coalesce) that calls saveProgressToDb(); the
database runs in WAL with synchronous=FULL, so the save survives
abnormal termination.

页面切换仅在内存更新当前页,阅读进度此前只在书签/注释操作、30秒自动
保存、正常关闭时落盘,killall 杀进程会丢失最新进度而书签已保存。
新增 0.5 秒防抖定时器(每次页面切换重启计时,连续变化自动合并),
超时后经 saveProgressToDb() 落盘;数据库为 WAL+synchronous=FULL,
异常退出后进度不丢。

Log: 页面切换后防抖保存阅读进度,异常退出进度不丢
PMS: BUG-375997
Influence: 翻页后 0.5 秒自动落盘阅读进度,killall 等异常退出进度可恢复;正常关闭流程行为不变。

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @add-uos, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 3 days and 4 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@sourcery-ai

sourcery-ai Bot commented Sep 7, 2026

Copy link
Copy Markdown

Reviewer's Guide

Reading progress is now persisted 500 ms after the latest page change via a single-shot debounce timer, reducing the window in which abnormal termination can lose the current page while preserving existing auto-save and clean-close behavior.

Sequence diagram for debounced reading progress persistence

sequenceDiagram
    participant Reader as Reader UI
    participant DocSheet
    participant Timer as m_progressSaveTimer
    participant DB as Progress database

    Reader->>DocSheet: onBrowserPageChanged(page)
    DocSheet->>DocSheet: update m_operation.currentPage
    DocSheet->>Timer: start()
    Note over Timer: Single-shot 500 ms timer
    opt another page change before timeout
        Reader->>DocSheet: onBrowserPageChanged(page)
        DocSheet->>Timer: start()
    end
    Timer->>DocSheet: saveProgressToDb()
    DocSheet->>DB: persist current reading progress
Loading

File-Level Changes

Change Details Files
Add a single-shot, restartable debounce timer to persist the current reading page after navigation changes.
  • Create a 500 ms parented QTimer connected to saveProgressToDb().
  • Restart the timer whenever the browser page changes, coalescing rapid navigation events.
  • Stop the debounce timer during shutdown after the existing immediate save path runs.
  • Document the timer and debounce interval alongside the progress persistence API and state.
reader/uiframe/DocSheet.cpp
reader/uiframe/DocSheet.h

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: add-uos, lzwind

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 100 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 未发现安全问题,代码实现与修复目的一致,防抖定时器方案合理,语法正确且性能良好

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议:


2. 代码质量 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议:


3. 代码性能 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议:


4. 代码安全 🔒

评价: 优秀 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议:


💡 改进建议代码示例

// 代码实现良好,无需修改

本报告由 AI 代码审查工具自动生成

@add-uos

add-uos commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

/merge

@deepin-bot
deepin-bot Bot merged commit 8b77188 into linuxdeepin:master Sep 7, 2026
9 checks passed
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.

3 participants