From 439bfdbfb54714feaaf37bb00377c6fb1f9bc12b Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sun, 17 Dec 2023 04:39:54 -0800 Subject: refactor(manga): move database --- src/lib/List/Manga/MangaListTemplate.svelte | 2 +- src/lib/Media/Manga/database.ts | 22 ++++++++++++++++++++++ src/lib/Media/chapters.ts | 22 ---------------------- src/lib/Media/manga.ts | 2 +- 4 files changed, 24 insertions(+), 24 deletions(-) create mode 100644 src/lib/Media/Manga/database.ts delete mode 100644 src/lib/Media/chapters.ts diff --git a/src/lib/List/Manga/MangaListTemplate.svelte b/src/lib/List/Manga/MangaListTemplate.svelte index b0179ca1..192943fd 100644 --- a/src/lib/List/Manga/MangaListTemplate.svelte +++ b/src/lib/List/Manga/MangaListTemplate.svelte @@ -4,7 +4,7 @@ import { onDestroy, onMount } from 'svelte'; import { chapterCount, pruneAllManga } from '$lib/Media/manga'; import manga from '../../../stores/manga'; - import { chapterDatabase } from '$lib/Media/chapters'; + import { chapterDatabase } from '$lib/Media/Manga/database'; import settings from '../../../stores/settings'; import lastPruneTimes from '../../../stores/lastPruneTimes'; import ListTitle from '../ListTitle.svelte'; diff --git a/src/lib/Media/Manga/database.ts b/src/lib/Media/Manga/database.ts new file mode 100644 index 00000000..a8a4d716 --- /dev/null +++ b/src/lib/Media/Manga/database.ts @@ -0,0 +1,22 @@ +import Dexie, { type Table } from 'dexie'; + +export interface Chapter { + id: number; + chapters: number | null; + volumes: number | null; +} + +export class ChapterDatabase extends Dexie { + chapters: Table; + + constructor() { + super('chapterDatabase'); + this.version(1).stores({ + chapters: 'id, chapters, volumes' + }); + + this.chapters = this.table('chapters'); + } +} + +export const chapterDatabase = new ChapterDatabase(); diff --git a/src/lib/Media/chapters.ts b/src/lib/Media/chapters.ts deleted file mode 100644 index a8a4d716..00000000 --- a/src/lib/Media/chapters.ts +++ /dev/null @@ -1,22 +0,0 @@ -import Dexie, { type Table } from 'dexie'; - -export interface Chapter { - id: number; - chapters: number | null; - volumes: number | null; -} - -export class ChapterDatabase extends Dexie { - chapters: Table; - - constructor() { - super('chapterDatabase'); - this.version(1).stores({ - chapters: 'id, chapters, volumes' - }); - - this.chapters = this.table('chapters'); - } -} - -export const chapterDatabase = new ChapterDatabase(); diff --git a/src/lib/Media/manga.ts b/src/lib/Media/manga.ts index 8842d9d9..a79445ae 100644 --- a/src/lib/Media/manga.ts +++ b/src/lib/Media/manga.ts @@ -2,7 +2,7 @@ import { recentMediaActivities, type Media } from '$lib/AniList/media'; import manga from '../../stores/manga'; import settings from '../../stores/settings'; import type { UserIdentity } from '../AniList/identity'; -import { chapterDatabase } from './chapters'; +import { chapterDatabase } from './Manga/database'; export const pruneAllManga = async () => { const all = await chapterDatabase.chapters.toArray(); -- cgit v1.2.3