0.2.77
This commit is contained in:
@@ -61,8 +61,16 @@ type preferenceDefinition struct {
|
||||
// number reads as minutes, which is what the first one to exist happened to be.
|
||||
Unit string `json:"unit,omitempty"`
|
||||
MaxLength int `json:"maxLength,omitempty"`
|
||||
AdminOnly bool `json:"adminOnly,omitempty"`
|
||||
Default any `json:"default"`
|
||||
// Uppercase folds a text value to capitals. It belongs to the definition rather than
|
||||
// to the kind: initials are read as capitals, and a person's name is not — folding
|
||||
// every text setting would have the launcher greeting somebody as MATT.
|
||||
Uppercase bool `json:"uppercase,omitempty"`
|
||||
// Placeholder is what the console shows in an empty field, which for these settings is
|
||||
// what happens when nobody fills it in. Blank is a legal value for both of them, so the
|
||||
// field has to say what blank means or it reads as a setting that was never finished.
|
||||
Placeholder string `json:"placeholder,omitempty"`
|
||||
AdminOnly bool `json:"adminOnly,omitempty"`
|
||||
Default any `json:"default"`
|
||||
}
|
||||
|
||||
func option(value, label string) preferenceOption {
|
||||
@@ -74,6 +82,17 @@ var preferenceCatalogue = []preferenceDefinition{
|
||||
Key: "profileInitials", Name: "Profile initials", Area: "Profile",
|
||||
Description: "Up to two characters shown in this person's user-switcher avatar. Leave blank to generate them from their name.",
|
||||
Kind: preferenceText, Default: "", MaxLength: 2, AdminOnly: true,
|
||||
Uppercase: true, Placeholder: "Generated from their name",
|
||||
},
|
||||
{
|
||||
// The friendly name Memby addresses somebody by, and nothing more: it is not a
|
||||
// second username and nothing is keyed on it. Blank is the ordinary state — the
|
||||
// television falls back to the account name — so this is only worth setting where
|
||||
// the account name is not what anybody would call the person.
|
||||
Key: "shortName", Name: "Short name", Area: "Profile",
|
||||
Description: "The friendly name Memby greets this person by. Leave blank to use their account name.",
|
||||
Kind: preferenceText, Default: "", MaxLength: shortNameMaxLength, AdminOnly: true,
|
||||
Placeholder: "Their account name",
|
||||
},
|
||||
{
|
||||
Key: "homeSections", Name: "Home rows", Area: "Home",
|
||||
@@ -237,6 +256,10 @@ var preferenceCatalogue = []preferenceDefinition{
|
||||
},
|
||||
}
|
||||
|
||||
// shortNameMaxLength bounds the friendly name. It is a first name on a launcher, not a
|
||||
// field to write a sentence in, and the greeting it lands in shares its line with a clock.
|
||||
const shortNameMaxLength = 24
|
||||
|
||||
// maxListEntries bounds the free-form id lists. They come from a television, and a row
|
||||
// list long enough to matter is already a bug on that end.
|
||||
const maxListEntries = 200
|
||||
@@ -334,7 +357,10 @@ func normalizePreference(definition preferenceDefinition, value any) any {
|
||||
trimmed := strings.TrimSpace(typed)
|
||||
if !strings.ContainsAny(trimmed, "\n\r") &&
|
||||
(definition.MaxLength <= 0 || len([]rune(trimmed)) <= definition.MaxLength) {
|
||||
return strings.ToUpper(trimmed)
|
||||
if definition.Uppercase {
|
||||
return strings.ToUpper(trimmed)
|
||||
}
|
||||
return trimmed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user