Refactor app component init function.
This commit is contained in:
parent
e541a155ff
commit
563bd20cfe
@ -61,31 +61,7 @@ export class AppComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
await this.router.events
|
await this.routeManagement();
|
||||||
.pipe(filter((e) => e instanceof NavigationEnd))
|
|
||||||
.forEach(async (routeInfo) => {
|
|
||||||
if (routeInfo instanceof NavigationEnd) {
|
|
||||||
this.url = routeInfo.url;
|
|
||||||
if (!this.url.match(this.accountDetailsRegex) || !this.url.includes('tx')) {
|
|
||||||
await this.blockSyncService.blockSync();
|
|
||||||
}
|
|
||||||
if (!this.url.includes('accounts')) {
|
|
||||||
try {
|
|
||||||
// TODO it feels like this should be in the onInit handler
|
|
||||||
await this.userService.loadAccounts(100);
|
|
||||||
} catch (error) {
|
|
||||||
this.loggingService.sendErrorLevelMessage('Failed to load accounts', this, { error });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!this.url.includes('tokens')) {
|
|
||||||
this.tokenService.load.subscribe(async (status: boolean) => {
|
|
||||||
if (status) {
|
|
||||||
await this.tokenService.getTokens();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load resize
|
// Load resize
|
||||||
@ -124,4 +100,31 @@ export class AppComponent implements OnInit {
|
|||||||
const conversion: any = event.detail.tx;
|
const conversion: any = event.detail.tx;
|
||||||
await this.transactionService.setConversion(conversion, 100);
|
await this.transactionService.setConversion(conversion, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async routeManagement(): Promise<void> {
|
||||||
|
await this.router.events
|
||||||
|
.pipe(filter((e) => e instanceof NavigationEnd))
|
||||||
|
.forEach(async (routeInfo) => {
|
||||||
|
if (routeInfo instanceof NavigationEnd) {
|
||||||
|
this.url = routeInfo.url;
|
||||||
|
if (!this.url.match(this.accountDetailsRegex) || !this.url.includes('tx')) {
|
||||||
|
await this.blockSyncService.blockSync();
|
||||||
|
}
|
||||||
|
if (!this.url.includes('accounts')) {
|
||||||
|
try {
|
||||||
|
await this.userService.loadAccounts(100);
|
||||||
|
} catch (error) {
|
||||||
|
this.loggingService.sendErrorLevelMessage('Failed to load accounts', this, { error });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!this.url.includes('tokens')) {
|
||||||
|
this.tokenService.load.subscribe(async (status: boolean) => {
|
||||||
|
if (status) {
|
||||||
|
await this.tokenService.getTokens();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,6 @@ export class AccountsComponent implements OnInit, AfterViewInit {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
// TODO it feels like this should be in the onInit handler
|
|
||||||
await this.userService.loadAccounts(100);
|
await this.userService.loadAccounts(100);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.loggingService.sendErrorLevelMessage('Failed to load accounts', this, { error });
|
this.loggingService.sendErrorLevelMessage('Failed to load accounts', this, { error });
|
||||||
|
Loading…
Reference in New Issue
Block a user