Documentation
¶
Overview ¶
Package settingsapi is what the Settings page's save writes: the fields POST /api/settings takes from the page, how a value is checked, and the save itself. The window's handler and `magpie settings` both save through Apply, so a value the CLI sets is checked and kept exactly as one the page sets (#4745).
Index ¶
- Variables
- func Apply(body []byte, web bool) (in, cur settings.Settings, err error)
- func Body(cur settings.Settings, key string, value json.RawMessage) ([]byte, error)
- func Field(key string) (reflect.StructField, bool)
- func Known(key string) bool
- func Merge(body []byte, cur settings.Settings, web bool) (settings.Settings, error)
- func Value(s settings.Settings, key string) (any, bool)
Constants ¶
This section is empty.
Variables ¶
var Choices = map[string][]string{ "theme": settings.Themes, "contrast": {"", settings.ContrastMore, settings.ContrastNormal}, "lang": settings.Langs, "tray": settings.Trays, "currency": settings.Currencies, "totalCurrency": settings.TotalCurrencies, "trayCurrency": settings.TotalCurrencies, "codexWarmup": {"off", "week", "all"}, "claudeWarmup": {"off", "week", "all"}, "agyWarmup": {"off", "week", "all"}, "trayUsageEvery": ints(settings.TrayEvery), "dayStart": {"0", "1", "2", "3", "4", "5", "6"}, "updateChannel": {settings.UpdateStable, settings.UpdateDaily}, "updateSource": {settings.UpdateSourceSite, settings.UpdateSourceGitHub}, "updateEvery": ints(settings.UpdateEveries), "searchFirst": {settings.SearchFirstModel, settings.SearchFirstAPI}, "replyModel": settings.ReplyModels, "imageResolution": {"1K", "2K", "4K"}, }
Choices are the values a setting with a closed set takes, for `magpie settings list` to name: settings' own lists, which settings.Save checks a saved value against (a value outside them is refused there, from the window as from the CLI). A setting's "" is its default.
var Keys = []string{}/* 101 elements not displayed */
Keys are the settings POST /api/settings saves from what it is sent, by their JSON names, in the order `magpie settings list` shows them. Every other field of settings.Settings is carried from the file (Merge), set by a route of its own or kept by settings.Save. TestKeysAreWhatTheSaveWrites fails when a field the save writes is missing here, or one here isn't written.
Functions ¶
func Apply ¶
Apply is POST /api/settings: body read over the settings saved now (Merge), checked and saved. It returns what was saved and what was there before, for the caller's reactions to a change (the window's Dock, fonts, tray menu and alerts). web is a page served to a browser, whose fonts are another computer's and never saved.
func Body ¶
Body is what the Settings page sends to set key to value (its JSON) and leave everything else as cur has it: cur whole, with key sent even when it is a zero value, which a field omitted would not be (an omitted noBird is "keep", false is "show the bird").
func Field ¶
func Field(key string) (reflect.StructField, bool)
Field is the struct field of settings.Settings saved under the JSON name key, and whether there is one.
Types ¶
This section is empty.