@@ -32,38 +32,38 @@ export class MainThreadLayout extends Disposable implements IMainThreadLayout {
32
32
}
33
33
34
34
$setTitle ( id : string , title : string ) : void {
35
- this . getHandler ( id ) . updateTitle ( title ) ;
35
+ this . getHandler ( id ) ? .updateTitle ( title ) ;
36
36
}
37
37
38
38
$setIcon ( id : string , iconPath : string ) : void {
39
39
const iconClass = this . iconService . fromIcon ( '' , iconPath , IconType . Background , IconShape . Square ) ;
40
- this . getHandler ( id ) . setIconClass ( iconClass ! ) ;
40
+ this . getHandler ( id ) ? .setIconClass ( iconClass ! ) ;
41
41
}
42
42
43
43
$setSize ( id : string , size : number ) : void {
44
- this . getHandler ( id ) . setSize ( size ) ;
44
+ this . getHandler ( id ) ? .setSize ( size ) ;
45
45
}
46
46
47
47
$activate ( id : string ) : void {
48
- this . getHandler ( id ) . activate ( ) ;
48
+ this . getHandler ( id ) ? .activate ( ) ;
49
49
}
50
50
51
51
$deactivate ( id : string ) : void {
52
- this . getHandler ( id ) . deactivate ( ) ;
52
+ this . getHandler ( id ) ? .deactivate ( ) ;
53
53
}
54
54
55
55
$setBadge ( id : string , badge : string ) : void {
56
- this . getHandler ( id ) . setBadge ( badge ) ;
56
+ this . getHandler ( id ) ? .setBadge ( badge ) ;
57
57
}
58
58
59
59
async $setVisible ( id : string , visible : boolean ) {
60
60
if ( visible ) {
61
- this . getHandler ( id ) . show ( ) ;
61
+ this . getHandler ( id ) ? .show ( ) ;
62
62
} else {
63
- if ( this . getHandler ( id ) . isActivated ( ) ) {
64
- this . getHandler ( id ) . deactivate ( ) ;
63
+ if ( this . getHandler ( id ) ? .isActivated ( ) ) {
64
+ this . getHandler ( id ) ? .deactivate ( ) ;
65
65
}
66
- this . getHandler ( id ) . hide ( ) ;
66
+ this . getHandler ( id ) ? .hide ( ) ;
67
67
}
68
68
}
69
69
@@ -75,8 +75,10 @@ export class MainThreadLayout extends Disposable implements IMainThreadLayout {
75
75
} else {
76
76
const disposer = this . eventBus . on ( TabBarRegistrationEvent , ( e ) => {
77
77
if ( e . payload . tabBarId === id ) {
78
- const handle = this . layoutService . getTabbarHandler ( id ) ;
79
- this . bindHandleEvents ( handle ! ) ;
78
+ const handler = this . layoutService . getTabbarHandler ( id ) ;
79
+ if ( handler ) {
80
+ this . bindHandleEvents ( handler ) ;
81
+ }
80
82
disposer . dispose ( ) ;
81
83
}
82
84
} ) ;
@@ -103,8 +105,8 @@ export class MainThreadLayout extends Disposable implements IMainThreadLayout {
103
105
protected getHandler ( id : string ) {
104
106
const handler = this . layoutService . getTabbarHandler ( id ) ;
105
107
if ( ! handler ) {
106
- this . logger . warn ( `MainThreaLayout:没有找到 ${ id } 对应的handler ` ) ;
108
+ this . logger . warn ( `Could not find a handler with \` ${ id } \` ` ) ;
107
109
}
108
- return handler ! ;
110
+ return handler ;
109
111
}
110
112
}
0 commit comments