Monorepo for Tangled tangled.org

appview: skip fork info query if user is not logged in

Prevents a nil dereference in the repo index route if the user is not
logged in, and hides the fork-sync button.

Fixes: <https://tangled.sh/@tangled.sh/core/issues/108>

authored by tjh.dev and committed by anirudh.fi 7c546a92 c4390757

Changed files
+7 -3
appview
pages
templates
repo
state
+1 -1
appview/pages/pages.go
··· 410 410 CommitsTrunc []*object.Commit 411 411 TagsTrunc []*types.TagReference 412 412 BranchesTrunc []types.Branch 413 - ForkInfo types.ForkInfo 413 + ForkInfo *types.ForkInfo 414 414 types.RepoIndexResponse 415 415 HTMLReadme template.HTML 416 416 Raw bool
+1 -1
appview/pages/templates/repo/index.html
··· 66 66 {{ end }} 67 67 </optgroup> 68 68 </select> 69 - {{ if .ForkInfo.IsFork }} 69 + {{ if and .ForkInfo .ForkInfo.IsFork }} 70 70 {{ $disabled := "" }} 71 71 {{ $title := "" }} 72 72 {{ if eq .ForkInfo.Status 0 }}
+5 -1
appview/state/repo.go
··· 137 137 RepoIndexResponse: result, 138 138 CommitsTrunc: commitsTrunc, 139 139 TagsTrunc: tagsTrunc, 140 - ForkInfo: *forkInfo, 140 + ForkInfo: forkInfo, 141 141 BranchesTrunc: branchesTrunc, 142 142 EmailToDidOrHandle: EmailToDidOrHandle(s, emails), 143 143 }) ··· 151 151 w http.ResponseWriter, 152 152 user *oauth.User, 153 153 ) (*types.ForkInfo, error) { 154 + if user == nil { 155 + return nil, nil 156 + } 157 + 154 158 forkInfo := types.ForkInfo{ 155 159 IsFork: repoInfo.Source != nil, 156 160 Status: types.UpToDate,