ScratchAddons / ScratchAddons

All-in-one browser extension for Scratch.
https://scratchaddons.com
GNU General Public License v3.0
702 stars 368 forks source link

New API: addon.settings.set #1950

Open nexensys opened 3 years ago

nexensys commented 3 years ago

Edit: see update below https://github.com/ScratchAddons/ScratchAddons/issues/1950#issuecomment-1287372899

Some addons have setting menus that they create when you are in the scratch editor (ex. onion skinning). Could we add a setter to the addon object to save changes users may have made in those setting menus? I ask this mainly because it is a feature that I would like to be able to use for my keyboard editor addon.

example usage:

addon.settings.set("option name", "value")

may also need something to get possible options of a setting:

addon.settings.getOptions("option name")
//returns options array or type of option (ex. number or string)
nexensys commented 3 years ago

Low priority.

GrahamSH-LLK commented 3 years ago

I'm not sure, but I think this may be a duplicate?

addon.settings.getOptions("option name")

would be useless because the addon is coded for these settings, they never change types without a specific code change.

GrahamSH-LLK commented 3 years ago

Why did you close this?

nexensys commented 3 years ago

because nothing had happened and it had bad opinions...?

WorldLanguages commented 3 years ago

Addons shouldn't set settings by themselves. Some addon.storage suggestions might be implemented at some point of the future, but it's still to be dicussed.

mxmou commented 3 years ago

Addons shouldn't set settings by themselves.

Being able to change settings in the addon's UI as well as on the settings page could be very useful (and I don't think that's the same as addons changing settings "by themselves"). For onion skinning, "load defaults" and "save defaults" would make the addon much easier to use. For themes, being able to (shift-)right click an element to change its color might be useful.

WorldLanguages commented 3 years ago

Hmm you have a point. But if we do this, we should make sure settings need to be explicitly set in the addon manifest as modifiable by the addon itself. Otherwise, any extension running on scratch.mit.edu could change all of the user's addon settings.

WorldLanguages commented 1 year ago

Addons shouldn't set settings by themselves.

Update: after some talk in the Discord server, I've seen there are situations where this it's beneficial to allow addons to change their own settings. However, both for security reasons and user experience, I concluded that not every setting should be "settable". Each setting should opt-in via an addon.json property. Also, allowing addons to save arbitrary values into settings, means we need to find a good way to validate whether a setting of type number remains a number, isn't NaN, etc.