Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/komga sync enhancement #100

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Settings" ADD COLUMN "komgaLibraries" TEXT[] DEFAULT ARRAY[]::TEXT[];
1 change: 1 addition & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ model Settings {
komgaHost String?
komgaUser String?
komgaPassword String?
komgaLibraries String[] @default([])
kavitaEnabled Boolean @default(false)
kavitaHost String?
kavitaUser String?
Expand Down
32 changes: 32 additions & 0 deletions src/components/settings/integration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,38 @@ export function IntegrationSettings() {
initialValue={settings.data.appConfig.komgaPassword}
/>
</Group>
<Group position="apart" className={classes.item} spacing="xl" noWrap>
<Box>
<Breadcrumbs
separator="/"
styles={{
separator: {
marginLeft: 4,
marginRight: 4,
},
breadcrumb: {
textTransform: 'capitalize',
fontSize: 13,
fontWeight: 500,
},
root: {
marginBottom: 5,
},
}}
>
Libraries
</Breadcrumbs>
<Text size="xs" color="dimmed">
Scan specific Komga libraries
</Text>
</Box>
<ArrayItem
configKey="komgaLibraries"
onUpdate={handleUpdate}
initialValue={settings.data.appConfig.komgaLibraries}
itemName="Library"
/>
</Group>
</Accordion.Panel>
</Accordion.Item>

Expand Down
19 changes: 12 additions & 7 deletions src/server/utils/integration/komga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { sanitizer } from '../../../utils';
import { prisma } from '../../db/client';

interface Library {
name: string;
id: string;
}

Expand Down Expand Up @@ -32,14 +33,18 @@ export const scanLibrary = async () => {
})
).json();

const includedLibraries = settings.komgaLibraries;

await Promise.all(
libraries.map(async (library) => {
const komgaLibraryUrl = new URL(`/api/v1/libraries/${library.id}/scan`, baseKomgaUrl).href;
await fetch(komgaLibraryUrl, {
method: 'POST',
headers,
});
}),
libraries
.filter((library) => (includedLibraries.length > 0 ? includedLibraries.includes(library.name) : library.name))
.map(async (library) => {
const komgaLibraryUrl = new URL(`/api/v1/libraries/${library.id}/scan`, baseKomgaUrl).href;
await fetch(komgaLibraryUrl, {
method: 'POST',
headers,
});
}),
);
}
};
Expand Down