@@ -11,6 +11,7 @@ import { getEmailFromGraphEntity } from '../../graph/graph.people';
1111import { Providers } from '../../Providers' ;
1212import { ProviderState } from '../../providers/IProvider' ;
1313import { getSvg , SvgIcon } from '../../utils/SvgHelper' ;
14+ import { TeamsHelper } from '../../utils/TeamsHelper' ;
1415import { IDynamicPerson , MgtPerson } from '../mgt-person/mgt-person' ;
1516import { MgtTemplatedComponent } from '../templatedComponent' ;
1617import { styles } from './mgt-person-card-css' ;
@@ -267,27 +268,31 @@ export class MgtPersonCard extends MgtTemplatedComponent {
267268 person = person || this . personDetails ;
268269 const userPerson = person as MicrosoftGraph . User ;
269270
271+ // Chat
270272 let chat : TemplateResult ;
271- let email : TemplateResult ;
272- let phone : TemplateResult ;
273-
274- if ( userPerson . mailNickname ) {
273+ if ( userPerson . userPrincipalName ) {
275274 chat = html `
276- < div class ="icon " @click =${ this . chatUser } >
275+ < div class ="icon " @click =${ ( ) => this . chatUser ( ) } >
277276 ${ getSvg ( SvgIcon . Chat , '#666666' ) }
278277 </ div >
279278 ` ;
280279 }
280+
281+ // Email
282+ let email : TemplateResult ;
281283 if ( getEmailFromGraphEntity ( person ) ) {
282284 email = html `
283285 < div class ="icon " @click =${ ( ) => this . emailUser ( ) } >
284286 ${ getSvg ( SvgIcon . Email , '#666666' ) }
285287 </ div >
286288 ` ;
287289 }
290+
291+ // Phone
292+ let phone : TemplateResult ;
288293 if ( userPerson . businessPhones && userPerson . businessPhones . length > 0 ) {
289294 phone = html `
290- < div class ="icon " @click =${ this . callUser } >
295+ < div class ="icon " @click =${ ( ) => this . callUser ( ) } >
291296 ${ getSvg ( SvgIcon . Phone , '#666666' ) }
292297 </ div >
293298 ` ;
@@ -378,27 +383,25 @@ export class MgtPersonCard extends MgtTemplatedComponent {
378383 */
379384 protected renderContactDetails ( person ?: IDynamicPerson ) : TemplateResult {
380385 person = person || this . personDetails ;
386+ const userPerson = person as MicrosoftGraph . User ;
381387
382388 if ( this . hasTemplate ( 'contact-details' ) ) {
383- return this . renderTemplate ( 'contact-details' , { person } ) ;
389+ return this . renderTemplate ( 'contact-details' , { userPerson } ) ;
384390 }
385391
386- const userPerson = person as MicrosoftGraph . User ;
387-
388- let phone : TemplateResult ;
389- let email : TemplateResult ;
390- let location : TemplateResult ;
392+ // Chat
391393 let chat : TemplateResult ;
392-
393- if ( userPerson . businessPhones && userPerson . businessPhones . length > 0 ) {
394- phone = html `
395- < div class ="details-icon " @click =${ this . callUser } >
396- ${ getSvg ( SvgIcon . SmallPhone , '#666666' ) }
397- < span class ="link-subtitle data "> ${ userPerson . businessPhones [ 0 ] } </ span >
394+ if ( userPerson . userPrincipalName ) {
395+ chat = html `
396+ < div class ="details-icon " @click =${ ( ) => this . chatUser ( ) } >
397+ ${ getSvg ( SvgIcon . SmallChat , '#666666' ) }
398+ < span class ="link-subtitle data "> ${ userPerson . userPrincipalName } </ span >
398399 </ div >
399400 ` ;
400401 }
401402
403+ // Email
404+ let email : TemplateResult ;
402405 if ( getEmailFromGraphEntity ( person ) ) {
403406 email = html `
404407 < div class ="details-icon " @click =${ ( ) => this . emailUser ( ) } >
@@ -408,15 +411,19 @@ export class MgtPersonCard extends MgtTemplatedComponent {
408411 ` ;
409412 }
410413
411- if ( userPerson . mailNickname ) {
412- chat = html `
413- < div class ="details-icon " @click =${ this . chatUser } >
414- ${ getSvg ( SvgIcon . SmallChat , '#666666' ) }
415- < span class ="link-subtitle data "> ${ userPerson . mailNickname } </ span >
414+ // Phone
415+ let phone : TemplateResult ;
416+ if ( userPerson . businessPhones && userPerson . businessPhones . length > 0 ) {
417+ phone = html `
418+ < div class ="details-icon " @click =${ ( ) => this . callUser ( ) } >
419+ ${ getSvg ( SvgIcon . SmallPhone , '#666666' ) }
420+ < span class ="link-subtitle data "> ${ userPerson . businessPhones [ 0 ] } </ span >
416421 </ div >
417422 ` ;
418423 }
419424
425+ // Location
426+ let location : TemplateResult ;
420427 if ( person . officeLocation ) {
421428 location = html `
422429 < div class ="details-icon ">
@@ -498,16 +505,27 @@ export class MgtPersonCard extends MgtTemplatedComponent {
498505 }
499506
500507 /**
501- * Use the sip: protocol to initiate a chat message to the user.
508+ * Initiate a chat message to the user via deeplink .
502509 *
503510 * @protected
504511 * @memberof MgtPersonCard
505512 */
506513 protected chatUser ( ) {
507514 const user = this . personDetails as MicrosoftGraph . User ;
508- if ( user && user . mailNickname ) {
509- const chat = user . mailNickname ;
510- window . open ( 'sip:' + chat , '_blank' ) ;
515+ if ( user && user . userPrincipalName ) {
516+ const users : string = user . userPrincipalName ;
517+ const url = `https://teams.microsoft.com/l/chat/0/0?users=${ users } ` ;
518+ const openWindow = ( ) => window . open ( url , '_blank' ) ;
519+
520+ if ( TeamsHelper . isAvailable ) {
521+ TeamsHelper . executeDeepLink ( url , ( status : boolean ) => {
522+ if ( ! status ) {
523+ openWindow ( ) ;
524+ }
525+ } ) ;
526+ } else {
527+ openWindow ( ) ;
528+ }
511529 }
512530 }
513531
0 commit comments