remove duplicated code

This commit is contained in:
Lunny Xiao 2025-01-14 21:57:42 -08:00
parent 2d644fb4ce
commit bb82979191
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
2 changed files with 17 additions and 24 deletions

View File

@ -46,18 +46,7 @@ func RefBlame(ctx *context.Context) {
return
}
showFileViewTreeSidebar := true
if ctx.Doer != nil {
v, err := user_model.GetUserSetting(ctx, ctx.Doer.ID, user_model.SettingsKeyShowFileViewTreeSidebar, "true")
if err != nil {
log.Error("GetUserSetting: %v", err)
} else {
showFileViewTreeSidebar, _ = strconv.ParseBool(v)
}
}
ctx.Data["RepoPreferences"] = &preferencesForm{
ShowFileViewTreeSidebar: showFileViewTreeSidebar,
}
prepareHomeTreeSideBarSwitch(ctx)
branchLink := ctx.Repo.RepoLink + "/src/" + ctx.Repo.RefTypeNameSubURL()
treeLink := branchLink

View File

@ -312,6 +312,21 @@ func handleRepoHomeFeed(ctx *context.Context) bool {
return false
}
func prepareHomeTreeSideBarSwitch(ctx *context.Context) {
showFileViewTreeSidebar := true
if ctx.Doer != nil {
v, err := user_model.GetUserSetting(ctx, ctx.Doer.ID, user_model.SettingsKeyShowFileViewTreeSidebar, "true")
if err != nil {
log.Error("GetUserSetting: %v", err)
} else {
showFileViewTreeSidebar, _ = strconv.ParseBool(v)
}
}
ctx.Data["RepoPreferences"] = &preferencesForm{
ShowFileViewTreeSidebar: showFileViewTreeSidebar,
}
}
// Home render repository home page
func Home(ctx *context.Context) {
if handleRepoHomeFeed(ctx) {
@ -325,18 +340,7 @@ func Home(ctx *context.Context) {
return
}
showFileViewTreeSidebar := true
if ctx.Doer != nil {
v, err := user_model.GetUserSetting(ctx, ctx.Doer.ID, user_model.SettingsKeyShowFileViewTreeSidebar, "true")
if err != nil {
log.Error("GetUserSetting: %v", err)
} else {
showFileViewTreeSidebar, _ = strconv.ParseBool(v)
}
}
ctx.Data["RepoPreferences"] = &preferencesForm{
ShowFileViewTreeSidebar: showFileViewTreeSidebar,
}
prepareHomeTreeSideBarSwitch(ctx)
title := ctx.Repo.Repository.Owner.Name + "/" + ctx.Repo.Repository.Name
if len(ctx.Repo.Repository.Description) > 0 {