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

Bugfixes #2

Merged
merged 5 commits into from
Oct 6, 2022
Merged
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
3 changes: 2 additions & 1 deletion src/TachiDesk/Common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ export async function searchRequest(
tiles.push(
createMangaTile({
id: String(serie.id),
title: createIconText({ text: serie.title+" "+source.displayName }),
title: createIconText({ text: serie.title }),
subtitleText: createIconText({text: source.displayName}),
image: `${tachiAPI}/manga/${serie.id}/thumbnail`,
})
);
Expand Down
51 changes: 21 additions & 30 deletions src/TachiDesk/Settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ export const testServerSettings = async (
): Promise<string> => {
// Try to establish a connection with the server. Return an human readable string containing the test result

const komgaAPI = await getTachiAPI(stateManager)
const tachiAPI = await getTachiAPI(stateManager)
const authorization = await getAuthorizationString(stateManager)

// We check credentials are set in server settings
if (komgaAPI === null || authorization === null) {
if (tachiAPI === null || authorization === null) {
return "Impossible: Unset credentials in server settings";
}

// To test these information, we try to make a connection to the server
// We could use a better endpoint to test the connection
const request = createRequestObject({
url: `${komgaAPI}/libraries/`,
url: `${tachiAPI}/settings/about`,
method: "GET",
incognito: true, // We don't want the authorization to be cached
headers: { authorization: authorization },
Expand All @@ -42,11 +42,13 @@ export const testServerSettings = async (
try {
const response = await requestManager.schedule(request, 1);
responseStatus = response.status;
JSON.parse(response.data); // throws error if an non json is found

} catch (error: any) {
// If the server is unavailable error.message will be 'AsyncOperationTimedOutError'
return `Failed: Could not connect to server - ${error.message}`;
}

switch (responseStatus) {
case 200: {
return "Successful connection!";
Expand Down Expand Up @@ -74,21 +76,10 @@ export const serverSettingsMenu = (
onSubmit: async (values: any) => setStateData(stateManager, values),
validate: async () => true,
sections: async () => [
createSection({
id: "information",
header: undefined,
rows: async () => [
createMultilineLabel({
label: "Demo Server",
value: "Server URL: https://demo.komga.org\nUsername: demo@komga.org\nPassword: komga-demo\n\nNote: Values are case-sensitive.",
id: "description",
}),
],
}),
createSection({
id: "serverSettings",
header: "Server Settings",
footer: "Minimal Komga version: v0.100.0",
footer: "Tested on Tachidesk Server version: v0.6.5 r1125",
rows: async () => retrieveStateData(stateManager).then((values) => [
createInputField({
id: "serverAddress",
Expand All @@ -97,23 +88,23 @@ export const serverSettingsMenu = (
value: values.serverURL,
maskInput: false,
}),
createInputField({
id: "serverUsername",
label: "Email",
placeholder: "demo@komga.org",
value: values.serverUsername,
maskInput: false,
}),
// createInputField({
// id: "serverUsername",
// label: "Email",
// placeholder: "demo@komga.org",
// value: values.serverUsername,
// maskInput: false,
// }),
// TS-Ignoring because this isnt documented yet
// Fallback to default input field if the app version doesnt support
// SecureInputField
// @ts-ignore
(typeof createSecureInputField == 'undefined' ? createInputField : createSecureInputField)({
id: "serverPassword",
label: "Password",
placeholder: "Some Super Secret Password",
value: values.serverPassword
}),
// (typeof createSecureInputField == 'undefined' ? createInputField : createSecureInputField)({
// id: "serverPassword",
// label: "Password",
// placeholder: "Some Super Secret Password",
// value: values.serverPassword
// }),
]),
}),
createSection({
Expand Down Expand Up @@ -157,7 +148,7 @@ export const testServerSettingsMenu = (
sections: async () => [
createSection({
id: "information",
header: "Connection to Komga server:",
header: "Connection to Tachidesk server:",
rows: () => testServerSettings(stateManager, requestManager).then(async (value) => [
createLabel({
label: value,
Expand Down
6 changes: 3 additions & 3 deletions src/TachiDesk/TachiDesk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ export class TachiDesk extends Source {
method: "GET",
});

const chaptersResponse = await this.requestManager.schedule(chapterRequest, 1);
const chaptersResponse = await this.requestManager.schedule(chapterRequest, 2);
const chaptersResult =
typeof chaptersResponse.data === "string"
? JSON.parse(chaptersResponse.data)
Expand Down Expand Up @@ -417,7 +417,7 @@ export class TachiDesk extends Source {
sections.push({
section: createHomeSection({
id: `${source.id}-popular`,
title: `${source.displayName} Popualr`,
title: `${source.displayName} Popular`,
view_more: true,
}),
request: createRequestObject({
Expand Down Expand Up @@ -447,7 +447,6 @@ export class TachiDesk extends Source {
const promises: Promise<void>[] = [];

for (const section of sections) {
sectionCallback(section.section);
promises.push(
this.requestManager.schedule(section.request, 1).then(response => {
let data: HomePageData
Expand All @@ -457,6 +456,7 @@ export class TachiDesk extends Source {
} catch (e) {
throw new Error(`${e}`)
}
sectionCallback(section.section);

const tiles = [];

Expand Down