Skip to content
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: No Loading Feedback on Login Form, Causing Unresponsiveness #955

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

Abbas-Askari
Copy link

@Abbas-Askari Abbas-Askari commented Feb 3, 2025

Add loader to login form

Throbber is added to the login form button while the request is pending and is removed afterwards, making the form more responsive.

Fixes #954

Video

VIdeo:
Screencast from 2025-02-03 18-35-47.webm

PR Test Details

Note: The PR will be ready for live testing at https://rocketchat.github.io/EmbeddedChat/pulls/pr-955 after approval.

@@ -43,7 +45,10 @@ export default function LoginForm() {
const handleSubmit = () => {
if (!userOrEmail) setUserOrEmail('');
if (!password) setPassword('');
handleLogin(userOrEmail, password);
setLoading(true);
handleLogin(userOrEmail, password).finally(() => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have it differently ? Instead of using finally here

Copy link
Author

@Abbas-Askari Abbas-Askari Feb 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Spiral-Memory
We can put the loading in useRCAuth hook. Then the inside LoginForm we will have:

const { handleLogin, loading } = useRCAuth();
...
const handleSubmit = () => {
    if (!userOrEmail) setUserOrEmail('');
    if (!password) setPassword('');
    handleLogin(userOrEmail, password); // No more setting loading to true and flase here.
  };

Would that be preferable?

I dont think you meant try ... catch instead of finally?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Spiral-Memory We can put the loading in useRCAuth hook. Then the inside LoginForm we will have:

const { handleLogin, loading } = useRCAuth();
...
const handleSubmit = () => {
    if (!userOrEmail) setUserOrEmail('');
    if (!password) setPassword('');
    handleLogin(userOrEmail, password); // No more setting loading to true and flase here.
  };

Would that be preferable?

I dont think you meant try ... catch instead of finally?

Done. I also added loading indication to TOTP form.

@Abbas-Askari
Copy link
Author

Requested changes are completed @Spiral-Memory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No Loading Feedback on Login Form, Causing Unresponsiveness
2 participants