Skip to content

Commit

Permalink
- updated app loading order
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyusung4698 committed Sep 17, 2020
1 parent 8048a62 commit 6c7c2d6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<ng-container *ngIf="window$ | async as window">
<ng-container [ngSwitch]="window.name">
<ng-container *ngIf="window$ | async as name">
<ng-container [ngSwitch]="name">
<app-background-window *ngSwitchCase="'background'"></app-background-window>
<app-evaluate-window *ngSwitchCase="'evaluate'"></app-evaluate-window>
<app-inspect-window *ngSwitchCase="'inspect'"></app-inspect-window>
Expand All @@ -11,6 +11,6 @@
<app-annotation-window *ngSwitchCase="'annotation'"></app-annotation-window>
<app-trade-window *ngSwitchCase="'trade'"></app-trade-window>
<app-trade-highlight-window *ngSwitchCase="'tradehighlight'"></app-trade-highlight-window>
<div *ngSwitchDefault>Could not match window with name: {{window.name}}</div>
<div *ngSwitchDefault>Could not match window with name: {{name}}</div>
</ng-container>
</ng-container>
28 changes: 17 additions & 11 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,6 @@ export class AppComponent implements OnInit, OnDestroy {
const { language, leagueId } = settings;
return this.context.init({ language, leagueId });
}),
tap(() => {
this.subscription = this.settings.change().on(settings => {
this.ngZone.run(() => {
this.i18n.use(settings.uiLanguage);
const { language, leagueId } = settings;
this.context.update({ language, leagueId });
});
});
}),
mergeMap(() => OWWindows.getCurrentWindow()),
retryWhen(errors => errors.pipe(
mergeMap(error => {
console.warn(`An unexpected error occured while loading PoE Overlay. ${error?.message ?? JSON.stringify(error)}`);
Expand All @@ -62,7 +52,23 @@ export class AppComponent implements OnInit, OnDestroy {
);
})
)),
tap(win => this.title.setTitle(`PoE Overlay - ${win.name.charAt(0).toUpperCase()}${win.name.slice(1)}`)),
tap(() => {
this.subscription = this.settings.change().on(settings => {
this.ngZone.run(() => {
this.i18n.use(settings.uiLanguage);
const { language, leagueId } = settings;
this.context.update({ language, leagueId });
});
});
}),
mergeMap(() => OWWindows.getCurrentWindow().pipe(
map(win => win.name),
catchError(error => {
console.warn(`An unexpected error occured while getting current window. ${error?.message ?? JSON.stringify(error)}`);
return of('background');
})
)),
tap(win => this.title.setTitle(`PoE Overlay - ${win.charAt(0).toUpperCase()}${win.slice(1)}`)),
catchError(() => new OWWindow().close().pipe(
map(() => null)
))
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/odk/ow-windows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class OWWindows {
if (result?.success) {
resolve(result.window);
} else {
reject(result.error);
reject(`Could not get current window. reason: ${result.error ?? JSON.stringify(result)}.`);
}
});
});
Expand Down

0 comments on commit 6c7c2d6

Please sign in to comment.