@@ -167,6 +167,7 @@ export class HistoryAndNortConvsComponent extends WsSharedComponent implements O
167167
168168 date_picker_is_disabled : boolean ;
169169 projectUsersArray : any ;
170+ other_project_users_that_has_abandoned_array : Array < any > ;
170171 requestWillBePermanentlyDeleted : string ;
171172 selectedRequestWillBePermanentDeleted : string ;
172173 selectedRequestsWasSuccessfullyDeleted : string ;
@@ -1582,6 +1583,123 @@ export class HistoryAndNortConvsComponent extends WsSharedComponent implements O
15821583 request [ 'requester_is_verified' ] = false ;
15831584 }
15841585
1586+ // ------------------------------------------------------------------------------------------
1587+ // for the tooltip on the icon of unserved conversations showing last users who have left the chat
1588+ // ------------------------------------------------------------------------------------------
1589+ if ( request . status === 150 && request . attributes && request . attributes . last_abandoned_by_project_user ) {
1590+
1591+ this . logger . log ( '[HISTORY & NORT-CONVS] - for the tooltip - request.attributes' , request . attributes )
1592+
1593+ const project_user_id = request . attributes . last_abandoned_by_project_user ;
1594+ this . logger . log ( '[HISTORY & NORT-CONVS] - LAST PROJECT-USER THAT HAS ABANDONED project_user_id' , project_user_id )
1595+
1596+ const users_found_in_storage_by_projectuserid = this . usersLocalDbService . getMemberFromStorage ( project_user_id ) ;
1597+ this . logger . log ( '[HISTORY & NORT-CONVS] - LAST PROJECT-USER THAT HAS ABANDONED project_users_found_in_storage' , users_found_in_storage_by_projectuserid )
1598+
1599+ if ( users_found_in_storage_by_projectuserid !== null ) {
1600+ this . logger . log ( '[HISTORY & NORT-CONVS] - LAST PROJECT-USER THAT HAS ABANDONED project_users_found_in_storage 1' , users_found_in_storage_by_projectuserid )
1601+ this . createArrayLast_abandoned_by_project_user ( users_found_in_storage_by_projectuserid , request )
1602+ } else {
1603+
1604+ this . usersService . getProjectUserByProjecUserId ( project_user_id )
1605+ . subscribe ( ( projectuser ) => {
1606+ this . logger . log ( '[HISTORY & NORT-CONVS] - LAST PROJECT-USER THAT HAS ABANDONED getProjectUserById RES' , projectuser )
1607+
1608+ let imgUrl = ''
1609+ if ( this . UPLOAD_ENGINE_IS_FIREBASE === true ) {
1610+ imgUrl = "https://firebasestorage.googleapis.com/v0/b/" + this . storageBucket + "/o/profiles%2F" + projectuser [ 'id_user' ] . _id + "%2Fphoto.jpg?alt=media"
1611+ } else {
1612+ imgUrl = this . baseUrl + "images?path=uploads%2Fusers%2F" + projectuser [ 'id_user' ] . _id + "%2Fimages%2Fthumbnails_200_200-photo.jpg"
1613+ this . logger . log ( '[HISTORY & NORT-CONVS] - LAST PROJECT-USER THAT HAS ABANDONED has image ' , imgUrl )
1614+ }
1615+ this . checkImageExists ( imgUrl , ( existsImage ) => {
1616+ if ( existsImage == true ) {
1617+ projectuser [ 'id_user' ] . hasImage = true
1618+ }
1619+ else {
1620+ projectuser [ 'id_user' ] . hasImage = false
1621+
1622+ this . createAgentAvatar ( projectuser [ 'id_user' ] )
1623+ }
1624+
1625+ this . usersLocalDbService . saveMembersInStorage ( projectuser [ 'id_user' ] . _id , projectuser [ 'id_user' ] , 'history-and-nort-convs' ) ;
1626+ this . usersLocalDbService . saveUserInStorageWithProjectUserId ( projectuser [ '_id' ] , projectuser [ 'id_user' ] ) ;
1627+
1628+ this . createArrayLast_abandoned_by_project_user ( projectuser [ 'id_user' ] , request ) ;
1629+ } )
1630+ } , error => {
1631+ // this.showSpinner = false;
1632+ this . logger . error ( '[HISTORY & NORT-CONVS] - LAST PROJECT-USER THAT HAS ABANDONED getProjectUserById - ERROR' , error ) ;
1633+ } , ( ) => {
1634+ this . logger . log ( '[HISTORY & NORT-CONVS] - LAST PROJECT-USER THAT HAS ABANDONED getProjectUserById - COMPLETE' )
1635+ } ) ;
1636+ }
1637+ }
1638+
1639+ // ------------------------------------------------------------------------------------------
1640+ // for the tooltip on the icon of unserved conversations showing users who have left the chat
1641+ // ------------------------------------------------------------------------------------------
1642+ if ( request . status === 150 && request . attributes && request . attributes && request . attributes . abandoned_by_project_users ) {
1643+ this . other_project_users_that_has_abandoned_array = [ ]
1644+ for ( const [ key , value ] of Object . entries ( request . attributes . abandoned_by_project_users ) ) {
1645+ this . logger . log ( '[HISTORY & NORT-CONVS] - OTHERS PROJECT-USER THAT HAVE ABANDONED key:value ' , `${ key } : ${ value } ` ) ;
1646+
1647+ if ( key !== request . attributes . last_abandoned_by_project_user ) {
1648+
1649+ const other_project_users_found = this . usersLocalDbService . getMemberFromStorage ( key ) ;
1650+
1651+ this . logger . log ( '[HISTORY & NORT-CONVS] - LAST PROJECT-USER THAT HAS ABANDONED other_project_users_found' , other_project_users_found )
1652+ if ( other_project_users_found !== null ) {
1653+ this . logger . log ( '[HISTORY & NORT-CONVS] - OTHER PROJECT-USER THAT HAS ABANDONED other_project_users_found 1' , other_project_users_found )
1654+ this . createArrayOther_project_users_that_has_abandoned ( other_project_users_found )
1655+
1656+ } else {
1657+
1658+ this . usersService . getProjectUserByProjecUserId ( key )
1659+ . subscribe ( ( projectuser ) => {
1660+ this . logger . log ( '[HISTORY & NORT-CONVS] - OTHER PROJECT-USER THAT HAS ABANDONED getProjectUserById RES' , projectuser )
1661+
1662+ let imgUrl = ''
1663+ if ( this . UPLOAD_ENGINE_IS_FIREBASE === true ) {
1664+ imgUrl = "https://firebasestorage.googleapis.com/v0/b/" + this . storageBucket + "/o/profiles%2F" + projectuser [ 'id_user' ] . _id + "%2Fphoto.jpg?alt=media"
1665+ } else {
1666+ imgUrl = this . baseUrl + "images?path=uploads%2Fusers%2F" + projectuser [ 'id_user' ] . _id + "%2Fimages%2Fthumbnails_200_200-photo.jpg"
1667+ this . logger . log ( '[HISTORY & NORT-CONVS] - OTHER PROJECT-USER THAT HAS ABANDONED has image ' , imgUrl )
1668+ }
1669+ this . checkImageExists ( imgUrl , ( existsImage ) => {
1670+ if ( existsImage == true ) {
1671+ projectuser [ 'id_user' ] . hasImage = true
1672+ }
1673+ else {
1674+ projectuser [ 'id_user' ] . hasImage = false
1675+
1676+ this . createAgentAvatar ( projectuser [ 'id_user' ] )
1677+ }
1678+
1679+ this . usersLocalDbService . saveMembersInStorage ( projectuser [ 'id_user' ] . _id , projectuser [ 'id_user' ] , 'history-and-nort-convs' ) ;
1680+ this . usersLocalDbService . saveUserInStorageWithProjectUserId ( projectuser [ '_id' ] , projectuser [ 'id_user' ] ) ;
1681+ } )
1682+
1683+ } , error => {
1684+
1685+ this . logger . error ( '[HISTORY & NORT-CONVS] - OTHER PROJECT-USER THAT HAS ABANDONED getProjectUserById - ERROR' , error ) ;
1686+ } , ( ) => {
1687+ this . logger . log ( '[HISTORY & NORT-CONVS] - OTHER PROJECT-USER THAT HAS ABANDONED getProjectUserById - COMPLETE' )
1688+
1689+ const _other_project_users_found = this . usersLocalDbService . getMemberFromStorage ( key ) ;
1690+ this . logger . log ( '[HISTORY & NORT-CONVS] - OTHER PROJECT-USER THAT HAS ABANDONED other_project_users_found 2' , _other_project_users_found )
1691+
1692+ if ( _other_project_users_found ) {
1693+ this . createArrayOther_project_users_that_has_abandoned ( _other_project_users_found )
1694+ }
1695+ } ) ;
1696+ }
1697+ this . logger . log ( '[HISTORY & NORT-CONVS] - LAST PROJECT-USER THAT HAS ABANDONED other_project_users_that_has_abandoned_array' , this . other_project_users_that_has_abandoned_array )
1698+ request [ 'attributes' ] [ 'other_project_users_that_has_abandoned_array' ] = this . other_project_users_that_has_abandoned_array
1699+ }
1700+ }
1701+ }
1702+
15851703 if ( request . department ) {
15861704 const deptHasName = request . department . hasOwnProperty ( 'name' )
15871705 if ( deptHasName ) {
@@ -3427,4 +3545,50 @@ export class HistoryAndNortConvsComponent extends WsSharedComponent implements O
34273545 } )
34283546 }
34293547
3548+ createArrayLast_abandoned_by_project_user ( user , request ) {
3549+ let imgUrl = ''
3550+ if ( this . UPLOAD_ENGINE_IS_FIREBASE === true ) {
3551+ imgUrl = "https://firebasestorage.googleapis.com/v0/b/" + this . storageBucket + "/o/profiles%2F" + user [ '_id' ] + "%2Fphoto.jpg?alt=media"
3552+ } else {
3553+ imgUrl = this . baseUrl + "images?path=uploads%2Fusers%2F" + user [ '_id' ] + "%2Fimages%2Fthumbnails_200_200-photo.jpg"
3554+ }
3555+
3556+ const last_abandoned_by_project_user_array = [ ]
3557+ last_abandoned_by_project_user_array . push (
3558+ {
3559+ _id : user [ '_id' ] ,
3560+ firstname : user [ 'firstname' ] ,
3561+ lastname : user [ 'lastname' ] ,
3562+ has_image : user [ 'hasImage' ] ,
3563+ img_url : imgUrl ,
3564+ fillColour : user [ 'fillColour' ] ,
3565+ fullname_initial : user [ 'fullname_initial' ]
3566+ }
3567+ )
3568+ request [ 'attributes' ] [ 'last_abandoned_by_project_user_array' ] = last_abandoned_by_project_user_array
3569+ }
3570+
3571+ createArrayOther_project_users_that_has_abandoned ( other_project_users_found ) {
3572+
3573+ this . logger . log ( '[HISTORY & NORT-CONVS] createArrayOther_project_users_that_has_abandoned other_project_users_found' , other_project_users_found )
3574+ let imgUrl = ''
3575+ if ( this . UPLOAD_ENGINE_IS_FIREBASE === true ) {
3576+ imgUrl = "https://firebasestorage.googleapis.com/v0/b/" + this . storageBucket + "/o/profiles%2F" + other_project_users_found [ '_id' ] + "%2Fphoto.jpg?alt=media"
3577+ } else {
3578+ imgUrl = this . baseUrl + "images?path=uploads%2Fusers%2F" + other_project_users_found [ '_id' ] + "%2Fimages%2Fthumbnails_200_200-photo.jpg"
3579+ }
3580+
3581+ this . other_project_users_that_has_abandoned_array . push (
3582+ {
3583+ _id : other_project_users_found [ '_id' ] ,
3584+ firstname : other_project_users_found [ 'firstname' ] ,
3585+ lastname : other_project_users_found [ 'lastname' ] ,
3586+ has_image : other_project_users_found [ 'hasImage' ] ,
3587+ img_url : imgUrl ,
3588+ fillColour : other_project_users_found [ 'fillColour' ] ,
3589+ fullname_initial : other_project_users_found [ 'fullname_initial' ]
3590+ }
3591+ )
3592+ }
3593+
34303594}
0 commit comments