11import { t } from "@vscode/l10n" ;
2- import { TreeItemCollapsibleState } from "vscode" ;
2+ import { TreeItemCollapsibleState , Uri } from "vscode" ;
33import { type ApiVscodeUser , type UserTreeItemData } from "../@types" ;
44import BaseTreeItem from "./BaseTreeItem" ;
55import UserChildTreeItem from "./UserChildTreeItem" ;
@@ -21,27 +21,30 @@ export default class UserTreeItem extends BaseTreeItem<UserChildTreeItem> {
2121 protected _patch ( data : Partial < UserTreeItemData & ApiVscodeUser > ) : this {
2222 if ( ! data ) return this ;
2323
24+ if ( data . avatar )
25+ this . iconPath = Uri . parse ( data . avatar ) ;
26+
2427 super . _patch ( data ) ;
2528
26- if ( data . userName !== undefined )
27- this . label = data . userName + ` (${ this . userID } )` ;
29+ if ( data . username )
30+ this . label = data . username + ` (${ this . userID } )` ;
2831
2932 if ( data . children instanceof Map ) {
3033 for ( const [ id , child ] of data . children ) {
3134 this . children . set ( id , child ) ;
3235 }
3336 }
3437
35- if ( data . ramUsedMb !== undefined && data . totalRamMb !== undefined )
38+ if ( typeof data . ramUsedMb === "number" && typeof data . totalRamMb === "number" )
3639 this . _addChild ( "ram" , {
3740 label : `${ data . ramUsedMb } /${ data . totalRamMb } ` ,
3841 description : t ( "label.available.ram" ) ,
3942 userID : this . userID ,
4043 } ) ;
4144
42- if ( data . plan !== undefined )
45+ if ( data . plan )
4346 this . _addChild ( "plan" , {
44- label : data . plan ! ,
47+ label : data . plan ,
4548 description : t ( "plan" ) ,
4649 userID : this . userID ,
4750 } ) ;
@@ -55,37 +58,37 @@ export default class UserTreeItem extends BaseTreeItem<UserChildTreeItem> {
5558 userID : this . userID ,
5659 } ) ;
5760
58- if ( data . locale !== undefined )
61+ if ( data . locale )
5962 this . _addChild ( "locale" , {
60- label : data . locale ! ,
63+ label : data . locale ,
6164 description : t ( "locale" ) ,
6265 userID : this . userID ,
6366 } ) ;
6467
65- if ( data . apps !== undefined )
68+ if ( data . apps )
6669 this . _addChild ( "apps" , {
67- label : `${ data . apps ? .length ?? 0 } ` ,
70+ label : `${ data . apps . length } ` ,
6871 description : t ( "label.apps.amount" ) ,
6972 userID : this . userID ,
7073 } ) ;
7174
72- if ( data . appsTeam !== undefined )
75+ if ( data . appsTeam )
7376 this . _addChild ( "team" , {
74- label : `${ data . appsTeam ? .length ?? 0 } ` ,
77+ label : `${ data . appsTeam . length } ` ,
7578 description : t ( "label.team.apps.amount" ) ,
7679 userID : this . userID ,
7780 } ) ;
7881
79- if ( data . customdomains !== undefined )
82+ if ( data . customdomains )
8083 this . _addChild ( "domains" , {
81- label : `${ data . customdomains ? .length ?? 0 } ` ,
84+ label : `${ data . customdomains . length } ` ,
8285 description : t ( "label.domains.amount" ) ,
8386 userID : this . userID ,
8487 } ) ;
8588
86- if ( data . subdomains !== undefined )
89+ if ( data . subdomains )
8790 this . _addChild ( "subdomains" , {
88- label : `${ data . subdomains ? .length ?? 0 } ` ,
91+ label : `${ data . subdomains . length } ` ,
8992 description : t ( "label.subdomains.amount" ) ,
9093 userID : this . userID ,
9194 } ) ;
0 commit comments