AlexanderOMara / flarum-gravatar

Flarum Gravatar: Use Gravatar for user avatars
Mozilla Public License 2.0
4 stars 1 forks source link

Boolean settings get not loaded correctly into settings dialog #3

Closed dartrax closed 3 years ago

dartrax commented 3 years ago

I've noticed strange behavior with boolean settings and the modal settings dialog. I use Flarum beta 15. If a boolean settings was ever changed, the settings dialog will display as checked every time when the settings page is reloded and settings dialog is opened, regardless of what was saved before.

To reproduce:

  1. Enable extension
  2. Open Settings
  3. Check a checkbox
  4. Save
  5. Reload
  6. Open Settings
  7. Uncheck the checkbox
  8. Save
  9. Reload (important!)
  10. Open Settings

The Checkbox will stay checked.

Looking into the Database, is seems like so: When loading settings, null = unchecked, 0 or 1 = checked When saving settings: 0 = unchecked, 1 = checked

image

AlexanderOMara commented 3 years ago

That's fun, must be the string 0 is considered truthy by the <input type="checkbox"> React component.

Just pushed version 1.2.1 which should handle this correctly.