Skip to content

Commit bd5cdc6

Browse files
committed
bug fixes
1 parent 95f572d commit bd5cdc6

File tree

5 files changed

+20
-155
lines changed

5 files changed

+20
-155
lines changed

src/Komga/forms/server_settings_form.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,13 @@ export class ServerSettingsForm extends Form {
8383
override async formDidSubmit(): Promise<void> {
8484
const { error, response } = await getCurrentUser({
8585
baseUrl: this.baseUrl,
86-
auth: `${this.credentials.username}:${this.credentials.password}`,
86+
auth: (auth) => {
87+
if (auth.scheme === 'basic') {
88+
return `${this.credentials.username}:${this.credentials.password}`
89+
} else {
90+
return undefined
91+
}
92+
},
8793
})
8894

8995
if (!error) {

src/Komga/interceptors/image_interceptor.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,13 @@ import { getKomgaCredentials } from '../utils/config.js'
77

88
export class KomgaImageInterceptor extends PaperbackInterceptor {
99
override async interceptRequest(request: Request): Promise<Request> {
10-
console.log(request.url)
11-
12-
// if (!request.url.includes('thumbnail')) {
13-
// return request
14-
// }
10+
// Normally auth is handled by the sdk. We only want to inject headers if they're not present
11+
if (request.headers!['Authorization'] !== undefined) {
12+
return request
13+
}
1514

1615
const { username, password } = getKomgaCredentials()
17-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
18-
request.headers!['Authorization'] =
19-
'Basic ' + btoa(`${username}:${password}`)
20-
21-
console.log(request.headers!['Authorization'])
16+
request.headers!['Authorization'] = 'Basic ' + btoa(`${username}:${password}`)
2217

2318
return request
2419
}

src/Komga/komga.ts

Lines changed: 5 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,7 @@ export class KomgaExtension implements IKomgaExtension {
9090
baseUrl: getKomgaBaseURL(),
9191
auth(auth) {
9292
const { username, password } = getKomgaCredentials()
93-
console.log(JSON.stringify(auth))
94-
console.log(username)
95-
console.log(password)
96-
93+
9794
if (auth.type == 'http' && auth.scheme == 'basic') {
9895
return `${username}:${password}`
9996
}
@@ -497,7 +494,7 @@ export class KomgaExtension implements IKomgaExtension {
497494
}
498495
}
499496
case 'continueReading': {
500-
const { data, error } = await getBooksList({
497+
const { data, error } = await getSeriesList({
501498
query: { sort: ['readProgress.readDate,desc'], page: metadata?.page },
502499
body: {
503500
condition: {
@@ -513,13 +510,13 @@ export class KomgaExtension implements IKomgaExtension {
513510

514511
const items: DiscoverSectionItem[] = []
515512
for (const serie of data.content ?? []) {
516-
const thumbnailUrl = `${client.getConfig().baseUrl}/api/v1/books/${serie.id}/thumbnail`
513+
const thumbnailUrl = `${client.getConfig().baseUrl}/api/v1/series/${serie.id}/thumbnail`
517514

518515
items.push({
519516
type: 'simpleCarouselItem',
520-
title: serie.seriesTitle,
517+
title: serie.name,
521518
imageUrl: thumbnailUrl,
522-
mangaId: serie.seriesId,
519+
mangaId: serie.id,
523520
subtitle: undefined,
524521
})
525522
}
@@ -589,137 +586,3 @@ export class KomgaExtension implements IKomgaExtension {
589586
}
590587
}
591588
}
592-
593-
/*
594-
595-
override async getHomePageSections(sectionCallback: (section: HomeSection) => void): Promise<void> {
596-
// This function is called on the homepage and should not throw if the server is unavailable
597-
// We won't use `await this.getKomgaAPI()` as we do not want to throw an error on
598-
// the homepage when server settings are not set
599-
const komgaAPI = await getKomgaAPI(this.stateManager)
600-
const { showOnDeck, showContinueReading } = await getOptions(this.stateManager)
601-
if (komgaAPI === null) {
602-
console.log('searchRequest failed because server settings are unset')
603-
const section = App.createHomeSection({
604-
id: 'unset',
605-
title: 'Go to source settings to set your Komga server credentials.',
606-
items: getServerUnavailableMangaTiles(),
607-
containsMoreItems: false,
608-
type: 'singleRowNormal'
609-
})
610-
sectionCallback(section)
611-
return
612-
}
613-
// The source define two homepage sections: new and latest
614-
const sections = []
615-
if (showOnDeck) {
616-
sections.push(App.createHomeSection({
617-
id: 'ondeck',
618-
title: 'On Deck',
619-
containsMoreItems: false,
620-
type: 'singleRowNormal'
621-
}))
622-
}
623-
if (showContinueReading) {
624-
sections.push(App.createHomeSection({
625-
id: 'continue',
626-
title: 'Continue Reading',
627-
containsMoreItems: false,
628-
type: 'singleRowNormal'
629-
}))
630-
}
631-
sections.push(App.createHomeSection({
632-
id: 'new',
633-
title: 'Recently added series',
634-
containsMoreItems: true,
635-
type: 'singleRowNormal'
636-
}))
637-
sections.push(App.createHomeSection({
638-
id: 'updated',
639-
title: 'Recently updated series',
640-
containsMoreItems: true,
641-
type: 'singleRowNormal'
642-
}))
643-
const promises: Promise<void>[] = []
644-
for (const section of sections) {
645-
// Let the app load empty tagSections
646-
sectionCallback(section)
647-
let apiPath: string, thumbPath: string, params: string, idProp: keyof BookDto
648-
switch (section.id) {
649-
case 'ondeck':
650-
apiPath = `${komgaAPI}/books/${section.id}`
651-
thumbPath = `${komgaAPI}/books`
652-
params = '?page=0&size=20&deleted=false'
653-
idProp = 'seriesId'
654-
break
655-
case 'continue':
656-
apiPath = `${komgaAPI}/books`
657-
thumbPath = `${komgaAPI}/books`
658-
params = '?sort=readProgress.readDate,desc&read_status=IN_PROGRESS&page=0&size=20&deleted=false'
659-
idProp = 'seriesId'
660-
break
661-
default:
662-
apiPath = `${komgaAPI}/series/${section.id}`
663-
thumbPath = `${komgaAPI}/series`
664-
params = '?page=0&size=20&deleted=false'
665-
idProp = 'id'
666-
break
667-
}
668-
const request = App.createRequest({
669-
url: apiPath,
670-
param: params,
671-
method: 'GET'
672-
})
673-
// Get the section data
674-
promises.push((async () => {
675-
const data = await this.requestManager.schedule(request, 1)
676-
const result: PageBookDto = typeof data.data === 'string' ? JSON.parse(data.data) : data.data
677-
678-
const tiles = []
679-
if (!result.content) {
680-
return
681-
}
682-
683-
for (const serie of result.content) {
684-
tiles.push(App.createPartialSourceManga({
685-
title: serie.metadata.title,
686-
image: `${thumbPath}/${serie.id}/thumbnail`,
687-
mangaId: serie[idProp],
688-
subtitle: undefined
689-
}))
690-
}
691-
692-
section.items = tiles
693-
sectionCallback(section)
694-
})())
695-
}
696-
// Make sure the function completes
697-
await Promise.all(promises)
698-
}
699-
override async getViewMoreItems(homepageSectionId: string, metadata: any): Promise<PagedResults> {
700-
const komgaAPI = await getKomgaAPI(this.stateManager)
701-
const page: number = metadata?.page ?? 0
702-
const request = App.createRequest({
703-
url: `${komgaAPI}/series/${homepageSectionId}`,
704-
param: `?page=${page}&size=${PAGE_SIZE}&deleted=false`,
705-
method: 'GET'
706-
})
707-
const data = await this.requestManager.schedule(request, 1)
708-
const result: PageBookDto = typeof data.data === 'string' ? JSON.parse(data.data) : data.data
709-
const tiles: PartialSourceManga[] = []
710-
for (const serie of result.content ?? []) {
711-
tiles.push(App.createPartialSourceManga({
712-
title: serie.metadata.title,
713-
image: `${komgaAPI}/series/${serie.id}/thumbnail`,
714-
mangaId: serie.id,
715-
subtitle: undefined
716-
}))
717-
}
718-
// If no series were returned we are on the last page
719-
metadata = tiles.length === 0 ? undefined : { page: page + 1 }
720-
return App.createPagedResults({
721-
results: tiles,
722-
metadata: metadata
723-
})
724-
}
725-
*/

src/Komga/pbconfig.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
} from '@paperback/types'
66

77
export default {
8-
version: '2.1',
8+
version: '2.2',
99
name: 'Komga',
1010
icon: 'icon.png',
1111
developers: [
@@ -31,6 +31,7 @@ export default {
3131
SourceIntents.SEARCH_RESULTS_PROVIDING,
3232
SourceIntents.CHAPTER_PROVIDING,
3333
SourceIntents.SETTINGS_FORM_PROVIDING,
34-
SourceIntents.DISCOVER_SECIONS_PROVIDING
34+
SourceIntents.DISCOVER_SECIONS_PROVIDING,
35+
SourceIntents.CLOUDFLARE_BYPASS_PROVIDING
3536
],
3637
} satisfies ExtensionInfo

src/Komga/sdk/client/Archive.zip

-12.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)