Skip to content

Commit

Permalink
Use constants for default values
Browse files Browse the repository at this point in the history
Signed-off-by: Jo Vandeginste <[email protected]>
  • Loading branch information
jovandeginste committed Feb 22, 2024
1 parent 11f92b6 commit 44eb377
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions pkg/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ import (
"github.com/vorlif/spreak/humanize/locale/nl"
)

const (
DefaultTheme = "browser"
DefaultLanguage = "browser"
)

type Version struct {
BuildTime string
Ref string
Expand Down
2 changes: 1 addition & 1 deletion pkg/app/tempates.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func echoFunc(key string, _ ...interface{}) string {
func (a *App) viewTemplateFunctions() template.FuncMap {
return template.FuncMap{
"i18n": echoFunc,
"language": func() string { return "browser" },
"language": func() string { return DefaultLanguage },
"supportedLanguages": a.translator.SupportedLanguages,
"humanizer": func() *humanize.Collection { return a.humanizer },

Expand Down
4 changes: 2 additions & 2 deletions pkg/app/users_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ func (a *App) userRegisterHandler(c echo.Context) error {
return a.redirectWithError(c, a.echo.Reverse("user-login"), fmt.Errorf("%w: %s", ErrInternalError, err))
}

u.Profile.Theme = "browser"
u.Profile.Language = "browser"
u.Profile.Theme = DefaultLanguage
u.Profile.Language = DefaultLanguage

if err := u.Create(a.db); err != nil {
return a.redirectWithError(c, a.echo.Reverse("user-login"), fmt.Errorf("%w: %s", ErrInternalError, err))
Expand Down

0 comments on commit 44eb377

Please sign in to comment.