Remember diff view style (#163)
This commit is contained in:
parent
bd76e156bb
commit
739f07c98e
7 changed files with 47 additions and 7 deletions
|
@ -180,7 +180,6 @@ func Diff(ctx *context.Context) {
|
|||
}
|
||||
|
||||
ctx.Data["CommitID"] = commitID
|
||||
ctx.Data["IsSplitStyle"] = ctx.Query("style") == "split"
|
||||
ctx.Data["Username"] = userName
|
||||
ctx.Data["Reponame"] = repoName
|
||||
ctx.Data["IsImageFile"] = commit.IsImageFile
|
||||
|
@ -239,7 +238,6 @@ func CompareDiff(ctx *context.Context) {
|
|||
}
|
||||
commits = models.ValidateCommitsWithEmails(commits)
|
||||
|
||||
ctx.Data["IsSplitStyle"] = ctx.Query("style") == "split"
|
||||
ctx.Data["CommitRepoLink"] = ctx.Repo.RepoLink
|
||||
ctx.Data["Commits"] = commits
|
||||
ctx.Data["CommitCount"] = commits.Len()
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -367,7 +367,6 @@ func ViewPullFiles(ctx *context.Context) {
|
|||
}
|
||||
|
||||
headTarget := path.Join(pull.HeadUserName, pull.HeadRepo.Name)
|
||||
ctx.Data["IsSplitStyle"] = ctx.Query("style") == "split"
|
||||
ctx.Data["Username"] = pull.HeadUserName
|
||||
ctx.Data["Reponame"] = pull.HeadRepo.Name
|
||||
ctx.Data["IsImageFile"] = commit.IsImageFile
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue