Skip to content

Commit

Permalink
home: imp code
Browse files Browse the repository at this point in the history
  • Loading branch information
Mizzick committed Jan 12, 2023
1 parent bb9989b commit e04181f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/home/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ var config = &configuration{
},
OSConfig: &osConfig{},
SchemaVersion: currentSchemaVersion,
Theme: Auto,
Theme: ThemeAuto,
}

// getConfigFilename returns path to the current config file
Expand Down
24 changes: 21 additions & 3 deletions internal/home/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,30 @@ func handleStatus(w http.ResponseWriter, r *http.Request) {
type Theme string

// Allowed themes.
//
// Keep in sync with client/src/helpers/constants.js.
const (
Auto Theme = "auto"
Light Theme = "light"
Dark Theme = "dark"
ThemeAuto Theme = "auto"
ThemeLight Theme = "light"
ThemeDark Theme = "dark"
)

// UnmarshalText implements the encoding.TextUnmarshaler interface for *Theme.
func (t *Theme) UnmarshalText(b []byte) (err error) {
switch string(b) {
case "auto":
*t = ThemeAuto
case "dark":
*t = ThemeDark
case "light":
*t = ThemeLight
default:
// Go on and return an error.
}

return fmt.Errorf("invalid value %q, supported: %q, %q, %q", b, ThemeAuto, ThemeDark, ThemeLight)
}

// profileJSON is an object for /control/profile endpoints.
type profileJSON struct {
Name string `json:"name"`
Expand Down

0 comments on commit e04181f

Please sign in to comment.