File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -87,10 +87,7 @@ class VirtualNetworkInterface {
87
87
}
88
88
89
89
// This waits for the Worker to be done with the setup
90
- async setupHandler ( e : MessageEvent ) {
91
- if ( ! secret ) {
92
- await get_decrypted_secret ( ) ;
93
- }
90
+ setupHandler ( e : MessageEvent ) {
94
91
if ( e . data === "started" ) {
95
92
this . worker . onmessage = ( e ) => this . handleWorkerMessage ( e ) ;
96
93
const message_data : SetupMessage = {
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import { ChargerListComponent } from "../components/charger_list";
23
23
import { connected } from "../components/Navbar" ;
24
24
import Median from "median-js-bridge" ;
25
25
import { get_decrypted_secret , secret } from "../utils" ;
26
+ import { Row , Spinner } from "react-bootstrap" ;
26
27
27
28
export interface ChargersState {
28
29
connected : boolean ;
@@ -41,23 +42,33 @@ export function ChargerList() {
41
42
const [ loaded , setLoaded ] = useState ( false ) ;
42
43
43
44
if ( Median . isNativeApp ( ) && ! loaded ) {
44
- setTimeout ( ( ) => {
45
+ setTimeout ( async ( ) => {
46
+ if ( ! secret ) {
47
+ await get_decrypted_secret ( ) ;
48
+ }
49
+ setLoaded ( true ) ;
45
50
const currentConnection = sessionStorage . getItem ( "currentConnection" ) ;
46
51
try {
47
52
const currentConnectionObject : ChargersState = JSON . parse ( currentConnection ) ;
48
53
if ( currentConnectionObject . connected ) {
49
54
setState ( currentConnectionObject ) ;
50
- setLoaded ( true )
51
55
}
52
56
} catch { }
53
57
} ) ;
58
+ } else if ( ! loaded ) {
59
+ setLoaded ( true ) ;
54
60
}
55
61
56
62
useEffect ( ( ) => {
57
63
connected . value = state . connected ;
58
64
document . title = state . connectedName == "" ? "Remote Access" : state . connectedName ;
59
65
} , [ state ] )
60
66
67
+ if ( ! loaded ) {
68
+ return < Row className = "align-content-center justify-content-center m-0 h-100" >
69
+ < Spinner className = "p-3" animation = 'border' variant = 'primary' />
70
+ </ Row >
71
+ }
61
72
if ( ! state . connected ) {
62
73
return < >
63
74
< ChargerListComponent setParentState = { setState } parentState = { state } />
You can’t perform that action at this time.
0 commit comments