Skip to content

Commit

Permalink
fix(userscript): show errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichthagel committed Oct 20, 2024
1 parent a3f2811 commit 750ff55
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions apps/userscript/src/DownloadButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ const DownloadButton: Component<Props> = (props) => {
}>);

window.removeEventListener("beforeunload", beforeUnload);
if (result.data) {
if (result.errors) {
setSmall(true);
setText(result.errors?.[0]?.message ?? JSON.stringify(result));
// alert(`error: ${result}`);
} else if (result.data) {
if (open) {
window.open(
`${TERUKO_BASE_URL}/${result.data.createImage[0]?.id as string}`,
Expand All @@ -79,8 +83,8 @@ const DownloadButton: Component<Props> = (props) => {
// alert(`uploaded (id: ${result.data.createImage[0].id})`);
} else {
setSmall(true);
setText(result.errors?.[0]?.message ?? JSON.stringify(result));
// alert(`error: ${result}`);
setText("no data");
// alert("no data");
}
} catch (error) {
window.removeEventListener("beforeunload", beforeUnload);
Expand Down

0 comments on commit 750ff55

Please sign in to comment.