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
Button to reset configuration #141
Button to reset configuration #141
Conversation
By simply removing 'settings' key from the indexedDB 'keyval' ObjectStore. As requested in #101
Moved the `storage.delete` statement to the main-controller so the settingsUI can be updated easily. The main-controller is informed about a reset by the `'reset-config'` event from the mainMenuUI component.
This allows for backwards compatability (and other wierd cases where the default configuration is missing). People who used the app before this change will not have a `default-config` entry in their indexedDB, courtesy of main-controller.js:224-233
When no default configuration was found, create a new toast using the toastUI rather then using the standard `alert()`. The toast also allows for easy implementation of a reload option in the notification.
Ohh thanks! Will take a look. |
I think the best way to do this is via a toast (https://github.com/jakearchibald/svgomg/blob/master/src/js/page/main-controller.js#L158) which says "Options reset" but has "Undo" & "Dismiss" buttons. I'll take a look at that. |
I've already used a toast, so I'm comfortable adding it for you 😄 |
Adds an "Undo" option to the existing toast if no default configuration was found, and a new toast with an "Undo" and "Dismiss" button if an existin default configuration *was* found.
Naive implementation to restore the config before resetting the configuration
By reusing _saveSettings in the _resetConfig method, slightly altering it to work as expected, as _resetConfig sets/saves the configuration on three seperate occasions. _saveSetting now also sets the config in the settings UI and compresses the SVG.
I'm going to have a hack around with this. I think the setting is currently in the wrong place – it should sit with the settings it resets. There might be a better way to encapsulate the behaviour too. I'll have a play and get you to review if that's ok? |
Of course it is, have a go at it 😄 |
#142 - how's this? |
Looks good 👍 |
Done in #142. Thanks @ericcornelissen for helping with the design! |
Np, glad it is added now 🎉 |
Adds a new button to the main menu that can be used to reset the configuration of SVGO. As requested in #101 (and simple-icons/#771).
Design considerations
There is currently no "Are you sure" popup when clicking the reset configuration button, might be an idea to add it(added with dfb7392)Clarification of the code
_compressSvg
, but may be called when no SVG has been selected yet.Tested on Desktop
Tested on Mobile