@@ -138,23 +138,41 @@ export class MgtPerson extends MgtTemplatedComponent {
138138 } else {
139139 this . _personAvatarBg = this . getColorFromName ( value . displayName ) ;
140140 }
141+
142+ if ( this . fetchImage ) {
143+ this . personImage = null ;
144+ }
145+
146+ this . requestStateUpdate ( ) ;
141147 this . requestUpdate ( 'personDetails' ) ;
142148 }
143149
144150 /**
145151 * Set the image of the person
146- * Set to '@' to look up image from the graph
147152 *
148153 * @type {string }
149154 * @memberof MgtPersonCard
150155 */
151156 @property ( {
152157 attribute : 'person-image' ,
153- reflect : true ,
154158 type : String
155159 } )
156160 public personImage : string ;
157161
162+ /**
163+ * Sets whether the person image should be fetched
164+ * from the Microsoft Graph based on the personDetails
165+ * provided by the user
166+ *
167+ * @type {boolean }
168+ * @memberof MgtPerson
169+ */
170+ @property ( {
171+ attribute : 'fetch-image' ,
172+ type : Boolean
173+ } )
174+ public fetchImage : boolean ;
175+
158176 /**
159177 * Gets or sets presence of person
160178 *
@@ -666,9 +684,7 @@ export class MgtPerson extends MgtTemplatedComponent {
666684 const graph = provider . graph . forComponent ( this ) ;
667685
668686 if ( this . personDetails ) {
669- // in some cases we might only have name or email, but need to find the image
670- // use @ for the image value to search for an image
671- if ( this . personImage === '@' && ! this . personDetails . personImage ) {
687+ if ( ! this . personDetails . personImage && ( ( this . fetchImage && ! this . personImage ) || this . personImage === '@' ) ) {
672688 const image = await getPersonImage ( graph , this . personDetails ) ;
673689 if ( image ) {
674690 this . personDetails . personImage = image ;
@@ -681,6 +697,7 @@ export class MgtPerson extends MgtTemplatedComponent {
681697
682698 this . personDetails = person ;
683699 this . personImage = this . getImage ( ) ;
700+ this . personDetails . personImage = this . personImage ;
684701 } else if ( this . personQuery ) {
685702 // Use the personQuery to find our person.
686703 const people = await findPeople ( graph , this . personQuery , 1 ) ;
0 commit comments