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 issue after deleting non-active account #765

Merged
merged 6 commits into from
Sep 25, 2023

Conversation

micahmo
Copy link
Member

@micahmo micahmo commented Sep 24, 2023

Pull Request Description

This PR fixes an issue with the new account switcher where deleting a non-active accont could cause the current active account to deactivate, and cause us to revert to an unlisted anonymous instance.

Issue Being Fixed

Issue Number: N/A

Screenshots / Recordings

Before

account-switcher-bug-before.mp4

After

account-switcher-bug-after.mp4

Checklist

  • Did you update CHANGELOG.md? -- N/A bug against new feature
  • Did you use localized strings where applicable? -- N/A
  • Did you add semanticLabels where applicable for accessibility? -- N/A

Copy link
Member

@hjiangsu hjiangsu left a comment

Choose a reason for hiding this comment

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

Looks good, just one question:

await Future.delayed(const Duration(milliseconds: 1500)

Is there a reason for the delay? I'm assuming its to wait for the accounts to switch/fetch information but maybe there's a better way to handle this aside from a static value? If we are keeping the delay, then it would be good to add some feedback to the user to let them know something is happening/has happened!

Also, on an unrelated note, I noticed that the selected account colour doesn't show up well when its in dark mode, but this can be for another PR!

@micahmo
Copy link
Member Author

micahmo commented Sep 25, 2023

Is there a reason for the delay?

Good question! First I'll just mention that this file already had a similar delay added in #677, but I know that was such a big PR it was probably overlooked.

await Future.delayed(const Duration(milliseconds: 1500), () {

But even more importantly, I'm really just copying some code that you added a while back.

// Add a bit of artificial delay to allow preferences to set the proper active profile
Future.delayed(const Duration(milliseconds: 500), () => context.read<InboxBloc>().add(const GetInboxEvent(reset: true)));

While I never really looked into this, based on the comment it seems, as you alluded to, that there is some fetching/loading that we have to wait for before proceeding. Without this, calling SwitchAccount directly after RemoveAccount doesn't work. I didn't bother looking into what RemoveAccount might be doing that causes a delay, since you had already added a similar wait. Hopefully it's ok, and short enough not to be a bother. I can even try shortening it a bit.

it would be good to add some feedback to the user to let them know something is happening/has happened!

Good point! In the profile switcher modal, can you think of a good place to add a spinner?

on an unrelated note, I noticed that the selected account colour doesn't show up well when its in dark mode

I think someone mentioned this in Matrix and said that some themes look better than others. I think I probably just need to increase the opacity.

@hjiangsu
Copy link
Member

While I never really looked into this, based on the comment it seems, as you alluded to, that there is some fetching/loading that we have to wait for before proceeding.

Yeah, I think maybe we can shorten the delay a bit more so that it feels "quicker". I think shortening the duration and adding the loading indicator should be good enough for now!

Good point! In the profile switcher modal, can you think of a good place to add a spinner?

I think we can add a spinner in place of the trash icon when we remove an account!

I think someone mentioned this in Matrix and said that some themes look better than others. I think I probably just need to increase the opacity.

It might just not be applying the proper colour? At least when I switch between light and dark, the selected colour is the same. I'll post a screenshot to show you what I mean!

@hjiangsu
Copy link
Member

hjiangsu commented Sep 25, 2023

image image

@micahmo
Copy link
Member Author

micahmo commented Sep 25, 2023

I think maybe we can shorten the delay a bit more so that it feels "quicker".

Done! Shortened as much as I could while keeping it working.

I think we can add a spinner in place of the trash icon when we remove an account!

Done! Works for log out and delete. There's still a slight delay after the account is gone and before the previous/new one is selected, but I think it's much better now.

qemu-system-x86_64_MpgtDrIZ6L.mp4

It might just not be applying the proper colour? At least when I switch between light and dark, the selected colour is the same. I'll post a screenshot to show you what I mean!

Oh, thank you, that's not what I was expecting lol (should've just tried it myself!). Fixed.

image

Should be good to go now!

@hjiangsu
Copy link
Member

Nice, it looks good now! Thanks :D

@hjiangsu hjiangsu merged commit 3002ab9 into thunder-app:develop Sep 25, 2023
@micahmo micahmo deleted the fix/delete-non-active-account branch September 25, 2023 18:41
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.

2 participants