diff --git a/assets/vue/app/domain/manga/application/store/mangaStore.js b/assets/vue/app/domain/manga/application/store/mangaStore.js
index d486e8f..b060ede 100644
--- a/assets/vue/app/domain/manga/application/store/mangaStore.js
+++ b/assets/vue/app/domain/manga/application/store/mangaStore.js
@@ -28,6 +28,11 @@ export const useMangaStore = defineStore('manga', {
// mais les données détaillées ne sont plus stockées ici.
currentMangaId: null,
+ // --- Manga Chapters State ---
+ mangaChapters: {},
+ loadingChapters: false,
+ chaptersError: null,
+
// --- Search State ---
searchResults: [],
loadingSearch: false,
@@ -86,6 +91,60 @@ export const useMangaStore = defineStore('manga', {
this.currentMangaId = null;
},
+ // --- Chapters Actions ---
+ async loadChapters(mangaId) {
+ if (this.loadingChapters) return;
+ this.loadingChapters = true;
+ this.chaptersError = null;
+
+ try {
+ const chaptersData = await mangaRepository.getChapters(mangaId);
+ this.mangaChapters[mangaId] = chaptersData;
+ } catch (err) {
+ this.chaptersError = err.message;
+ } finally {
+ this.loadingChapters = false;
+ }
+ },
+
+ updateChapterAvailability(chapterId, isAvailable = true) {
+ console.log(`Mise à jour du chapitre ${chapterId}, disponible: ${isAvailable}`);
+
+ // Pour chaque manga dans notre store
+ Object.keys(this.mangaChapters).forEach(mangaId => {
+ const chaptersObj = this.mangaChapters[mangaId];
+ if (!chaptersObj || !chaptersObj.items) return;
+
+ const chapters = chaptersObj.items;
+
+ // Chercher le chapitre correspondant
+ const chapterIndex = chapters.findIndex(chapter => chapter.id === chapterId);
+
+ // Si on trouve le chapitre, mettre à jour son état
+ if (chapterIndex !== -1) {
+ console.log(`Chapitre trouvé dans le manga ${mangaId}, index: ${chapterIndex}`);
+
+ // Important: créer une nouvelle référence pour que Vue détecte le changement
+ const updatedChapter = {
+ ...chapters[chapterIndex],
+ isAvailable: isAvailable
+ };
+
+ // Créer un nouveau tableau pour garantir la réactivité
+ const updatedChapters = [...chapters];
+ updatedChapters[chapterIndex] = updatedChapter;
+
+ // Mise à jour reactive du store
+ this.mangaChapters[mangaId] = {
+ ...chaptersObj,
+ items: updatedChapters
+ };
+
+ console.log('Chapitre mis à jour avec succès');
+ }
+ });
+ },
+
// --- Search Actions ---
async searchMangaDex(query) {
if (this.loadingSearch) return;
@@ -130,16 +189,13 @@ export const useMangaStore = defineStore('manga', {
}
},
- // --- Chapter Actions ---
+ // --- Scrape Chapter Action ---
async searchChapter(chapterId) {
try {
await mangaRepository.searchChapter(chapterId);
- // Rafraîchir la collection après la recherche
- await this.refreshCollectionInBackground();
- return true;
} catch (error) {
console.error('Erreur lors de la recherche du chapitre:', error);
- return false;
+ throw error;
}
}
}
diff --git a/assets/vue/app/domain/manga/presentation/components/MangaChapter.vue b/assets/vue/app/domain/manga/presentation/components/MangaChapter.vue
index 0cbd1b2..cf5c9c2 100644
--- a/assets/vue/app/domain/manga/presentation/components/MangaChapter.vue
+++ b/assets/vue/app/domain/manga/presentation/components/MangaChapter.vue
@@ -11,14 +11,13 @@
params: {
chapterId: chapter.id
}
- }"
- class="text-green-500">
+ }">
{{ chapter.title || 'Sans titre' }}
{{ chapter.title || 'Sans titre' }}
- |