@@ -69,18 +69,25 @@ class FlashMessage {
69
69
return this . level ;
70
70
}
71
71
}
72
-
72
+ const flashM = new FlashMessage ( '' , 1 ) ;
73
+ const defaultFlashState = {
74
+ getMessages : function ( ) : FlashMessage [ ] {
75
+ return [ flashM ] ;
76
+ } ,
77
+ addMessage : function ( msg : string , level : FlashLevel ) : void { } ,
78
+ hideMessage : function ( index : string ) : void { } ,
79
+ } ;
73
80
// the flash context handles flash messages across the app
74
- export const FlashContext = createContext < FlashState > ( undefined ) ;
81
+ export const FlashContext = createContext < FlashState > ( defaultFlashState ) ;
75
82
76
83
// the proxy state provides the proxy address across all the app
77
84
export interface ProxyState {
78
85
getProxy ( ) : string ;
79
- setProxy ( p : string ) ;
86
+ setProxy ( p : string ) : void ;
80
87
}
81
88
82
89
export class ProxyHolder implements ProxyState {
83
- proxy : string ;
90
+ proxy ! : string ;
84
91
85
92
getProxy ( ) : string {
86
93
return this . proxy ;
@@ -145,7 +152,7 @@ const Failed: FC = ({ children }) => (
145
152
// and displays flash messages.
146
153
const AppContainer = ( ) => {
147
154
const [ content , setContent ] = useState < ReactElement > ( < Loading /> ) ;
148
- const [ auth , setAuth ] = useState < AuthState > ( undefined ) ;
155
+ const [ auth , setAuth ] = useState < AuthState > ( defaultAuth ) ;
149
156
150
157
const [ flashes , setFlashes ] = useState < FlashMessage [ ] > ( [ ] ) ;
151
158
@@ -226,7 +233,7 @@ const AppContainer = () => {
226
233
await setDefaultProxy ( ) ;
227
234
228
235
setContent ( < App /> ) ;
229
- } catch ( e ) {
236
+ } catch ( e : any ) {
230
237
setContent ( < Failed > { e . toString ( ) } </ Failed > ) ;
231
238
console . log ( 'error:' , e ) ;
232
239
}
0 commit comments