mirror of
https://github.com/bookorbit/bookorbit.git
synced 2026-11-03 00:11:37 -06:00
fix(storygraph): skip progress sync on read transition
Updating status to read on StoryGraph automatically logs the remaining page count. Sending a subsequent progress update for the full book page count would create a duplicate journal entry, inflating the logged page count. Skip the progress update when transitioning to the read status. Closes #643
This commit is contained in:
@@ -312,6 +312,15 @@ describe('StorygraphSyncService', () => {
|
||||
|
||||
await expect(makeService().syncBook(1, 1)).resolves.toBe('synced');
|
||||
expect(mockMatchService.matchBook).toHaveBeenCalled();
|
||||
expect(mockClient.post).toHaveBeenCalledTimes(1);
|
||||
expect(mockClient.post).toHaveBeenCalledWith(
|
||||
1,
|
||||
cookies,
|
||||
expect.stringContaining('/update-status.js?book_id=abc-123&status=read'),
|
||||
{},
|
||||
'csrf-token',
|
||||
);
|
||||
expect(mockClient.post).not.toHaveBeenCalledWith(1, cookies, '/update-progress', expect.anything(), 'csrf-token');
|
||||
});
|
||||
|
||||
it('skips unselected books when sync mode is selected-only', async () => {
|
||||
|
||||
@@ -470,7 +470,9 @@ export class StorygraphSyncService {
|
||||
try {
|
||||
await this.updateStatus(userId, cookies, match.storygraphBookId, storygraphStatus);
|
||||
|
||||
if (book.progress != null) {
|
||||
// StoryGraph's read transition logs the remaining pages. A subsequent progress update
|
||||
// would create another journal entry for the full page count.
|
||||
if (book.progress != null && storygraphStatus !== STORYGRAPH_STATUS.READ) {
|
||||
await this.updateProgress(userId, cookies, match.storygraphBookId, book.progress);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user