r/Devvit • u/Chosen1PR App Developer • 11d ago
Feature Request Please allow us to update app settings programmatically
Currently, app settings can only be updated in one of two ways: Either by using the app settings page on developers.reddit.com, or by using the Devvit CLI. I think it would be very useful to be able to update app settings programmatically, via a function such as reddit.setSetting() or some similar name.
An example of how this could be very beneficial is: Let's say one of my Mod Tools app's settings is a boolean value and I want to change it to a select, to give the user/mod more options. Ideally, I'd like to base the default value of that select setting on the previous value of the boolean setting, so that when the app is updated, it doesn't break the workflow for mods.
I also logged an "issue" on GitHub with this request, so if any admin likes this idea, feel free to use that ticket for tracking purposes.
4
1
u/PokeRestockHandler 8d ago
Im confused. I get changing true to false but changing a boolean to a different type is heavier and hints at reflection which is terrible for reliability
1
u/Chosen1PR App Developer 8d ago edited 8d ago
Sorry if I wasn't clear enough. For changing the setting type, I meant when updating the app, not during normal operation.
Hypothetical example: My app currently has a
booleansetting which is just on/off. I decide I want more granular control over this setting so I change it to aselect(drop-down) setting to give the user more options. I also rename the setting internally.I then use the
onAppUpdatetrigger during an app update to search for the oldbooleansetting by name. If I find it, that means I'm updating from a version of the app that has that old setting. I can then update the value of the newselectsetting based on the oldbooleanvalue.For example, if the new setting has values
off,low,medium, andhigh, an old value offalsewould becomeoffwhereas an old value oftruecould becomemedium.Edit: Now that I think of it, I'm not so sure the
onAppUpdatetrigger would have access to the old setting... Either way, I think you get where I'm going with this. I wasn't referring to changing setting types on the fly.1
u/stonk_lord_ 6d ago
Maybe they should add a legacy attribute to the settings page. In devvit.json you should be able to add a "legacy" attribute to all settings that you no longer want the moderators to see when using your app, but you can still access those legacy settings via settings.get().
You can then simply update your new setting value based on whatever value you got from the legacy setting onappupdate
•
u/vip-bot 11d ago
There is 1 comment from Reddit Admins in this post:
u/Xenccc commented:
This summary was generated automatically. If you have any questions, please contact r/Devvit moderators.