11import { exec , toast } from './kernelsu.js' ;
2- import { get_active_iface , get_active_algorithm , getInitcwndInitrwndValue , get_wifi_calling_state } from './common.js' ;
2+ import { get_active_iface , get_active_algorithm , getInitcwndInitrwndValue , get_wifi_calling_state , getModuleActiveState } from './common.js' ;
33import router_state from './router.js' ;
44
55export async function updateModuleStatus ( ) {
6+ var module_status = "Loading Module Status...⌛" ;
67 var active_iface = "None" ;
7- var active_iface_type = "Unknown ⁉️"
8+ var active_iface_type = "Unknown ⁉️" ;
89 var active_algorithm = "Unknown ⁉️" ;
910 var wifi_calling_state = "Unknown ⁉️" ;
1011 var active_InitcwndInitrwndValue = [ ] ;
1112 try
1213 {
14+ module_status = ( await getModuleActiveState ( ) ) == true ? "Enabled ✅" : "Disabled ❌" ;
1315 active_iface = await get_active_iface ( ) ;
1416 active_iface = active_iface ? active_iface : "None" ;
1517 active_iface_type = active_iface . startsWith ( "rmnet" ) || active_iface . startsWith ( "ccmni" ) ? "Cellular 📶" : active_iface . startsWith ( "wlan" ) ? "Wi-Fi 🛜" : "Unknown ⁉️" ;
@@ -24,6 +26,7 @@ export async function updateModuleStatus () {
2426 addLog ( 'Error updating status.' ) ;
2527 toast ( "Error updating status." ) ;
2628 } finally {
29+ router_state . homePageParams . module_status = module_status ;
2730 router_state . homePageParams . active_iface_type = active_iface_type ;
2831 router_state . homePageParams . active_iface = active_iface ;
2932 router_state . homePageParams . active_algorithm = active_algorithm ;
@@ -34,54 +37,71 @@ export async function updateModuleStatus () {
3437
3538export function updateHomeUI ( ) {
3639 if ( router_state . isInitializing == false ) {
37- document . getElementById ( 'active_iface_type_value' ) . textContent = router_state . homePageParams . active_iface_type ;
38- document . getElementById ( 'active_iface_value' ) . textContent = router_state . homePageParams . active_iface ;
39- document . getElementById ( 'tcp_cong_value' ) . textContent = router_state . homePageParams . active_algorithm ;
40-
41- const wifiCallingDiv = document . getElementById ( 'wifi_calling_value_div' ) ;
42- const wifiCallingSpan = document . getElementById ( 'wifi_calling_value' ) ;
43-
44- if ( router_state . homePageParams . active_iface_type == "Wi-Fi 🛜" )
40+ document . getElementById ( 'module_status_value' ) . textContent = router_state . homePageParams . module_status ;
41+ if ( router_state . homePageParams . module_status == "Enabled ✅" )
4542 {
46- if ( wifiCallingDiv ?. classList . contains ( 'hidden' ) )
47- wifiCallingDiv . classList . remove ( 'hidden' ) ;
43+ const ifaceTypeDiv = document . getElementById ( 'active_iface_type_div' ) ;
44+ const ifaceValDiv = document . getElementById ( 'active_iface_div' ) ;
45+ const tcpCongValDiv = document . getElementById ( 'tcp_cong_div' ) ;
4846
49- wifiCallingSpan . textContent = router_state . homePageParams . wifi_calling_state ;
50- }
51- else
52- {
53- if ( wifiCallingDiv . classList . contains ( 'hidden' ) )
54- wifiCallingDiv . classList . add ( 'hidden' ) ;
55- wifiCallingSpan . textContent = "Unknown ⁉️" ;
56- }
57-
58- const initcwndDiv = document . getElementById ( 'initcwnd_value_div' ) ;
59- const initrwndDiv = document . getElementById ( 'initrwnd_value_div' ) ;
60- const initcwndSpan = document . getElementById ( 'initcwnd_value' ) ;
61- const initrwndSpan = document . getElementById ( 'initrwnd_value' ) ;
62-
63- const values = router_state . homePageParams . active_InitcwndInitrwndValue ;
64- const isLoading = values . length < 2 && router_state . settingsPageParams . initcwndInitrwnd ;
65-
66- if ( values . length == 2 || isLoading )
67- {
68- if ( initcwndDiv ?. classList . contains ( 'hidden' ) )
69- initcwndDiv . classList . remove ( 'hidden' ) ;
47+ document . getElementById ( 'active_iface_type_value' ) . textContent = router_state . homePageParams . active_iface_type ;
48+ document . getElementById ( 'active_iface_value' ) . textContent = router_state . homePageParams . active_iface ;
49+ document . getElementById ( 'tcp_cong_value' ) . textContent = router_state . homePageParams . active_algorithm ;
7050
71- if ( initrwndDiv ?. classList . contains ( 'hidden' ) )
72- initrwndDiv . classList . remove ( 'hidden' ) ;
51+ if ( ifaceTypeDiv ?. classList . contains ( 'hidden' ) )
52+ ifaceTypeDiv . classList . remove ( 'hidden' ) ;
7353
74- initcwndSpan . textContent = values . length == 2 ? values [ 0 ] : "Loading initcwnd value..." ;
75- initrwndSpan . textContent = values . length == 2 ? values [ 1 ] : "Loading initrwnd value..." ;
76- }
77- else
78- {
79- // No data and not loading → hide the section
80- if ( initcwndDiv && ! initcwndDiv . classList . contains ( 'hidden' ) )
81- initcwndDiv . classList . add ( 'hidden' ) ;
54+ if ( ifaceValDiv ?. classList . contains ( 'hidden' ) )
55+ ifaceValDiv . classList . remove ( 'hidden' ) ;
56+
57+ if ( tcpCongValDiv ?. classList . contains ( 'hidden' ) )
58+ tcpCongValDiv . classList . remove ( 'hidden' ) ;
59+
60+ const wifiCallingDiv = document . getElementById ( 'wifi_calling_value_div' ) ;
61+ const wifiCallingSpan = document . getElementById ( 'wifi_calling_value' ) ;
62+
63+ if ( router_state . homePageParams . active_iface_type == "Wi-Fi 🛜" )
64+ {
65+ if ( wifiCallingDiv ?. classList . contains ( 'hidden' ) )
66+ wifiCallingDiv . classList . remove ( 'hidden' ) ;
67+
68+ wifiCallingSpan . textContent = router_state . homePageParams . wifi_calling_state ;
69+ }
70+ else
71+ {
72+ if ( wifiCallingDiv . classList . contains ( 'hidden' ) )
73+ wifiCallingDiv . classList . add ( 'hidden' ) ;
74+ wifiCallingSpan . textContent = "Unknown ⁉️" ;
75+ }
76+
77+ const initcwndDiv = document . getElementById ( 'initcwnd_value_div' ) ;
78+ const initrwndDiv = document . getElementById ( 'initrwnd_value_div' ) ;
79+ const initcwndSpan = document . getElementById ( 'initcwnd_value' ) ;
80+ const initrwndSpan = document . getElementById ( 'initrwnd_value' ) ;
81+
82+ const values = router_state . homePageParams . active_InitcwndInitrwndValue ;
83+ const isLoading = values . length < 2 && router_state . settingsPageParams . initcwndInitrwnd ;
8284
83- if ( initrwndDiv && ! initrwndDiv . classList . contains ( 'hidden' ) )
84- initrwndDiv . classList . add ( 'hidden' ) ;
85+ if ( values . length == 2 || isLoading )
86+ {
87+ if ( initcwndDiv ?. classList . contains ( 'hidden' ) )
88+ initcwndDiv . classList . remove ( 'hidden' ) ;
89+
90+ if ( initrwndDiv ?. classList . contains ( 'hidden' ) )
91+ initrwndDiv . classList . remove ( 'hidden' ) ;
92+
93+ initcwndSpan . textContent = values . length == 2 ? values [ 0 ] : "Loading initcwnd value..." ;
94+ initrwndSpan . textContent = values . length == 2 ? values [ 1 ] : "Loading initrwnd value..." ;
95+ }
96+ else
97+ {
98+ // No data and not loading → hide the section
99+ if ( initcwndDiv && ! initcwndDiv . classList . contains ( 'hidden' ) )
100+ initcwndDiv . classList . add ( 'hidden' ) ;
101+
102+ if ( initrwndDiv && ! initrwndDiv . classList . contains ( 'hidden' ) )
103+ initrwndDiv . classList . add ( 'hidden' ) ;
104+ }
85105 }
86106 }
87107}
0 commit comments