Skip to content

Commit

Permalink
- fixed a unhandled error if no event data is available
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyusung4698 committed Jun 18, 2020
1 parent 439b6b9 commit 9e5e516
Show file tree
Hide file tree
Showing 11 changed files with 92 additions and 72 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.0.3 (2020-06-18)

- fixed a unhandled error if no event data is available

## 1.0.2 (2020-06-16)

- added misc module
Expand Down
11 changes: 7 additions & 4 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"meta": {
"name": "PoE Overlay",
"author": "Kyusung4698",
"version": "1.0.2",
"version": "1.0.3",
"minimum-overwolf-version": "0.147.0",
"description": "Search the market and send trade offers. Get current market values for your item. View insights for maps and items.",
"dock_button_title": "PoE Overlay",
Expand Down Expand Up @@ -38,11 +38,11 @@
"transparent": true,
"show_in_taskbar": false,
"size": {
"width": 1212,
"width": 1242,
"height": 699
},
"min_size": {
"width": 1212,
"width": 1242,
"height": 699
}
},
Expand Down Expand Up @@ -180,8 +180,11 @@
"event_data": {
"game_ids": [
7212
]
],
"wait_for_stable_framerate": 30
},
"tracked": false,
"include_launchers": false,
"start_minimized": false
}
],
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "poe-overlay-overwolf",
"version": "1.0.2",
"version": "1.0.3",
"scripts": {
"watch": "ng build --watch",
"watch:prod": "ng build --watch --prod",
Expand Down
5 changes: 4 additions & 1 deletion src/app/core/event/event-emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ export class EventEmitter<TEvent> {

public next(event: TEvent): void {
Object.getOwnPropertyNames(this.registry).forEach(key => {
this.registry[key](event);
const fn = this.registry[key];
if (fn) {
fn(event);
}
});
this.latest = event;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ export class BackgroundWindowComponent implements OnInit, OnDestroy {
});
});
});
this.hotkeys.start();
this.game.start();
});
}
Expand Down Expand Up @@ -118,11 +117,6 @@ export class BackgroundWindowComponent implements OnInit, OnDestroy {
this.shouldQuit = false;
this.launcherWindow.close();

const path = info.executionPath.split('/');
path.pop();
const log = `${path.join('/')}/logs/Client.txt`;
this.log.start(log);

forkJoin([
this.annotationWindow.open(info.width, info.height),
this.notificationWindow.open(info.width, info.height)
Expand All @@ -135,6 +129,13 @@ export class BackgroundWindowComponent implements OnInit, OnDestroy {
module.onInfo(info, settings);
}
});

const path = info.executionPath.split('/');
path.pop();
const log = `${path.join('/')}/logs/Client.txt`;
this.log.start(log);

this.hotkeys.start();
});
if (!result) {
this.notification.show('event.start-error');
Expand Down
25 changes: 14 additions & 11 deletions src/app/modules/commands/service/command.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import { ChatService } from '@shared/module/poe/chat';
import { EventService } from '@shared/module/poe/event';
import { Observable } from 'rxjs';
import { Observable, of } from 'rxjs';
import { map, tap } from 'rxjs/operators';

@Injectable({
Expand All @@ -14,15 +14,18 @@ export class CommandService {
private readonly event: EventService) { }

public execute(command: string): Observable<void> {
// TODO: Error handling
return this.event.getCharacter().pipe(
tap(character => {
if (character?.name.length) {
command = command.replace('@char', character.name);
}
this.chat.send(command);
}),
map(() => null)
);
if (command.includes('@char')) {
return this.event.getCharacter().pipe(
map(character => {
if (character?.name?.length) {
command = command.replace('@char', character.name);
}
return this.chat.send(command);
})
);
} else {
this.chat.send(command);
return of(null);
}
}
}
84 changes: 43 additions & 41 deletions src/app/modules/trade/trade.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,47 +102,49 @@ export class TradeModule implements FeatureModule<TradeFeatureSettings> {

private registerAnnotation(): void {
let lastId = '';
this.annotation.message$.on(message => this.ngZone.run(() => {
const id = message?.id || '';
if (id === lastId) {
return;
}
lastId = id;
this.annotation.message$.on(message => {
this.ngZone.run(() => {
const id = message?.id || '';
if (id === lastId) {
return;
}
lastId = id;

switch (id) {
case 'trade.outgoing':
case 'trade.incoming':
this.event.getCharacter().pipe(
catchError(() => of(null))
).subscribe(character => {
const item: TradeItemMessage = {
direction: id === 'trade.outgoing'
? TradeWhisperDirection.Outgoing
: TradeWhisperDirection.Incoming,
itemName: 'Apocalypse Horn Decimation Bow',
joined$: new BehaviorSubject(false),
league: 'Standard',
left: 4,
top: 6,
// tslint:disable:max-line-length
message: 'Hi, I would like to buy your Apocalypse Horn Decimation Bow for 2 chaos in Delirium (stash tab "Annotation"; position: left 4, top 6)',
// tslint:enable:max-line-length
name: character?.name || 'PoEOverlayUnknownCharacter',
stash: 'Annotation',
timeReceived: new Date(),
type: TradeParserType.TradeItem,
whispers$: new BehaviorSubject([]),
currencyType: 'chaos',
price: 2
};
this.trade.set(item);
});
break;
case 'trade.settings':
this.highlightWindow.close().subscribe();
this.trade.clear();
break;
}
}));
switch (id) {
case 'trade.outgoing':
case 'trade.incoming':
this.event.getCharacter().pipe(
catchError(() => of(null))
).subscribe(character => {
const item: TradeItemMessage = {
direction: id === 'trade.outgoing'
? TradeWhisperDirection.Outgoing
: TradeWhisperDirection.Incoming,
itemName: 'Apocalypse Horn Decimation Bow',
joined$: new BehaviorSubject(false),
league: 'Standard',
left: 4,
top: 6,
// tslint:disable:max-line-length
message: 'Hi, I would like to buy your Apocalypse Horn Decimation Bow for 2 chaos in Delirium (stash tab "Annotation"; position: left 4, top 6)',
// tslint:enable:max-line-length
name: character?.name || 'PoEOverlayUnknownCharacter',
stash: 'Annotation',
timeReceived: new Date(),
type: TradeParserType.TradeItem,
whispers$: new BehaviorSubject([]),
currencyType: 'chaos',
price: 2
};
this.trade.set(item);
});
break;
case 'trade.settings':
this.highlightWindow.close().subscribe();
this.trade.clear();
break;
}
});
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ export class TradeHighlightWindowComponent implements OnInit, OnDestroy {

public ngOnInit(): void {
this.updateData(this.window.data$.get());
this.subscription = this.window.data$.on(data => this.ngZone.run(() => {
this.updateData(data);
}));
this.subscription = this.window.data$.on(data => {
this.ngZone.run(() => {
this.updateData(data);
});
});
}

public ngOnDestroy(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ export class TradeWindowComponent implements OnInit, OnDestroy {

public ngOnInit(): void {
this.data$.next(this.window.data$.get());
this.subscription = this.window.data$.on(data => this.ngZone.run(() => {
this.data$.next(data);
}));
this.subscription = this.window.data$.on(data => {
this.ngZone.run(() => {
this.data$.next(data);
});
});
}

public ngOnDestroy(): void {
Expand Down
2 changes: 1 addition & 1 deletion src/app/shared/module/poe/event/event.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import { OWGamesEvents } from '@app/odk';
import { Observable, of } from 'rxjs';
import { catchError, map, tap } from 'rxjs/operators';
import { catchError, map } from 'rxjs/operators';

interface EventInfo {
match_info: {
Expand Down

0 comments on commit 9e5e516

Please sign in to comment.