From 721192fce77ca48d0f461efa4d951b8f2fa98fb4 Mon Sep 17 00:00:00 2001 From: User Date: Mon, 6 Jan 2025 12:58:10 -0500 Subject: [PATCH] 0.1.1 --- app/Helper/Timezones.php | 1 - .../Auth/AuthenticatedSessionController.php | 2 +- .../Auth/ConfirmablePasswordController.php | 2 +- ...mailVerificationNotificationController.php | 2 +- .../EmailVerificationPromptController.php | 2 +- .../Auth/RegisteredUserController.php | 2 +- .../Auth/VerifyEmailController.php | 4 +- app/Http/Controllers/ComicController.php | 21 +- app/Http/Controllers/ProfileController.php | 1 - app/Http/Requests/ProfileUpdateRequest.php | 2 +- app/Models/User.php | 14 +- composer.lock | 15 +- resources/js/Layouts/AppLayout.jsx | 21 +- resources/js/Pages/Comic/Chapters.jsx | 22 +- resources/js/Pages/Comic/Favourites.jsx | 26 +-- resources/js/Pages/Comic/Histories.jsx | 30 ++- resources/js/Pages/Comic/Index.jsx | 2 +- resources/js/Pages/Comic/Read.jsx | 203 ++++++++++-------- resources/js/Pages/Pages/Installation.jsx | 2 +- resources/js/Pages/Pages/Updates.jsx | 14 ++ resources/js/Pages/Profile/Edit.jsx | 4 +- .../Pages/Profile/Partials/DeleteUserForm.jsx | 30 ++- resources/js/components/ui/app-sidebar.jsx | 2 +- 23 files changed, 227 insertions(+), 197 deletions(-) diff --git a/app/Helper/Timezones.php b/app/Helper/Timezones.php index 4e5a769..15428b2 100644 --- a/app/Helper/Timezones.php +++ b/app/Helper/Timezones.php @@ -37,5 +37,4 @@ class Timezones return $tzForSelect; } - } diff --git a/app/Http/Controllers/Auth/AuthenticatedSessionController.php b/app/Http/Controllers/Auth/AuthenticatedSessionController.php index d44fe97..ea99bc4 100644 --- a/app/Http/Controllers/Auth/AuthenticatedSessionController.php +++ b/app/Http/Controllers/Auth/AuthenticatedSessionController.php @@ -33,7 +33,7 @@ class AuthenticatedSessionController extends Controller $request->session()->regenerate(); - return redirect()->intended(route('dashboard', absolute: false)); + return redirect()->intended(route('comics.index')); } /** diff --git a/app/Http/Controllers/Auth/ConfirmablePasswordController.php b/app/Http/Controllers/Auth/ConfirmablePasswordController.php index d2b1f14..51575bb 100644 --- a/app/Http/Controllers/Auth/ConfirmablePasswordController.php +++ b/app/Http/Controllers/Auth/ConfirmablePasswordController.php @@ -36,6 +36,6 @@ class ConfirmablePasswordController extends Controller $request->session()->put('auth.password_confirmed_at', time()); - return redirect()->intended(route('dashboard', absolute: false)); + return redirect()->intended(route('comics.index')); } } diff --git a/app/Http/Controllers/Auth/EmailVerificationNotificationController.php b/app/Http/Controllers/Auth/EmailVerificationNotificationController.php index f64fa9b..7264e7d 100644 --- a/app/Http/Controllers/Auth/EmailVerificationNotificationController.php +++ b/app/Http/Controllers/Auth/EmailVerificationNotificationController.php @@ -14,7 +14,7 @@ class EmailVerificationNotificationController extends Controller public function store(Request $request): RedirectResponse { if ($request->user()->hasVerifiedEmail()) { - return redirect()->intended(route('dashboard', absolute: false)); + return redirect()->intended(route('comics.index')); } $request->user()->sendEmailVerificationNotification(); diff --git a/app/Http/Controllers/Auth/EmailVerificationPromptController.php b/app/Http/Controllers/Auth/EmailVerificationPromptController.php index b42e0d5..2c98319 100644 --- a/app/Http/Controllers/Auth/EmailVerificationPromptController.php +++ b/app/Http/Controllers/Auth/EmailVerificationPromptController.php @@ -16,7 +16,7 @@ class EmailVerificationPromptController extends Controller public function __invoke(Request $request): RedirectResponse|Response { return $request->user()->hasVerifiedEmail() - ? redirect()->intended(route('dashboard', absolute: false)) + ? redirect()->intended(route('comics.index')) : Inertia::render('Auth/VerifyEmail', ['status' => session('status')]); } } diff --git a/app/Http/Controllers/Auth/RegisteredUserController.php b/app/Http/Controllers/Auth/RegisteredUserController.php index a446ab9..7e0b666 100644 --- a/app/Http/Controllers/Auth/RegisteredUserController.php +++ b/app/Http/Controllers/Auth/RegisteredUserController.php @@ -48,6 +48,6 @@ class RegisteredUserController extends Controller Auth::login($user); - return redirect(route('dashboard', absolute: false)); + return redirect(route('comics.index')); } } diff --git a/app/Http/Controllers/Auth/VerifyEmailController.php b/app/Http/Controllers/Auth/VerifyEmailController.php index 784765e..0f545cc 100644 --- a/app/Http/Controllers/Auth/VerifyEmailController.php +++ b/app/Http/Controllers/Auth/VerifyEmailController.php @@ -15,13 +15,13 @@ class VerifyEmailController extends Controller public function __invoke(EmailVerificationRequest $request): RedirectResponse { if ($request->user()->hasVerifiedEmail()) { - return redirect()->intended(route('dashboard', absolute: false).'?verified=1'); + return redirect()->intended(route('comics.index')); } if ($request->user()->markEmailAsVerified()) { event(new Verified($request->user())); } - return redirect()->intended(route('dashboard', absolute: false).'?verified=1'); + return redirect()->intended(route('comics.index')); } } diff --git a/app/Http/Controllers/ComicController.php b/app/Http/Controllers/ComicController.php index 393aa68..e99d766 100644 --- a/app/Http/Controllers/ComicController.php +++ b/app/Http/Controllers/ComicController.php @@ -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(); diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index 6f98c98..46dfbac 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -43,7 +43,6 @@ class ProfileController extends Controller $settings = $request->user()->settings; $settings['timezone'] = $request->get('timezone'); $request->user()->settings = $settings; - $request->user()->save(); $request->user()->save(); diff --git a/app/Http/Requests/ProfileUpdateRequest.php b/app/Http/Requests/ProfileUpdateRequest.php index e5a56a8..c5cdf8b 100644 --- a/app/Http/Requests/ProfileUpdateRequest.php +++ b/app/Http/Requests/ProfileUpdateRequest.php @@ -12,7 +12,7 @@ class ProfileUpdateRequest extends FormRequest /** * Get the validation rules that apply to the request. * - * @return array|string> + * @return array */ public function rules(): array { diff --git a/app/Models/User.php b/app/Models/User.php index 537bbaf..aabadc8 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -71,13 +71,11 @@ class User extends Authenticatable implements MustVerifyEmail $userId = $this->id; // Step 1: Identify records to keep - $idsToKeep = ReadingHistory::query() - ->select('reading_histories.id') // Specify table name explicitly + $idsToKeep = ReadingHistory::query()->select('reading_histories.id') ->joinSub( ReadingHistory::query() ->select('comic_id', 'user_id', 'chapter_id', DB::raw('MIN(created_at) as earliest_created_at')) - ->where('user_id', $userId) // Specify user_id with table name - ->groupBy('comic_id', 'user_id', 'chapter_id'), + ->where('user_id', $userId)->groupBy('comic_id', 'user_id', 'chapter_id'), 'b', function (JoinClause $join) { $join->on('reading_histories.comic_id', '=', 'b.comic_id') @@ -85,14 +83,10 @@ class User extends Authenticatable implements MustVerifyEmail ->on('reading_histories.chapter_id', '=', 'b.chapter_id') ->on('reading_histories.created_at', '=', 'b.earliest_created_at'); } - ) - ->where('reading_histories.user_id', $userId) // Specify table name explicitly - ->pluck('id'); + )->where('reading_histories.user_id', $userId)->pluck('id'); // Step 2: Delete duplicates for the user - $deletedCount = ReadingHistory::where('user_id', $userId) - ->whereNotIn('id', $idsToKeep) - ->delete(); + $deletedCount = ReadingHistory::where('user_id', $userId)->whereNotIn('id', $idsToKeep)->delete(); // Return the result as an array return [ diff --git a/composer.lock b/composer.lock index a6a3151..e39bfe4 100644 --- a/composer.lock +++ b/composer.lock @@ -8759,16 +8759,16 @@ }, { "name": "sebastian/comparator", - "version": "6.2.1", + "version": "6.3.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "43d129d6a0f81c78bee378b46688293eb7ea3739" + "reference": "d4e47a769525c4dd38cea90e5dcd435ddbbc7115" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/43d129d6a0f81c78bee378b46688293eb7ea3739", - "reference": "43d129d6a0f81c78bee378b46688293eb7ea3739", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/d4e47a769525c4dd38cea90e5dcd435ddbbc7115", + "reference": "d4e47a769525c4dd38cea90e5dcd435ddbbc7115", "shasum": "" }, "require": { @@ -8781,6 +8781,9 @@ "require-dev": { "phpunit/phpunit": "^11.4" }, + "suggest": { + "ext-bcmath": "For comparing BcMath\\Number objects" + }, "type": "library", "extra": { "branch-alias": { @@ -8824,7 +8827,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/comparator/issues", "security": "https://github.com/sebastianbergmann/comparator/security/policy", - "source": "https://github.com/sebastianbergmann/comparator/tree/6.2.1" + "source": "https://github.com/sebastianbergmann/comparator/tree/6.3.0" }, "funding": [ { @@ -8832,7 +8835,7 @@ "type": "github" } ], - "time": "2024-10-31T05:30:08+00:00" + "time": "2025-01-06T10:28:19+00:00" }, { "name": "sebastian/complexity", diff --git a/resources/js/Layouts/AppLayout.jsx b/resources/js/Layouts/AppLayout.jsx index 4b7556e..64359fb 100644 --- a/resources/js/Layouts/AppLayout.jsx +++ b/resources/js/Layouts/AppLayout.jsx @@ -5,11 +5,11 @@ import { Moon, Sun } from 'lucide-react'; import { Separator } from '@radix-ui/react-separator'; import { Tooltip, TooltipProvider, TooltipTrigger } from '@radix-ui/react-tooltip'; -import { AppSidebar } from '@/components/ui/app-sidebar.jsx'; +import { AppSidebar } from '@/components/ui/app-sidebar'; import { Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList } from '@/components/ui/breadcrumb'; import { Button } from '@/components/ui/button'; import { SidebarInset, SidebarProvider, SidebarTrigger } from '@/components/ui/sidebar'; -import { TooltipContent } from '@/components/ui/tooltip.jsx'; +import { TooltipContent } from '@/components/ui/tooltip'; import { Toaster } from '@/components/ui/toaster'; export default function AppLayout({ auth, header, children, toolbar }) { @@ -59,17 +59,12 @@ export default function AppLayout({ auth, header, children, toolbar }) { - - { theme === 'dark' && ( - - ) } - { theme === 'light' && ( - - ) } + + { theme === 'dark' ? () : () }

Toggle day / night mode

diff --git a/resources/js/Pages/Comic/Chapters.jsx b/resources/js/Pages/Comic/Chapters.jsx index 11830b3..88cf7b6 100644 --- a/resources/js/Pages/Comic/Chapters.jsx +++ b/resources/js/Pages/Comic/Chapters.jsx @@ -50,10 +50,12 @@ export default function Chapters({ auth, comic, chapters, histories, offset }) { const groupOnClickHandler = (pathword) => { router.get(`/comic/${ comic.comic.path_word }?group=${ pathword }`, {}, { only: ['chapters'], - preserveState: true + preserveState: true, + onSuccess: () => { + setGroup(pathword); + setAscending(true); + } }); - setGroup(pathword); - setAscending(true); } const ComicChapterLink = (props) => { @@ -160,16 +162,17 @@ export default function Chapters({ auth, comic, chapters, histories, offset }) { - + groupOnClickHandler(e)} >
{ Object.entries(comic.groups).map((g, i) => ( - groupOnClickHandler(g[1].path_word) } - key={ g[1].path_word } - value={ g[1].path_word }> + { g[1].name } + + { g[1].count } + - )) } + ) ) }
@@ -200,7 +203,8 @@ export default function Chapters({ auth, comic, chapters, histories, offset }) {
-
+
{ (chapters.total > chapters.limit && chapters.offset > 0) && ( - - -

Options

-
- - + + @@ -157,6 +163,54 @@ export default function Read({ auth, comic, chapter }) { onCheckedChange={ (e) => toggleReadingMode(e) } />
+
+
+
+ +

Only applicable to RTL mode

+
+ toggleTwoPagesPerScreen(e) } /> +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
Done @@ -165,67 +219,10 @@ export default function Read({ auth, comic, chapter }) { - - - - - - - - -

Jump To

-
-
-
-
- - - Jump to - - - - -
- -
- - - setIsJumpToPageOpen(false) }>Done - - -
-
- - - - - - - -

TOC

-
-
-
- { chapter.chapter.prev && ( - + + + +

TOC

+
+
+
+ { chapter.chapter.next && ( - +