Skip to content
This repository has been archived by the owner on Aug 26, 2023. It is now read-only.

Pressing "save" on an empty custom API key text field accidentally shows the "updated successfully" snackbar #264

Open
prestosole opened this issue Feb 18, 2022 · 14 comments
Labels
bug Something isn't working UI
Milestone

Comments

@prestosole
Copy link
Member

Describe the bug
Pressing "save" on an empty custom API key text field accidentally shows the "updated successfully" snackbar

To Reproduce
Steps to reproduce the behavior:

  1. Go to Settings > API key
  2. Click on the API key tile
  3. Leave the text field blank
  4. Press on the "save" button

Expected behavior
The "API key updated successfully" snackbar should only be shown when a user enters a real API key and not any text, including leaving the text field blank.

Smartphone (please complete the following information):

  • Device: Galaxy s20 FE 5G
  • OS: Android 12 (One UI 4.0)
  • App version: v2.0.0
@prestosole prestosole added the bug Something isn't working label Feb 18, 2022
@triallax
Copy link
Member

triallax commented Feb 18, 2022

Technically, the behavior is not incorrect:

newApiKeyString.isEmpty
? const ApiKeyModel.default_()
: ApiKeyModel.custom(newApiKeyString),

As you can see in the lines above, if the content of the text field is empty, then the API key is set to the default one. Perhaps we can show a different snack bar text in that case, something like "API key set to default successfully."

@triallax triallax added the UI label Feb 18, 2022
@prestosole
Copy link
Member Author

prestosole commented Feb 18, 2022

That doesn't make any sense to me. We shouldn't show anything if the user pressed "save" on a blank text field.

@triallax
Copy link
Member

That's assuming that nothing happened, but in this case, the API key WAS updated, just to the default one.

@prestosole
Copy link
Member Author

Well, technically, yes, but it will be weird to show the user a snackbar when leaving the text field empty.

@triallax
Copy link
Member

Well, any alternatives then? The API key was updated, it wouldn't be wise not to tell the user that it was.

@prestosole
Copy link
Member Author

prestosole commented Feb 18, 2022

Just ... don't show a snackbar when the text field is left empty. If the user wants to get back to using the default API key, there is a button dedicated for that.

@triallax
Copy link
Member

That doesn't change the fact that the API key will be set to the default one without the user knowing it. My proposal: move the "reset API key" thing into the dialog as a "Reset" action button or something like that, and don't allow the user to save the API key unless the text field is not empty. That solves the issue.

@triallax
Copy link
Member

triallax commented Feb 18, 2022

I'm still not convinced by your claim though, because if there was an API key and it was removed manually by the user, then isn't that a change the user should be alerted about?

@prestosole
Copy link
Member Author

To the user, it makes zero sense.

@prestosole
Copy link
Member Author

We shouldn't allow the text field to save if it's blank

@prestosole
Copy link
Member Author

That's the simplest solution to the problem

@prestosole
Copy link
Member Author

We can have a setting where a user can choose whether they want to use the default API key or a custom one, and only allow them to provide a custom API key when the setting is set to custom.

@prestosole
Copy link
Member Author

That way they will never get the dialog if they're using the default API key.

@triallax
Copy link
Member

triallax commented Mar 4, 2022

@prestosole sounds good, feel free to open an issue for that.

@triallax triallax added this to the v2.0.2 milestone Apr 29, 2022
@triallax triallax removed this from the v2.0.2 milestone Jun 9, 2022
@prestosole prestosole added this to the v2.1.0 milestone Jul 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working UI
Projects
None yet
Development

No branches or pull requests

2 participants