Merge branch 'efficient-emoji-loading' into 'master'
Only load emoji spritesheet when necessary On a normal issue where the only award emoji displayed by default are the thumbs-up and thumbs-down emoji, this decreases the page load by 670KB or 250KB depending on pixel density. Resolves #14334. See merge request !3449
This commit is contained in:
commit
9e2032173c
|
@ -1,6 +1,7 @@
|
|||
Please view this file on the master branch, on stable branches it's out of date.
|
||||
|
||||
v 8.7.0 (unreleased)
|
||||
- Load award emoji images separately unless opening the full picker. Saves several hundred KBs of data for most pages. (Connor Shea)
|
||||
- All images in discussions and wikis now link to their source files !3464 (Connor Shea).
|
||||
- Return status code 303 after a branch DELETE operation to avoid project deletion (Stan Hu)
|
||||
- Improved Markdown rendering performance !3389 (Yorick Peterse)
|
||||
|
|
|
@ -115,17 +115,32 @@ module IssuesHelper
|
|||
icon('eye-slash') if issue.confidential?
|
||||
end
|
||||
|
||||
def emoji_icon(name, unicode = nil, aliases = [])
|
||||
def emoji_icon(name, unicode = nil, aliases = [], sprite: true)
|
||||
unicode ||= Emoji.emoji_filename(name) rescue ""
|
||||
|
||||
content_tag :div, "",
|
||||
class: "icon emoji-icon emoji-#{unicode}",
|
||||
title: name,
|
||||
data: {
|
||||
aliases: aliases.join(' '),
|
||||
emoji: name,
|
||||
unicode_name: unicode
|
||||
}
|
||||
data = {
|
||||
aliases: aliases.join(" "),
|
||||
emoji: name,
|
||||
unicode_name: unicode
|
||||
}
|
||||
|
||||
if sprite
|
||||
# Emoji icons for the emoji menu, these use a spritesheet.
|
||||
content_tag :div, "",
|
||||
class: "icon emoji-icon emoji-#{unicode}",
|
||||
title: name,
|
||||
data: data
|
||||
else
|
||||
# Emoji icons displayed separately, used for the awards already given
|
||||
# to an issue or merge request.
|
||||
content_tag :img, "",
|
||||
class: "icon emoji",
|
||||
title: name,
|
||||
height: "20px",
|
||||
width: "20px",
|
||||
src: url_to_image("#{unicode}.png"),
|
||||
data: data
|
||||
end
|
||||
end
|
||||
|
||||
def emoji_author_list(notes, current_user)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
.awards.votes-block
|
||||
- awards_sort(votable.notes.awards.grouped_awards).each do |emoji, notes|
|
||||
%button.btn.award-control.js-emoji-btn.has-tooltip{class: (note_active_class(notes, current_user)), title: emoji_author_list(notes, current_user), data: {placement: "top"}}
|
||||
= emoji_icon(emoji)
|
||||
= emoji_icon(emoji, sprite: false)
|
||||
%span.award-control-text.js-counter
|
||||
= notes.count
|
||||
|
||||
|
|
Loading…
Reference in New Issue