Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion apps/server/src/annotations/annotations-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,16 @@ export class AnnotationsRepository {
.onConflict(['book_md5', 'device_id', 'page_ref', 'datetime'])
// Only update fields that users can actually change in KoReader
// Do NOT update pageno/total_pages - these are historical context!
.merge(['text', 'note', 'datetime_updated', 'chapter', 'updated_at', 'drawer', 'color']);
.merge([
'text',
'note',
'datetime_updated',
'chapter',
'updated_at',
'drawer',
'color',
'deleted_at',
]);
}
};

Expand Down
12 changes: 3 additions & 9 deletions apps/server/src/upload/upload-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,10 @@ export class UploadService {
)
);

const bookMd5s = newBooks.map((b) => b.md5).filter((md5): md5 is string => !!md5);

// FIXME: with this, if there is only 1 annotation and it gets removed, it won't get marked as deleted, because `annotationsByBook` will be empty. It will only get marked as deleted if the user adds another annotation to trigger an update on the book.
await Promise.all(
bookMd5s.map((bookMd5) =>
this.detectAndMarkDeletedAnnotations(
bookMd5,
deviceId,
annotationsByBook[bookMd5] || [],
trx
)
Object.entries(annotationsByBook).map(([bookMd5, annotations]) =>
this.detectAndMarkDeletedAnnotations(bookMd5, deviceId, annotations, trx)
)
);
}
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
],
"scripts": {
"build": "turbo run build",
"test:coverage": "turbo run test:coverage"
"test:coverage": "turbo run test:coverage",
"dev": "turbo run dev --parallel"
},
"devDependencies": {
"prettier": "3.6.2",
Expand Down