@@ -66,17 +66,20 @@ async def init_tasks(self):
66
66
self ._latest_tasks_inited = self .page .loop .time ()
67
67
68
68
async def on_window_event (self , event : ft .WindowEvent ):
69
- logging .info (f"Window event: { event .type } " )
70
69
if (
71
70
event .type == ft .WindowEventType .MINIMIZE
72
71
or event .type == ft .WindowEventType .HIDE
72
+ or event .type == ft .WindowEventType .BLUR
73
73
):
74
74
# kill all tasks when window is minimized
75
75
self ._server_status_task .cancel ()
76
76
self ._check_launcher_updates_task .cancel ()
77
77
self ._check_modpack_update_task .cancel ()
78
78
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
+ ):
80
83
# restart tasks when window is restored
81
84
await self .init_tasks ()
82
85
@@ -105,14 +108,14 @@ async def _check_launcher_updates(self):
105
108
self .page .update ()
106
109
107
110
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 )
109
112
while True :
110
113
await asyncio .sleep (60 )
111
114
await asyncio .to_thread (self ._check_modpack_update )
112
115
113
- def _check_modpack_update (self ):
116
+ def _check_modpack_update (self , force : bool = False ):
114
117
if self .page :
115
- modpack ._fetch_latest_index ()
118
+ modpack ._fetch_latest_index (force = force )
116
119
if modpack .is_up_to_date ():
117
120
return
118
121
if modpack .installed_version == "unknown" :
@@ -457,10 +460,10 @@ async def _server_status_update(self):
457
460
while True :
458
461
try :
459
462
await asyncio .to_thread (self ._update_server_status )
460
- await asyncio .sleep (10 )
463
+ await asyncio .sleep (5 )
461
464
except Exception as e :
462
465
logging .info (f"Error updating server status: { e } " )
463
- await asyncio .sleep (10 )
466
+ await asyncio .sleep (5 )
464
467
465
468
async def _playtime_update (self ):
466
469
while True :
@@ -528,10 +531,10 @@ def _check_game(self, event: ft.TapEvent):
528
531
self ._install_minecraft ()
529
532
# check if modpack version is latest
530
533
elif not modpack .is_up_to_date ():
531
- self ._update_modpack ()
534
+ self ._update_modpack (event )
532
535
# check if modpack installed correctly
533
536
elif not modpack .verify_installation ():
534
- self ._update_modpack ()
537
+ self ._update_modpack (event )
535
538
else :
536
539
self ._launch_minecraft (modpack .modloader_full )
537
540
@@ -633,7 +636,7 @@ def _install_minecraft(self):
633
636
if self .page is not None :
634
637
self .page .update ()
635
638
636
- def _update_modpack (self ):
639
+ def _update_modpack (self , event : ft . TapEvent ):
637
640
logging .info ("Updating modpack..." )
638
641
self ._progress_bar .visible = True
639
642
self ._progress_text .visible = True
@@ -654,12 +657,9 @@ def _update_modpack(self):
654
657
self ._check_game_button_enable ()
655
658
self ._play_button_enable ()
656
659
# 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
+ )
663
663
664
664
if self .page is not None :
665
665
self .page .update ()
0 commit comments