Apply suggestions from code review
This commit is contained in:
parent
04a9be5c93
commit
f6ba19a629
@ -5,7 +5,7 @@ description: Suwayomi Widget Configuration
|
|||||||
|
|
||||||
Learn more about [Suwayomi](https://github.com/Suwayomi/Suwayomi-Server).
|
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.
|
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}`.
|
Category IDs can be obtained from the url when navigating to it, `?tab={categoryID}`.
|
||||||
|
|||||||
@ -20,7 +20,6 @@ export default function Component({ service }) {
|
|||||||
widget.fields = ["download", "nondownload", "read", "unread"];
|
widget.fields = ["download", "nondownload", "read", "unread"];
|
||||||
} else if (widget.fields.length > 4) {
|
} else if (widget.fields.length > 4) {
|
||||||
widget.fields = widget.fields.slice(0, 4);
|
widget.fields = widget.fields.slice(0, 4);
|
||||||
widget.fields = widget.fields.map((field) => field.toLowerCase());
|
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<Container service={service}>
|
<Container service={service}>
|
||||||
|
|||||||
@ -132,7 +132,6 @@ export default async function suwayomiProxyHandler(req, res) {
|
|||||||
widget.fields = ["download", "nondownload", "read", "unread"];
|
widget.fields = ["download", "nondownload", "read", "unread"];
|
||||||
} else if (widget.fields.length > 4) {
|
} else if (widget.fields.length > 4) {
|
||||||
widget.fields = widget.fields.slice(0, 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 }));
|
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 } });
|
return res.status(status).send({ error: { message: "Error getting data. body: %s, data: %s", body, data } });
|
||||||
}
|
}
|
||||||
|
|
||||||
const responseJSON = JSON.parse(data);
|
const returnData = extractCounts(JSON.parse(data), widget.fields);
|
||||||
|
|
||||||
const returnData = extractCounts(responseJSON, widget.fields);
|
|
||||||
|
|
||||||
if (contentType) res.setHeader("Content-Type", contentType);
|
if (contentType) res.setHeader("Content-Type", contentType);
|
||||||
return res.status(status).send(returnData);
|
return res.status(status).send(returnData);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user