Repository navigation
fix(chapters): don't flag re-dated chapters as updates; format dates - #2111
blackstargit wants to merge 1 commit into
Conversation
Library update marked any changed chapter as updated, so a plugin that starts sending release dates (or one whose date fetch fails now and then) put every chapter of every novel into Updates and fired the per-row stats trigger for each. - An empty incoming releaseTime keeps the stored one. - updatedTime is left out of the ON CONFLICT SET; existing chapters are only marked updated when renamed (e.g. a "🔒" locked marker removed), marked before the upsert so a crash in between can't lose it. New chapters are still marked on insert. - Chapter drawer and jump-to-chapter modal format releaseTime with formatDate, like the novel chapter list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
[Medium impact] The changes affect library chapter updates and two chapter-navigation views. The PR appears safe to merge, with two non-blocking test improvements. FindingsSummaryThe PR stops date and ordering changes from creating Updates entries. New and renamed chapters still receive
Acknowledged intent from Reviews (1) · Last reviewed commit: "fix(chapters): don't flag re-dated chapt..." · Reviewed by Greptile |
| await insertChapters( | ||
| novelId, | ||
| [{ path: '/chapter/1', name: 'Chapter 1', releaseTime: '' }], | ||
| touch, | ||
| ); |
There was a problem hiding this comment.
Date preservation test skips updates
All other fields match, so the new where condition skips this row. The test would still pass if set.releaseTime reverted to excluded.releaseTime, leaving date loss during an actual update unchecked. Change another field, such as page, and assert that it changes while the stored date stays intact.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| const { rerender } = renderChapter({ | ||
| ...chapter, | ||
| releaseTime: '2024-03-05T10:20:30.000Z', | ||
| }); | ||
| expect(screen.queryByText('2024-03-05T10:20:30.000Z')).toBeNull(); |
There was a problem hiding this comment.
The ISO-date check only proves that the raw string disappeared. It also passes if valid dates render as blank text. Pass an explicit dateFormat with relativeTimestamps={false} and assert the expected date is visible. Keep the existing non-date check.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
fix(chapters): don't flag re-dated chapters as updates; format dates
Problem
A library update marks an existing chapter as updated (
updatedTime = now) whenever any field differs:release time, position, page or chapter number. The Updates tab lists every chapter with
updatedTime, so:every chapter of every novel from that source lands in Updates on the next library update.
releaseTimebetween a value and'', which floods Updatesagain on every failure and every recovery.
update_novel_stats_on_updatetrigger, which rescans the novel's chapters.That makes it O(n²) per novel for large libraries.
Change (
insertChapters)releaseTimekeeps the stored one:COALESCE(NULLIF(excluded.releaseTime, ''), Chapter.releaseTime).updatedTimeis removed from theON CONFLICT DO UPDATE SET. Naming it there fires the trigger even whenthe value is unchanged.
plugin drops its "🔒" locked marker when a chapter unlocks). The rename mark is written before the upsert,
so a crash in between can't lose it.
releaseTimewithformatDate, like thenovel chapter list. They used to print the raw string.
Tests
ChapterQueries.test.ts:''→ ISO fills the date without marking an update;''keeps the stored date;RenderListChaptertest: an ISO date is formatted, and a non-date string is shown unchanged.tscclean;jest --selectProjects rn460/460. Tested on a device (Pixel 9 Pro XL, Android 17) with mylibrary and the WebNovel plugin 1.1.0.
Notes
''/null. That's intentional.