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: Generate address qr in suspended thread #279

Merged

Conversation

yellowHatpro
Copy link
Contributor

@yellowHatpro yellowHatpro commented Mar 25, 2023

@fivetran-tangyetong
Copy link
Collaborator

Hi @yellowHatpro , would clicking the Generate a new address button launch multiple computations of a new QR on separate threads? In that case we might want to either:

  1. Add a flag to ensure only generate 1 QR at a time, or
  2. disable the button while the QR is being generated.
    What do you think?

@yellowHatpro
Copy link
Contributor Author

As per my fixes, I am calling the QR-generating function inside a Launched Effect (and inside the IO thread), whose key is the address itself. So if the address is changed, it will then only prompt the QR-generating function (only once) to be called again.
I didn't investigate the Generate a new address button yet, but I didn't notice anything to change even if I pressed the button.
Yeah, we can do something like a progress bar while generating the new QR; what say???

@fivetran-tangyetong
Copy link
Collaborator

Oh sorry for not clarifying, I was referring to issue #286 . Just in case multiple threads are created when users press the generate qr code more than once here and something unexpected happens.

I think adding a spinning circle might be a good feature to have, and you can open up a new issue (and pr) for that!

@yellowHatpro
Copy link
Contributor Author

Aaaalright I am on it 🚀😁

@fivetran-tangyetong
Copy link
Collaborator

Thanks, so just to confirm again does pressing the Generate a new address button create multiple threads? If that happens it would be good to add a flag to stop multiple threads from being created!

@yellowHatpro
Copy link
Contributor Author

Hi, I don't see anything happen when I click the Generate a new address button. I don't know what the purpose was, but the function (getLastUnusedAddress) always returns the same value.

@yellowHatpro
Copy link
Contributor Author

So I think no new threads are spawned on clicking the button

@yellowHatpro
Copy link
Contributor Author

And also, as per the current implementation of the Generate new address button, I think even if I use a progress bar to appear when the button is clicked and QR is generated, there won't be any effect because nothing actually happens on clicking the button.

@fivetran-tangyetong
Copy link
Collaborator

Looks good to me! Sorry for not catching it earlier, could you quickly rename the commit to our convention, something like the PR name, i.e. Fix: Generate address qr in suspended thread

@yellowHatpro yellowHatpro changed the title fix: image taking long time to load on main thread Fix: Generate address qr in suspended thread Apr 9, 2023
@yellowHatpro
Copy link
Contributor Author

@darkvoid32 I've changed the PR and Commit name accordingly

@yellowHatpro
Copy link
Contributor Author

I am not sure, but did you mean the commit message?
Sorry I actually changed commit lol

@fivetran-tangyetong
Copy link
Collaborator

fivetran-tangyetong commented Apr 9, 2023

Yeap I meant the commit message! Just merge all of them back into 1 commit and its good to go afterwards.

@yellowHatpro
Copy link
Contributor Author

@darkvoid32 done senpaii✅

@fivetran-tangyetong fivetran-tangyetong merged commit 6caca6c into thunderbiscuit:master Apr 10, 2023
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.

QR image generating taking too long
2 participants