ux: process synced books in update time ascending order (#337)

This commit is contained in:
Huang Xin
2025-02-09 18:58:56 +01:00
committed by GitHub
parent effbc08561
commit 8e7240bb9b
@@ -74,6 +74,8 @@ export const useBooksSync = ({ onSyncStart, onSyncEnd }: UseBooksSyncProps) => {
const updateLibrary = async () => {
if (!syncedBooks?.length) return;
// Process old books first so that when we update the library the order is preserved
syncedBooks.sort((a, b) => a.updatedAt - b.updatedAt);
const processOldBook = async (oldBook: Book) => {
const matchingBook = syncedBooks.find((newBook) => newBook.hash === oldBook.hash);