Apply suggestions from code review

This commit is contained in:
shamoon 2024-11-11 17:50:07 -08:00
parent 04a9be5c93
commit f6ba19a629
3 changed files with 2 additions and 6 deletions

View File

@ -5,7 +5,7 @@ description: Suwayomi Widget Configuration
Learn more about [Suwayomi](https://github.com/Suwayomi/Suwayomi-Server).
Allowed fields:["download", "nondownload", "read", "unread", "downloadedread", "downloadedunread", "nondownloadedread", "nondownloadedunread"]
Allowed fields: ["download", "nondownload", "read", "unread", "downloadedread", "downloadedunread", "nondownloadedread", "nondownloadedunread"]
The widget defaults to the first four above. If more than four fields are provided, only the first 4 are displayed.
Category IDs can be obtained from the url when navigating to it, `?tab={categoryID}`.

View File

@ -20,7 +20,6 @@ export default function Component({ service }) {
widget.fields = ["download", "nondownload", "read", "unread"];
} else if (widget.fields.length > 4) {
widget.fields = widget.fields.slice(0, 4);
widget.fields = widget.fields.map((field) => field.toLowerCase());
}
return (
<Container service={service}>

View File

@ -132,7 +132,6 @@ export default async function suwayomiProxyHandler(req, res) {
widget.fields = ["download", "nondownload", "read", "unread"];
} else if (widget.fields.length > 4) {
widget.fields = widget.fields.slice(0, 4);
widget.fields = widget.fields.map((field) => field.toLowerCase());
}
const url = new URL(formatApiCall(widgets[widget.type].api, { endpoint, ...widget }));
@ -169,9 +168,7 @@ export default async function suwayomiProxyHandler(req, res) {
return res.status(status).send({ error: { message: "Error getting data. body: %s, data: %s", body, data } });
}
const responseJSON = JSON.parse(data);
const returnData = extractCounts(responseJSON, widget.fields);
const returnData = extractCounts(JSON.parse(data), widget.fields);
if (contentType) res.setHeader("Content-Type", contentType);
return res.status(status).send(returnData);