@@ -27,12 +27,11 @@ export async function init(options: {
2727 initSDK ( )
2828
2929 // Add Eruda if needed.
30- if ( options . eruda ) {
31- import ( 'eruda' ) . then ( ( { default : eruda } ) => {
32- eruda . init ( )
33- eruda . position ( { x : window . innerWidth - 50 , y : 0 } )
34- } )
35- }
30+ options . eruda
31+ && void import ( 'eruda' ) . then ( ( { default : eruda } ) => {
32+ eruda . init ( )
33+ eruda . position ( { x : window . innerWidth - 50 , y : 0 } )
34+ } )
3635
3736 // Telegram for macOS has a ton of bugs, including cases, when the client doesn't
3837 // even response to the "web_app_request_theme" method. It also generates an incorrect
@@ -49,16 +48,18 @@ export async function init(options: {
4948 firstThemeSent = true
5049 tp ||= retrieveLaunchParams ( ) . tgWebAppThemeParams
5150 }
52- return emitEvent ( 'theme_changed' , { theme_params : tp } )
51+ emitEvent ( 'theme_changed' , { theme_params : tp } )
52+ return
5353 }
5454
5555 if ( event . name === 'web_app_request_safe_area' ) {
56- return emitEvent ( 'safe_area_changed' , {
56+ emitEvent ( 'safe_area_changed' , {
5757 left : 0 ,
5858 top : 0 ,
5959 right : 0 ,
6060 bottom : 0 ,
6161 } )
62+ return
6263 }
6364
6465 next ( )
@@ -77,30 +78,31 @@ export async function init(options: {
7778 }
7879
7980 if ( viewport . mount . isAvailable ( ) ) {
80- viewport . mount ( ) . then ( ( ) => {
81- viewport . bindCssVars ( )
81+ await viewport . mount ( )
82+ viewport . bindCssVars ( )
8283
83- if ( viewport . requestFullscreen . isAvailable ( ) ) {
84- viewport . requestFullscreen ( ) . finally ( ( ) => {
85- // Wait
86- setTimeout ( ( ) => {
87- // The app is now in fullscreen
88- if ( window . innerWidth > 600 ) {
89- // Application should be in fullscreen mode only on small screens!
90- viewport . exitFullscreen ( )
91- }
92- } , 50 )
93- } )
94- }
95- } )
84+ if ( viewport . requestFullscreen . isAvailable ( ) ) {
85+ await viewport . requestFullscreen ( )
86+
87+ setTimeout ( ( ) => {
88+ // The app is now in fullscreen
89+ if ( window . innerWidth > 600 ) {
90+ // Application should be in fullscreen mode only on small screens!
91+ viewport . exitFullscreen ( )
92+ }
93+ } , 100 )
94+ }
9695 }
9796
98- closingBehavior . mount . ifAvailable ( )
99- closingBehavior . enableConfirmation . ifAvailable ( )
97+ if ( closingBehavior . mount . isAvailable ( ) ) {
98+ closingBehavior . mount ( )
99+ closingBehavior . enableConfirmation ( )
100+ }
100101
101- // Disable vertical swipes to prevent app close
102- swipeBehavior . mount . ifAvailable ( )
103- swipeBehavior . disableVertical . ifAvailable ( )
102+ if ( swipeBehavior . mount . isAvailable ( ) ) {
103+ swipeBehavior . mount ( )
104+ swipeBehavior . disableVertical ( )
105+ }
104106
105107 // Orientation lock
106108 postEvent ( 'web_app_toggle_orientation_lock' , {
0 commit comments