@@ -66,17 +66,20 @@ async def init_tasks(self):
6666 self ._latest_tasks_inited = self .page .loop .time ()
6767
6868 async def on_window_event (self , event : ft .WindowEvent ):
69- logging .info (f"Window event: { event .type } " )
7069 if (
7170 event .type == ft .WindowEventType .MINIMIZE
7271 or event .type == ft .WindowEventType .HIDE
72+ or event .type == ft .WindowEventType .BLUR
7373 ):
7474 # kill all tasks when window is minimized
7575 self ._server_status_task .cancel ()
7676 self ._check_launcher_updates_task .cancel ()
7777 self ._check_modpack_update_task .cancel ()
7878 self ._playtime_update_task .cancel ()
79- elif event .type == ft .WindowEventType .FOCUS or event .type == ft .WindowEventType .RESTORE :
79+ elif (
80+ event .type == ft .WindowEventType .FOCUS
81+ or event .type == ft .WindowEventType .RESTORE
82+ ):
8083 # restart tasks when window is restored
8184 await self .init_tasks ()
8285
@@ -105,14 +108,14 @@ async def _check_launcher_updates(self):
105108 self .page .update ()
106109
107110 async def _check_modpack_update_async (self ):
108- await asyncio .to_thread (self ._check_modpack_update )
111+ await asyncio .to_thread (self ._check_modpack_update , force = True )
109112 while True :
110113 await asyncio .sleep (60 )
111114 await asyncio .to_thread (self ._check_modpack_update )
112115
113- def _check_modpack_update (self ):
116+ def _check_modpack_update (self , force : bool = False ):
114117 if self .page :
115- modpack ._fetch_latest_index ()
118+ modpack ._fetch_latest_index (force = force )
116119 if modpack .is_up_to_date ():
117120 return
118121 if modpack .installed_version == "unknown" :
@@ -457,10 +460,10 @@ async def _server_status_update(self):
457460 while True :
458461 try :
459462 await asyncio .to_thread (self ._update_server_status )
460- await asyncio .sleep (10 )
463+ await asyncio .sleep (5 )
461464 except Exception as e :
462465 logging .info (f"Error updating server status: { e } " )
463- await asyncio .sleep (10 )
466+ await asyncio .sleep (5 )
464467
465468 async def _playtime_update (self ):
466469 while True :
@@ -528,10 +531,10 @@ def _check_game(self, event: ft.TapEvent):
528531 self ._install_minecraft ()
529532 # check if modpack version is latest
530533 elif not modpack .is_up_to_date ():
531- self ._update_modpack ()
534+ self ._update_modpack (event )
532535 # check if modpack installed correctly
533536 elif not modpack .verify_installation ():
534- self ._update_modpack ()
537+ self ._update_modpack (event )
535538 else :
536539 self ._launch_minecraft (modpack .modloader_full )
537540
@@ -633,7 +636,7 @@ def _install_minecraft(self):
633636 if self .page is not None :
634637 self .page .update ()
635638
636- def _update_modpack (self ):
639+ def _update_modpack (self , event : ft . TapEvent ):
637640 logging .info ("Updating modpack..." )
638641 self ._progress_bar .visible = True
639642 self ._progress_text .visible = True
@@ -654,12 +657,9 @@ def _update_modpack(self):
654657 self ._check_game_button_enable ()
655658 self ._play_button_enable ()
656659 # update version column
657- self ._version_column .controls [
658- 0
659- ].value = f"Встановлена версія: { modpack .installed_version } "
660- self ._version_column .controls [
661- 1
662- ].value = f"Остання версія: { modpack .remote_version } "
660+ self ._version_tooltip .message = (
661+ f"Встановлено останню версію: { modpack .installed_version } "
662+ )
663663
664664 if self .page is not None :
665665 self .page .update ()
0 commit comments