This commit is contained in:
User
2025-01-06 12:58:10 -05:00
parent 489e054614
commit 721192fce7
23 changed files with 227 additions and 197 deletions

View File

@@ -64,8 +64,8 @@ class ComicController extends Controller
public function postFavourite(Request $request): JsonResponse
{
try {
// Get pathname to comic_id
$comic = Comic::where('pathword', $request->pathword)->firstOrFail();
// Get pathname to comic_id, if metadata is null, also do fetching
$comic = Comic::where('pathword', $request->pathword)->whereNotNull('metadata')->firstOrFail();
} catch (ModelNotFoundException $e) {
// Fetch from remote
$remoteComic = $this->copyManga->comic($request->pathword);
@@ -345,9 +345,13 @@ class ComicController extends Controller
// Update history
$request->user()->readingHistories()->attach($chapterObj->id, ['comic_id' => $comicObj->id]);
// Get chapters from DB
$chapters = $comicObj->chapters()->where('metadata->group_path_word', $chapter['chapter']['group_path_word'])->orderBy('order')->get(['name', 'chapter_uuid']);
return Inertia::render('Comic/Read', [
'comic' => $this->scToZh($comic),
'chapter' => $this->scToZh($chapter),
'chapters' => $this->scToZh($chapters),
]);
}
@@ -385,6 +389,13 @@ class ComicController extends Controller
return redirect()->route('comics.histories');
}
/**
* Remove histories for specified comic
*
* @param Request $request
* @param string $pathword
* @return Response
*/
public function destroyHistory(Request $request, string $pathword): Response
{
$comicId = Comic::where('pathword', $pathword)->firstOrFail(['id'])->id;
@@ -399,6 +410,12 @@ class ComicController extends Controller
]);
}
/**
* Remove duplicated records
*
* @param Request $request
* @return RedirectResponse
*/
public function destroyHistories(Request $request): RedirectResponse
{
$result = $request->user()->cleanUpReadingHistories();