From cc0a332f028589ec5c3d54a2cad5c523326d9ba2 Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Sat, 13 Jul 2024 15:54:43 +0200 Subject: [PATCH] Improve duplicate detection by title Some mangas might be the same but didn't get detected because they had different symbols (e.g. "'" instead of "`") --- src/screens/settings/LibraryDuplicates.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/screens/settings/LibraryDuplicates.tsx b/src/screens/settings/LibraryDuplicates.tsx index 6df0eefa..936087ab 100644 --- a/src/screens/settings/LibraryDuplicates.tsx +++ b/src/screens/settings/LibraryDuplicates.tsx @@ -37,10 +37,16 @@ import { BaseMangaGrid } from '@/components/source/BaseMangaGrid.tsx'; import { IMangaGridProps } from '@/components/MangaGrid.tsx'; import { StyledGroupItemWrapper } from '@/components/virtuoso/StyledGroupItemWrapper.tsx'; +const cleanupTitle = (title: string): string => + title + .toLowerCase() + .trim() + .replace(/[^a-zA-Z0-9]/g, ''); + const findDuplicatesByTitle = >( libraryMangas: Manga[], ): Record => { - const titleToMangas = Object.groupBy(libraryMangas, ({ title }) => title.toLowerCase().trim()); + const titleToMangas = Object.groupBy(libraryMangas, ({ title }) => cleanupTitle(title)); return Object.fromEntries( Object.entries(titleToMangas) @@ -63,10 +69,10 @@ const findDuplicatesByTitleAndAlternativeTitles =