mirror of
https://github.com/go-gitea/gitea
synced 2025-07-23 02:38:35 +00:00
Remember diff view style (#163)
This commit is contained in:
committed by
Lunny Xiao
parent
bd76e156bb
commit
739f07c98e
@@ -21,3 +21,24 @@ func SetEditorconfigIfExists(ctx *context.Context) {
|
||||
|
||||
ctx.Data["Editorconfig"] = ec
|
||||
}
|
||||
|
||||
func SetDiffViewStyle(ctx *context.Context) {
|
||||
var (
|
||||
userStyle = ctx.User.DiffViewStyle
|
||||
queryStyle = ctx.Query("style")
|
||||
style string
|
||||
)
|
||||
|
||||
if queryStyle == "unified" || queryStyle == "split" {
|
||||
style = queryStyle
|
||||
} else if userStyle == "unified" || userStyle == "split" {
|
||||
style = userStyle
|
||||
} else {
|
||||
style = "unified"
|
||||
}
|
||||
|
||||
ctx.Data["IsSplitStyle"] = style == "split"
|
||||
if err := ctx.User.UpdateDiffViewStyle(style); err != nil {
|
||||
ctx.Handle(500, "ErrUpdateDiffViewStyle", err)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user