Commit 40807a96 authored by Phil Hughes's avatar Phil Hughes

Lazy load avatars in diffs

Adds the lazy attribute to lazy load avatars in merge request diffs.
parent 020110b3
...@@ -75,6 +75,7 @@ export default { ...@@ -75,6 +75,7 @@ export default {
:key="note.id" :key="note.id"
:img-src="note.author.avatar_url" :img-src="note.author.avatar_url"
:tooltip-text="getTooltipText(note)" :tooltip-text="getTooltipText(note)"
lazy
class="diff-comment-avatar js-diff-comment-avatar" class="diff-comment-avatar js-diff-comment-avatar"
@click.native="$emit('toggleLineDiscussions')" @click.native="$emit('toggleLineDiscussions')"
/> />
......
...@@ -392,6 +392,7 @@ export default { ...@@ -392,6 +392,7 @@ export default {
:img-src="author.avatar_url" :img-src="author.avatar_url"
:img-alt="author.name" :img-alt="author.name"
:img-size="40" :img-size="40"
lazy
> >
<template #avatar-badge> <template #avatar-badge>
<slot name="avatar-badge"></slot> <slot name="avatar-badge"></slot>
......
...@@ -30,6 +30,11 @@ export default { ...@@ -30,6 +30,11 @@ export default {
GlTooltip: GlTooltipDirective, GlTooltip: GlTooltipDirective,
}, },
props: { props: {
lazy: {
type: Boolean,
required: false,
default: false,
},
linkHref: { linkHref: {
type: String, type: String,
required: false, required: false,
...@@ -91,6 +96,7 @@ export default { ...@@ -91,6 +96,7 @@ export default {
:size="imgSize" :size="imgSize"
:tooltip-text="avatarTooltipText" :tooltip-text="avatarTooltipText"
:tooltip-placement="tooltipPlacement" :tooltip-placement="tooltipPlacement"
:lazy="lazy"
> >
<slot></slot> </user-avatar-image <slot></slot> </user-avatar-image
><span ><span
......
...@@ -104,4 +104,15 @@ describe('User Avatar Link Component', () => { ...@@ -104,4 +104,15 @@ describe('User Avatar Link Component', () => {
); );
}); });
}); });
describe('lazy', () => {
it('passes lazy prop to avatar image', () => {
createWrapper({
username: '',
lazy: true,
});
expect(wrapper.find(UserAvatarImage).props('lazy')).toBe(true);
});
});
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment