Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
shamoon committed Nov 12, 2024
1 parent 04a9be5 commit f6ba19a
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/widgets/services/suwayomi.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}`.
Expand Down
1 change: 0 additions & 1 deletion src/widgets/suwayomi/component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}>
Expand Down
5 changes: 1 addition & 4 deletions src/widgets/suwayomi/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit f6ba19a

Please sign in to comment.