Trigger library search on artist/author click (#939)
* add search func * Fix lint issues and clean up --------- Co-authored-by: schroda <50052685+schroda@users.noreply.github.com>
This commit is contained in:
@@ -27,6 +27,8 @@ import { MANGA_BASE_FIELDS } from '@/lib/graphql/fragments/MangaFragments.ts';
|
||||
import { MetadataMigrationSettings } from '@/modules/migration/Migration.types.ts';
|
||||
import {
|
||||
MangaAction,
|
||||
MangaArtistInfo,
|
||||
MangaAuthorInfo,
|
||||
MangaDownloadInfo,
|
||||
MangaGenreInfo,
|
||||
MangaIdInfo,
|
||||
@@ -92,6 +94,8 @@ type PerformActionOptions<Action extends MangaAction> = Action extends 'mark_as_
|
||||
|
||||
type MigrateFuncReturn = { copy: () => Promise<unknown>[]; cleanup: () => Promise<unknown>[] };
|
||||
|
||||
const ARTIST_AUTHOR_SEPARATOR_REGEX = /\s*[,|、]\s*/;
|
||||
|
||||
export class Mangas {
|
||||
static getIds(mangas: MangaIdInfo[]): number[] {
|
||||
return mangas.map((manga) => manga.id);
|
||||
@@ -592,4 +596,12 @@ export class Mangas {
|
||||
Mangas.isType(manga, MangaType.MANHUA)
|
||||
);
|
||||
}
|
||||
|
||||
static getArtists<Manga extends MangaArtistInfo>(manga: Manga): string[] | undefined {
|
||||
return manga.artist?.split(ARTIST_AUTHOR_SEPARATOR_REGEX);
|
||||
}
|
||||
|
||||
static getAuthors<Manga extends MangaAuthorInfo>(manga: Manga): string[] | undefined {
|
||||
return manga.author?.split(ARTIST_AUTHOR_SEPARATOR_REGEX);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user