aboutsummaryrefslogtreecommitdiffstats
path: root/templates/repo/issue
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2023-02-15 21:37:34 +0800
committerGitHub <noreply@github.com>2023-02-15 21:37:34 +0800
commitbd820aa9c52da4568b460a0b8604287f8ed8df26 (patch)
tree15e59e1d4f705b1c5adbd418ed711dfd602a1b25 /templates/repo/issue
parent03638f9725de3cda5207384098b38462f56d442e (diff)
downloadgitea-bd820aa9c52da4568b460a0b8604287f8ed8df26.tar.gz
gitea-bd820aa9c52da4568b460a0b8604287f8ed8df26.zip
Add context cache as a request level cache (#22294)
To avoid duplicated load of the same data in an HTTP request, we can set a context cache to do that. i.e. Some pages may load a user from a database with the same id in different areas on the same page. But the code is hidden in two different deep logic. How should we share the user? As a result of this PR, now if both entry functions accept `context.Context` as the first parameter and we just need to refactor `GetUserByID` to reuse the user from the context cache. Then it will not be loaded twice on an HTTP request. But of course, sometimes we would like to reload an object from the database, that's why `RemoveContextData` is also exposed. The core context cache is here. It defines a new context ```go type cacheContext struct { ctx context.Context data map[any]map[any]any lock sync.RWMutex } var cacheContextKey = struct{}{} func WithCacheContext(ctx context.Context) context.Context { return context.WithValue(ctx, cacheContextKey, &cacheContext{ ctx: ctx, data: make(map[any]map[any]any), }) } ``` Then you can use the below 4 methods to read/write/del the data within the same context. ```go func GetContextData(ctx context.Context, tp, key any) any func SetContextData(ctx context.Context, tp, key, value any) func RemoveContextData(ctx context.Context, tp, key any) func GetWithContextCache[T any](ctx context.Context, cacheGroupKey string, cacheTargetID any, f func() (T, error)) (T, error) ``` Then let's take a look at how `system.GetString` implement it. ```go func GetSetting(ctx context.Context, key string) (string, error) { return cache.GetWithContextCache(ctx, contextCacheKey, key, func() (string, error) { return cache.GetString(genSettingCacheKey(key), func() (string, error) { res, err := GetSettingNoCache(ctx, key) if err != nil { return "", err } return res.SettingValue, nil }) }) } ``` First, it will check if context data include the setting object with the key. If not, it will query from the global cache which may be memory or a Redis cache. If not, it will get the object from the database. In the end, if the object gets from the global cache or database, it will be set into the context cache. An object stored in the context cache will only be destroyed after the context disappeared.
Diffstat (limited to 'templates/repo/issue')
-rw-r--r--templates/repo/issue/list.tmpl6
-rw-r--r--templates/repo/issue/milestone_issues.tmpl6
-rw-r--r--templates/repo/issue/new_form.tmpl6
-rw-r--r--templates/repo/issue/view_content.tmpl8
-rw-r--r--templates/repo/issue/view_content/comments.tmpl64
-rw-r--r--templates/repo/issue/view_content/pull.tmpl2
-rw-r--r--templates/repo/issue/view_content/sidebar.tmpl12
7 files changed, 52 insertions, 52 deletions
diff --git a/templates/repo/issue/list.tmpl b/templates/repo/issue/list.tmpl
index 96d82d4aa6..4b55e7bec8 100644
--- a/templates/repo/issue/list.tmpl
+++ b/templates/repo/issue/list.tmpl
@@ -128,7 +128,7 @@
<a class="item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}">{{.locale.Tr "repo.issues.filter_poster_no_select"}}</a>
{{range .Posters}}
<a class="{{if eq $.PosterID .ID}}active selected{{end}} item" href="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{.ID}}">
- {{avatar .}} {{.GetDisplayName}}
+ {{avatar $.Context .}} {{.GetDisplayName}}
</a>
{{end}}
</div>
@@ -148,7 +148,7 @@
<a class="item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&poster={{$.PosterID}}">{{.locale.Tr "repo.issues.filter_assginee_no_select"}}</a>
{{range .Assignees}}
<a class="{{if eq $.AssigneeID .ID}}active selected{{end}} item" href="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{.ID}}&poster={{$.PosterID}}">
- {{avatar .}} {{.GetDisplayName}}
+ {{avatar $.Context .}} {{.GetDisplayName}}
</a>
{{end}}
</div>
@@ -292,7 +292,7 @@
</div>
{{range .Assignees}}
<div class="item issue-action" data-element-id="{{.ID}}" data-url="{{$.RepoLink}}/issues/assignee">
- {{avatar .}} {{.GetDisplayName}}
+ {{avatar $.Context .}} {{.GetDisplayName}}
</div>
{{end}}
</div>
diff --git a/templates/repo/issue/milestone_issues.tmpl b/templates/repo/issue/milestone_issues.tmpl
index 45b5b490a9..8d6a97a713 100644
--- a/templates/repo/issue/milestone_issues.tmpl
+++ b/templates/repo/issue/milestone_issues.tmpl
@@ -73,7 +73,7 @@
<a class="item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&assignee={{$.AssigneeID}}">{{.locale.Tr "repo.issues.filter_poster_no_select"}}</a>
{{range .Posters}}
<a class="{{if eq $.PosterID .ID}}active selected{{end}} item" href="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&assignee={{$.AssigneeID}}&poster={{.ID}}">
- {{avatar .}} {{.GetDisplayName}}
+ {{avatar $.Context .}} {{.GetDisplayName}}
</a>
{{end}}
</div>
@@ -93,7 +93,7 @@
<a class="item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&poster={{$.PosterID}}">{{.locale.Tr "repo.issues.filter_assginee_no_select"}}</a>
{{range .Assignees}}
<a class="{{if eq $.AssigneeID .ID}}active selected{{end}} item" href="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&assignee={{.ID}}&poster={{$.PosterID}}">
- {{avatar . 28 "gt-mr-2"}}
+ {{avatar $.Context . 28 "gt-mr-2"}}
{{.GetDisplayName}}
</a>
{{end}}
@@ -179,7 +179,7 @@
</div>
{{range .Assignees}}
<div class="item issue-action" data-element-id="{{.ID}}" data-url="{{$.RepoLink}}/issues/assignee">
- {{avatar . 28 "gt-mr-2"}}
+ {{avatar $.Context . 28 "gt-mr-2"}}
{{.GetDisplayName}}
</div>
{{end}}
diff --git a/templates/repo/issue/new_form.tmpl b/templates/repo/issue/new_form.tmpl
index 84c2c64a72..8fbd9d256a 100644
--- a/templates/repo/issue/new_form.tmpl
+++ b/templates/repo/issue/new_form.tmpl
@@ -8,7 +8,7 @@
<div class="twelve wide column">
<div class="ui comments">
<div class="comment">
- {{template "shared/user/avatarlink" .SignedUser}}
+ {{template "shared/user/avatarlink" Dict "Context" $.Context "user" .SignedUser}}
<div class="ui segment content">
<div class="field">
<input name="title" id="issue_title" placeholder="{{.locale.Tr "repo.milestones.title"}}" value="{{if .TitleQuery}}{{.TitleQuery}}{{else if .IssueTemplateTitle}}{{.IssueTemplateTitle}}{{else}}{{.title}}{{end}}" tabindex="3" autofocus required maxlength="255" autocomplete="off">
@@ -217,7 +217,7 @@
<a class="item muted" href="#" data-id="{{.ID}}" data-id-selector="#assignee_{{.ID}}">
<span class="octicon-check invisible">{{svg "octicon-check"}}</span>
<span class="text">
- {{avatar . 28 "gt-mr-3"}}{{.GetDisplayName}}
+ {{avatar $.Context . 28 "gt-mr-3"}}{{.GetDisplayName}}
</span>
</a>
{{end}}
@@ -229,7 +229,7 @@
</span>
{{range .Assignees}}
<a class="hide item gt-p-2 muted" id="assignee_{{.ID}}" href="{{$.RepoLink}}/issues?assignee={{.ID}}">
- {{avatar . 28 "gt-mr-3 gt-vm"}}{{.GetDisplayName}}
+ {{avatar $.Context . 28 "gt-mr-3 gt-vm"}}{{.GetDisplayName}}
</a>
{{end}}
</div>
diff --git a/templates/repo/issue/view_content.tmpl b/templates/repo/issue/view_content.tmpl
index b3970d6404..ab419472ed 100644
--- a/templates/repo/issue/view_content.tmpl
+++ b/templates/repo/issue/view_content.tmpl
@@ -23,7 +23,7 @@
<span class="timeline-avatar"><img src="{{AppSubUrl}}/assets/img/avatar_default.png"></span>
{{else}}
<a class="timeline-avatar" {{if gt .Issue.Poster.ID 0}}href="{{.Issue.Poster.HomeLink}}"{{end}}>
- {{avatar .Issue.Poster}}
+ {{avatar $.Context .Issue.Poster}}
</a>
{{end}}
<div class="content comment-container">
@@ -42,7 +42,7 @@
</span>
{{else}}
<a class="inline-timeline-avatar" href="{{.Issue.Poster.HomeLink}}">
- {{avatar .Issue.Poster}}
+ {{avatar $.Context .Issue.Poster}}
</a>
<span class="text grey">
{{template "shared/user/authorlink" .Issue.Poster}}
@@ -101,7 +101,7 @@
{{if and (or .IsRepoAdmin .HasIssuesOrPullsWritePermission (not .Issue.IsLocked)) (not .Repository.IsArchived)}}
<div class="timeline-item comment form">
<a class="timeline-avatar" href="{{.SignedUser.HomeLink}}">
- {{avatar .SignedUser}}
+ {{avatar $.Context .SignedUser}}
</a>
<div class="content">
<form class="ui segment form" id="comment-form" action="{{$.RepoLink}}/issues/{{.Issue.Index}}/comments" method="post">
@@ -152,7 +152,7 @@
{{if .Repository.IsArchived}}
<div class="timeline-item comment form">
<a class="timeline-avatar" href="{{.SignedUser.HomeLink}}">
- {{avatar .SignedUser}}
+ {{avatar $.Context .SignedUser}}
</a>
<div class="content">
<form class="ui segment form" id="comment-form" action="{{$.RepoLink}}/issues/{{.Issue.Index}}/comments" method="post">
diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl
index 90646045d0..0074f3f431 100644
--- a/templates/repo/issue/view_content/comments.tmpl
+++ b/templates/repo/issue/view_content/comments.tmpl
@@ -18,7 +18,7 @@
<span class="timeline-avatar"><img src="{{AppSubUrl}}/assets/img/avatar_default.png"></span>
{{else}}
<a class="timeline-avatar"{{if gt .Poster.ID 0}} href="{{.Poster.HomeLink}}"{{end}}>
- {{avatar .Poster}}
+ {{avatar $.Context .Poster}}
</a>
{{end}}
<div class="content comment-container">
@@ -38,7 +38,7 @@
{{else}}
{{if gt .Poster.ID 0}}
<a class="inline-timeline-avatar" href="{{.Poster.HomeLink}}">
- {{avatar .Poster}}
+ {{avatar $.Context .Poster}}
</a>
{{end}}
<span class="text grey muted-links">
@@ -94,7 +94,7 @@
{{else if eq .Type 1}}
<div class="timeline-item event" id="{{.HashTag}}">
<span class="badge gt-bg-green gt-text-white">{{svg "octicon-dot-fill"}}</span>
- {{template "shared/user/avatarlink" .Poster}}
+ {{template "shared/user/avatarlink" Dict "Context" $.Context "user" .Poster}}
<span class="text grey muted-links">
{{template "shared/user/authorlink" .Poster}}
{{if .Issue.IsPull}}
@@ -107,7 +107,7 @@
{{else if eq .Type 2}}
<div class="timeline-item event" id="{{.HashTag}}">
<span class="badge gt-bg-red gt-text-white">{{svg "octicon-circle-slash"}}</span>
- {{template "shared/user/avatarlink" .Poster}}
+ {{template "shared/user/avatarlink" Dict "Context" $.Context "user" .Poster}}
<span class="text grey muted-links">
{{template "shared/user/authorlink" .Poster}}
{{if .Issue.IsPull}}
@@ -120,7 +120,7 @@
{{else if eq .Type 28}}
<div class="timeline-item event" id="{{.HashTag}}">
<span class="badge gt-bg-purple gt-text-white">{{svg "octicon-git-merge"}}</span>
- {{template "shared/user/avatarlink" .Poster}}
+ {{template "shared/user/avatarlink" Dict "Context" $.Context "user" .Poster}}
<span class="text grey muted-links">
{{template "shared/user/authorlink" .Poster}}
{{$link := printf "%s/commit/%s" $.Repository.Link ($.Issue.PullRequest.MergedCommitID|PathEscape)}}
@@ -147,7 +147,7 @@
{{$createdStr:= TimeSinceUnix .CreatedUnix $.locale}}
<div class="timeline-item event" id="{{.HashTag}}">
<span class="badge">{{svg "octicon-bookmark"}}</span>
- {{template "shared/user/avatarlink" .Poster}}
+ {{template "shared/user/avatarlink" Dict "Context" $.Context "user" .Poster}}
{{if eq .RefAction 3}}<del>{{end}}
<span class="text grey muted-links">
{{template "shared/user/authorlink" .Poster}}
@@ -162,7 +162,7 @@
{{else if eq .Type 4}}
<div class="timeline-item event" id="{{.HashTag}}">
<span class="badge">{{svg "octicon-bookmark"}}</span>
- {{template "shared/user/avatarlink" .Poster}}
+ {{template "shared/user/avatarlink" Dict "Context" $.Context "user" .Poster}}
<span class="text grey muted-links">
{{template "shared/user/authorlink" .Poster}}
{{$.locale.Tr "repo.issues.commit_ref_at" .EventTag $createdStr | Safe}}
@@ -176,7 +176,7 @@
{{if or .AddedLabels .RemovedLabels}}
<div class="timeline-item event" id="{{.HashTag}}">
<span class="badge">{{svg "octicon-tag"}}</span>
- {{template "shared/user/avatarlink" .Poster}}
+ {{template "shared/user/avatarlink" Dict "Context" $.Context "user" .Poster}}
<span class="text grey muted-links">
{{template "shared/user/authorlink" .Poster}}
{{if and .AddedLabels (not .RemovedLabels)}}
@@ -192,7 +192,7 @@
{{else if eq .Type 8}}
<div class="timeline-item event" id="{{.HashTag}}">
<span class="badge">{{svg "octicon-milestone"}}</span>
- {{template "shared/user/avatarlink" .Poster}}
+ {{template "shared/user/avatarlink" Dict "Context" $.Context "user" .Poster}}
<span class="text grey muted-links">
{{template "shared/user/authorlink" .Poster}}
{{if gt .OldMilestoneID 0}}{{if gt .MilestoneID 0}}{{$.locale.Tr "repo.issues.change_milestone_at" (.OldMilestone.Name|Escape) (.Milestone.Name|Escape) $createdStr | Safe}}{{else}}{{$.locale.Tr "repo.issues.remove_milestone_at" (.OldMilestone.Name|Escape) $createdStr | Safe}}{{end}}{{else if gt .MilestoneID 0}}{{$.locale.Tr "repo.issues.add_milestone_at" (.Milestone.Name|Escape) $createdStr | Safe}}{{end}}
@@ -203,7 +203,7 @@
<span class="badge">{{svg "octicon-person"}}</span>
{{if gt .AssigneeID 0}}
{{if .RemovedAssignee}}
- {{template "shared/user/avatarlink" .Assignee}}
+ {{template "shared/user/avatarlink" Dict "Context" $.Context "user" .Assignee}}
<span class="text grey muted-links">
{{template "shared/user/authorlink" .Assignee}}
{{if eq .Poster.ID .Assignee.ID}}
@@ -213,7 +213,7 @@
{{end}}
</span>
{{else}}
- {{template "shared/user/avatarlink" .Assignee}}
+ {{template "shared/user/avatarlink" "user" .Assignee}}
<span class="text grey muted-links">
{{template "shared/user/authorlink" .Assignee}}
{{if eq .Poster.ID .AssigneeID}}
@@ -228,7 +228,7 @@
{{else if eq .Type 10}}
<div class="timeline-item event" id="{{.HashTag}}">
<span class="badge">{{svg "octicon-pencil"}}</span>
- {{template "shared/user/avatarlink" .Poster}}
+ {{template "shared/user/avatarlink" Dict "Context" $.Context "user" .Poster}}
<span class="text grey muted-links">
{{template "shared/user/authorlink" .Poster}}
{{$.locale.Tr "repo.issues.change_title_at" (.OldTitle|RenderEmoji) (.NewTitle|RenderEmoji) $createdStr | Safe}}
@@ -237,7 +237,7 @@
{{else if eq .Type 11}}
<div class="timeline-item event" id="{{.HashTag}}">
<span class="badge">{{svg "octicon-git-branch"}}</span>
- {{template "shared/user/avatarlink" .Poster}}
+ {{template "shared/user/avatarlink" Dict "Context" $.Context "user" .Poster}}
<span class="text grey muted-links">
{{template "shared/user/authorlink" .Poster}}
{{$.locale.Tr "repo.issues.delete_branch_at" (.OldRef|Escape) $createdStr | Safe}}
@@ -246,7 +246,7 @@
{{else if eq .Type 12}}
<div class="timeline-item event" id="{{.HashTag}}">
<span class="badge">{{svg "octicon-clock"}}</span>
- {{template "shared/user/avatarlink" .Poster}}
+ {{template "shared/user/avatarlink" Dict "Context" $.Context "user" .Poster}}
<span class="text grey muted-links">
{{template "shared/user/authorlink" .Poster}}
{{$.locale.Tr "repo.issues.start_tracking_history" $createdStr | Safe}}
@@ -255,7 +255,7 @@
{{else if eq .Type 13}}
<div class="timeline-item event" id="{{.HashTag}}">
<span class="badge">{{svg "octicon-clock"}}</span>
- {{template "shared/user/avatarlink" .Poster}}
+ {{template "shared/user/avatarlink" Dict "Context" $.Context "user" .Poster}}
<span class="text grey muted-links">
{{template "shared/user/authorlink" .Poster}}
{{$.locale.Tr "repo.issues.stop_tracking_history" $createdStr | Safe}}
@@ -269,7 +269,7 @@
{{else if eq .Type 14}}
<div class="timeline-item event" id="{{.HashTag}}">
<span class="badge">{{svg "octicon-clock"}}</span>
- {{template "shared/user/avatarlink" .Poster}}
+ {{template "shared/user/avatarlink" Dict "Context" $.Context "user" .Poster}}
<span class="text grey muted-links">
{{template "shared/user/authorlink" .Poster}}
{{$.locale.Tr "repo.issues.add_time_history" $createdStr | Safe}}
@@ -283,7 +283,7 @@
{{else if eq .Type 15}}
<div class="timeline-item event" id="{{.HashTag}}">
<span class="badge">{{svg "octicon-clock"}}</span>
- {{template "shared/user/avatarlink" .Poster}}
+ {{template "shared/user/avatarlink" Dict "Context" $.Context "user" .Poster}}
<span class="text grey muted-links">
{{template "shared/user/authorlink" .Poster}}
{{$.locale.Tr "repo.issues.cancel_tracking_history" $createdStr | Safe}}
@@ -292,7 +292,7 @@
{{else if eq .Type 16}}
<div class="timeline-item event" id="{{.HashTag}}">
<span class="badge">{{svg "octicon-clock"}}</span>
- {{template "shared/user/avatarlink" .Poster}}
+ {{template "shared/user/avatarlink" Dict "Context" $.Context "user" .Poster}}
<span class="text grey muted-links">
{{template "shared/user/authorlink" .Poster}}
{{$.locale.Tr "repo.issues.due_date_added" .Content $createdStr | Safe}}
@@ -301,7 +301,7 @@
{{else if eq .Type 17}}
<div class="timeline-item event" id="{{.HashTag}}">
<span class="badge">{{svg "octicon-clock"}}</span>
- {{template "shared/user/avatarlink" .Poster}}
+ {{template "shared/user/avatarlink" Dict "Context" $.Context "user" .Poster}}
<span class="text grey muted-links">
{{template "shared/user/authorlink" .Poster}}
{{$parsedDeadline := .Content | ParseDeadline}}
@@ -311,7 +311,7 @@
{{else if eq .Type 18}}
<div class="timeline-item event" id="{{.HashTag}}">
<span class="badge">{{svg "octicon-clock"}}</span>
- {{template "shared/user/avatarlink" .Poster}}
+ {{template "shared/user/avatarlink" Dict "Context" $.Context "user" .Poster}}
<span class="text grey muted-links">
{{template "shared/user/authorlink" .Poster}}
{{$.locale.Tr "repo.issues.due_date_remove" .Content $createdStr | Safe}}
@@ -320,7 +320,7 @@
{{else if eq .Type 19}}
<div class="timeline-item event" id="{{.HashTag}}">
<span class="badge">{{svg "octicon-package-dependents"}}</span>
- {{template "shared/user/avatarlink" .Poster}}
+ {{template "shared/user/avatarlink" Dict "Context" $.Context "user" .Poster}}
<span class="text grey muted-links">
{{template "shared/user/authorlink" .Poster}}
{{$.locale.Tr "repo.issues.dependency.added_dependency" $createdStr | Safe}}
@@ -343,7 +343,7 @@
{{else if eq .Type 20}}
<div class="timeline-item event" id="{{.HashTag}}">
<span class="badge">{{svg "octicon-package-dependents"}}</span>
- {{template "shared/user/avatarlink" .Poster}}
+ {{template "shared/user/avatarlink" Dict "Context" $.Context "user" .Poster}}
<span class="text grey muted-links">
{{template "shared/user/authorlink" .Poster}}
{{$.locale.Tr "repo.issues.dependency.removed_dependency" $createdStr | Safe}}
@@ -369,7 +369,7 @@
{{if .OriginalAuthor}}
{{else}}
<a class="timeline-avatar"{{if gt .Poster.ID 0}} href="{{.Poster.HomeLink}}"{{end}}>
- {{avatar .Poster}}
+ {{avatar $.Context .Poster}}
</a>
{{end}}
<span class="badge{{if eq .Review.Type 1}} gt-bg-green gt-text-white{{else if eq .Review.Type 3}} gt-bg-red gt-text-white{{end}}">{{svg (printf "octicon-%s" .Review.Type.Icon)}}</span>
@@ -529,7 +529,7 @@
<div class="comment-header-left gt-df gt-ac">
{{if not .OriginalAuthor}}
<a class="avatar">
- {{avatar .Poster}}
+ {{avatar $.Context .Poster}}
</a>
{{end}}
<span class="text grey muted-links">
@@ -626,7 +626,7 @@
{{else if eq .Type 23}}
<div class="timeline-item event" id="{{.HashTag}}">
<span class="badge">{{svg "octicon-lock"}}</span>
- {{template "shared/user/avatarlink" .Poster}}
+ {{template "shared/user/avatarlink" Dict "Context" $.Context "user" .Poster}}
{{if .Content}}
<span class="text grey muted-links">
{{template "shared/user/authorlink" .Poster}}
@@ -642,7 +642,7 @@
{{else if eq .Type 24}}
<div class="timeline-item event" id="{{.HashTag}}">
<span class="badge">{{svg "octicon-key"}}</span>
- {{template "shared/user/avatarlink" .Poster}}
+ {{template "shared/user/avatarlink" Dict "Context" $.Context "user" .Poster}}
<span class="text grey muted-links">
{{template "shared/user/authorlink" .Poster}}
{{$.locale.Tr "repo.issues.unlock_comment" $createdStr | Safe}}
@@ -651,7 +651,7 @@
{{else if eq .Type 25}}
<div class="timeline-item event">
<span class="badge">{{svg "octicon-git-branch"}}</span>
- {{template "shared/user/avatarlink" .Poster}}
+ {{template "shared/user/avatarlink" Dict "Context" $.Context "user" .Poster}}
<span class="text grey muted-links">
<a{{if gt .Poster.ID 0}} href="{{.Poster.HomeLink}}"{{end}}>{{.Poster.Name}}</a>
{{$.locale.Tr "repo.pulls.change_target_branch_at" (.OldRef|Escape) (.NewRef|Escape) $createdStr | Safe}}
@@ -660,7 +660,7 @@
{{else if eq .Type 26}}
<div class="timeline-item event" id="{{.HashTag}}">
<span class="badge">{{svg "octicon-clock"}}</span>
- {{template "shared/user/avatarlink" .Poster}}
+ {{template "shared/user/avatarlink" Dict "Context" $.Context "user" .Poster}}
<span class="text grey muted-links">
{{template "shared/user/authorlink" .Poster}}
@@ -674,7 +674,7 @@
{{else if eq .Type 27}}
<div class="timeline-item event" id="{{.HashTag}}">
<span class="badge">{{svg "octicon-eye"}}</span>
- {{template "shared/user/avatarlink" .Poster}}
+ {{template "shared/user/avatarlink" Dict "Context" $.Context "user" .Poster}}
<span class="text grey muted-links">
{{template "shared/user/authorlink" .Poster}}
{{if (gt .AssigneeID 0)}}
@@ -715,7 +715,7 @@
{{if not $.UnitProjectsGlobalDisabled}}
<div class="timeline-item event" id="{{.HashTag}}">
<span class="badge">{{svg "octicon-project"}}</span>
- {{template "shared/user/avatarlink" .Poster}}
+ {{template "shared/user/avatarlink" Dict "Context" $.Context "user" .Poster}}
<span class="text grey muted-links">
{{template "shared/user/authorlink" .Poster}}
{{if gt .OldProjectID 0}}
@@ -734,7 +734,7 @@
<div class="timeline-item-group">
<div class="timeline-item event" id="{{.HashTag}}">
<a class="timeline-avatar"{{if gt .Poster.ID 0}} href="{{.Poster.HomeLink}}"{{end}}>
- <img src="{{.Poster.AvatarLink}}">
+ <img src="{{.Poster.AvatarLink $.Context}}">
</a>
<span class="badge grey">{{svg "octicon-x" 16}}</span>
<span class="text grey muted-links">
@@ -772,7 +772,7 @@
{{else if eq .Type 33}}
<div class="timeline-item event" id="{{.HashTag}}">
<span class="badge">{{svg "octicon-git-branch"}}</span>
- {{template "shared/user/avatarlink" .Poster}}
+ {{template "shared/user/avatarlink" Dict "Context" $.Context "user" .Poster}}
<span class="text grey muted-links">
{{template "shared/user/authorlink" .Poster}}
{{if and .OldRef .NewRef}}
diff --git a/templates/repo/issue/view_content/pull.tmpl b/templates/repo/issue/view_content/pull.tmpl
index ae463d1b3f..663264171b 100644
--- a/templates/repo/issue/view_content/pull.tmpl
+++ b/templates/repo/issue/view_content/pull.tmpl
@@ -10,7 +10,7 @@
<div class="review-item-left">
{{if .User}}
<a href="{{.User.HomeLink}}">
- {{avatar .User}}
+ {{avatar $.Context .User}}
</a>
{{end}}
<span>
diff --git a/templates/repo/issue/view_content/sidebar.tmpl b/templates/repo/issue/view_content/sidebar.tmpl
index 90afe6b85e..9ba46f3715 100644
--- a/templates/repo/issue/view_content/sidebar.tmpl
+++ b/templates/repo/issue/view_content/sidebar.tmpl
@@ -26,7 +26,7 @@
<a class="{{if not .CanChange}}ui tooltip{{end}} item {{if .Checked}} checked {{end}} {{if not .CanChange}}ban-change{{end}}" href="#" data-id="{{.ItemID}}" data-id-selector="#review_request_{{.ItemID}}" {{if not .CanChange}} data-content="{{$.locale.Tr "repo.issues.remove_request_review_block"}}"{{end}}>
<span class="octicon-check {{if not .Checked}}invisible{{end}}">{{svg "octicon-check"}}</span>
<span class="text">
- {{avatar .User 28 "gt-mr-3"}}
+ {{avatar $.Context .User 28 "gt-mr-3"}}
{{.User.GetDisplayName}}
</span>
</a>
@@ -56,7 +56,7 @@
<div class="item gt-mb-2">
{{if .User}}
<a class="muted sidebar-item-link" href="{{.User.HomeLink}}">
- {{avatar .User 28 "gt-mr-3"}}
+ {{avatar $.Context .User 28 "gt-mr-3"}}
{{.User.GetDisplayName}}
</a>
{{else if .Team}}
@@ -288,7 +288,7 @@
{{end}}
<span class="octicon-check {{if not $checked}}invisible{{end}}">{{svg "octicon-check"}}</span>
<span class="text">
- {{avatar . 28 "gt-mr-3"}}
+ {{avatar $.Context . 28 "gt-mr-3"}}
{{.GetDisplayName}}
</span>
</a>
@@ -301,7 +301,7 @@
{{range .Issue.Assignees}}
<div class="item">
<a class="muted sidebar-item-link" href="{{$.RepoLink}}/{{if $.Issue.IsPull}}pulls{{else}}issues{{end}}?assignee={{.ID}}">
- {{avatar . 28 "gt-mr-3"}}
+ {{avatar $.Context . 28 "gt-mr-3"}}
{{.GetDisplayName}}
</a>
</div>
@@ -316,7 +316,7 @@
<div class="ui list gt-df gt-fw">
{{range .Participants}}
<a class="ui tooltip" {{if gt .ID 0}}href="{{.HomeLink}}"{{end}} data-content="{{.GetDisplayName}}" data-position="top center">
- {{avatar . 28 "gt-my-1 gt-mr-2"}}
+ {{avatar $.Context . 28 "gt-my-1 gt-mr-2"}}
</a>
{{end}}
</div>
@@ -393,7 +393,7 @@
{{range $user, $trackedtime := .WorkingUsers}}
<div class="comment gt-mt-3">
<a class="avatar">
- {{avatar $user}}
+ {{avatar $.Context $user}}
</a>
<div class="content">
{{template "shared/user/authorlink" $user}}