@@ -206,37 +206,22 @@ export const Provider: ParentComponent = (props) => {
206
206
state . should_zap_hodl
207
207
) ;
208
208
209
- // Sync our nostr profile info
210
- try {
211
- await mutinyWallet . sync_nostr ( ) ;
212
- } catch ( e ) {
213
- console . error ( "error syncing nostr profile" , e ) ;
214
- }
215
-
216
209
// Give other components access to settings via the store
217
210
setState ( { settings : settings } ) ;
218
211
219
212
// If we get this far then we don't need the password anymore
220
213
setState ( { needs_password : false } ) ;
221
214
222
- // Check if we're subscribed and update the timestamp
223
- try {
224
- const timestamp = await mutinyWallet ?. check_subscribed ( ) ;
225
-
226
- // Check that timestamp is a number
227
- if ( timestamp && ! isNaN ( Number ( timestamp ) ) ) {
228
- setState ( { subscription_timestamp : Number ( timestamp ) } ) ;
229
- }
230
- } catch ( e ) {
231
- console . error ( "error checking subscription" , e ) ;
232
- }
233
-
234
215
// Get balance
216
+ console . time ( "get_balance" ) ;
235
217
const balance = await mutinyWallet . get_balance ( ) ;
218
+ console . timeEnd ( "get_balance" ) ;
236
219
237
220
// Get federations
221
+ console . time ( "list_federations" ) ;
238
222
const federations =
239
223
( await mutinyWallet . list_federations ( ) ) as MutinyFederationIdentity [ ] ;
224
+ console . timeEnd ( "list_federations" ) ;
240
225
241
226
setState ( {
242
227
mutiny_wallet : mutinyWallet ,
@@ -255,6 +240,40 @@ export const Provider: ParentComponent = (props) => {
255
240
}
256
241
}
257
242
} ,
243
+ async postSetup ( ) : Promise < void > {
244
+ console . time ( "post_setup" ) ;
245
+ if ( ! state . mutiny_wallet ) {
246
+ console . error (
247
+ "Unable to run post setup, no mutiny_wallet is set"
248
+ ) ;
249
+ setState ( {
250
+ setup_error : new Error (
251
+ "Attempted post-setup without a Mutiny Wallet initialized."
252
+ )
253
+ } ) ;
254
+ return ;
255
+ }
256
+
257
+ // Sync our nostr profile info
258
+ try {
259
+ await state . mutiny_wallet . sync_nostr ( ) ;
260
+ } catch ( e ) {
261
+ console . error ( "error syncing nostr profile" , e ) ;
262
+ }
263
+
264
+ // Check if we're subscribed and update the timestamp
265
+ try {
266
+ const timestamp = await state . mutiny_wallet . check_subscribed ( ) ;
267
+
268
+ // Check that timestamp is a number
269
+ if ( timestamp && ! isNaN ( Number ( timestamp ) ) ) {
270
+ setState ( { subscription_timestamp : Number ( timestamp ) } ) ;
271
+ }
272
+ } catch ( e ) {
273
+ console . error ( "error checking subscription" , e ) ;
274
+ }
275
+ console . timeEnd ( "post_setup" ) ;
276
+ } ,
258
277
setShouldCreateNewWallet ( shouldCreateNewWallet : boolean ) {
259
278
setState ( { shouldCreateNewWallet } ) ;
260
279
} ,
@@ -509,6 +528,9 @@ export const Provider: ParentComponent = (props) => {
509
528
console . warn ( "setup aborted" ) ;
510
529
}
511
530
531
+ // After we have the mutiny wallet we still need to check for subscription and sync nostr
532
+ await actions . postSetup ( ) ;
533
+
512
534
console . log ( "node manager setup done" ) ;
513
535
514
536
// Setup an event listener to stop the mutiny wallet when the page unloads
0 commit comments