fix: removing too soon from ls, bad page on mark as unread

This commit is contained in:
Julien Froidefond
2025-03-23 15:19:05 +01:00
parent a964e0960c
commit 7834003482

View File

@@ -22,7 +22,6 @@ export function MarkAsUnreadButton({ bookId, onSuccess, className }: MarkAsUnrea
e.stopPropagation(); // Empêcher la propagation au parent e.stopPropagation(); // Empêcher la propagation au parent
setIsLoading(true); setIsLoading(true);
try { try {
ClientOfflineBookService.removeCurrentPageById(bookId);
const response = await fetch(`/api/komga/books/${bookId}/read-progress`, { const response = await fetch(`/api/komga/books/${bookId}/read-progress`, {
method: "DELETE", method: "DELETE",
}); });
@@ -31,6 +30,9 @@ export function MarkAsUnreadButton({ bookId, onSuccess, className }: MarkAsUnrea
throw new Error(t("books.actions.markAsUnread.error.update")); throw new Error(t("books.actions.markAsUnread.error.update"));
} }
// On supprime la page courante du localStorage seulement après que l'API a répondu
ClientOfflineBookService.removeCurrentPageById(bookId);
toast({ toast({
title: t("books.actions.markAsUnread.success.title"), title: t("books.actions.markAsUnread.success.title"),
description: t("books.actions.markAsUnread.success.description"), description: t("books.actions.markAsUnread.success.description"),