-
Notifications
You must be signed in to change notification settings - Fork 340
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
Fix infinite spinner for login that results in failure #1305
Conversation
Your code looks good, but I'm confused as to why the exception isn't already being captured in the API wrapper and returning a result with state = failed. |
Here's some relevant code from class WrappedLemmyHttpClient {
#client: LemmyHttp;
constructor(client: LemmyHttp) {
this.#client = client;
for (const key of Object.getOwnPropertyNames(
Object.getPrototypeOf(this.#client)
)) {
if (key !== "constructor") {
WrappedLemmyHttpClient.prototype[key] = async (...args) => {
try {
const res = await this.#client[key](...args);
return {
data: res,
state: "success",
};
} catch (error) {
console.error(`API error: ${error}`);
toast(i18n.t(error), "danger");
return {
state: "failed",
msg: error,
};
}
};
}
}
}
} Even though |
5915077
to
39b9dc8
Compare
@SleeplessOne1917 I have updated the code to address your points, take a look when you can? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh thanks for this one, sry I missed it!
a180f96
to
ccf9554
Compare
ccf9554
to
93e3598
Compare
Added error handling to the login form, so it doesn't just "spin infinitely" when there is an error. Error is surfaced as a toast using existing code, just calling i.setState() in the catch block.