Skip to content

Commit

Permalink
Merge pull request #494 from Kyusung4698/develop
Browse files Browse the repository at this point in the history
0.6.15 (2020-03-27)
  • Loading branch information
Kyusung4698 authored Mar 27, 2020
2 parents 5ced41b + 2106c28 commit 1b5bbc6
Show file tree
Hide file tree
Showing 11 changed files with 186 additions and 93 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 0.6.15 (2020-03-27)

- fix an error occured while fetching poe.ninja (#468)
- fix poe overlay does not recognize if poe is no longer active (#485, #486)

## 0.6.14 (2020-03-26)

- add nonunique rarity support (#477)
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
![GitHub Release Date](https://img.shields.io/github/release-date/Kyusung4698/PoE-Overlay)
<a href="https://www.patreon.com/bePatron?u=30666721"><img src="https://c5.patreon.com/external/logo/become_a_patron_button.png" alt="Become a Patron" width="85px" height="20px"></a>

# PoE Overlay 0.6.14
# PoE Overlay 0.6.15

An Overlay for Path of Exile. The ***core aspect*** is to blend in with the game. Built with Electron and Angular.

Expand Down Expand Up @@ -74,11 +74,11 @@ These instructions will set you up to run and enjoy the overlay.
#### Installing

1. Head over to [Releases](https://github.com/Kyusung4698/PoE-Overlay/releases) and download one of the following files
1. `poe-overlay-Setup-0.6.14.exe` to install locally. This supports auto update/ auto launch.
2. `poe-overlay-0.6.14.exe` portable version. This does not support auto update/ auto launch.
1. `poe-overlay-Setup-0.6.15.exe` to install locally. This supports auto update/ auto launch.
2. `poe-overlay-0.6.15.exe` portable version. This does not support auto update/ auto launch.
2. Run either of your downloaded file
3. Start Path of Exile
4. Wait until you can see `PoE Overlay 0.6.14` in the bottom left corner
4. Wait until you can see `PoE Overlay 0.6.15` in the bottom left corner
5. Hit `f7` and set `Language` and `League` to meet your game settings

#### Shortcuts
Expand Down
4 changes: 4 additions & 0 deletions hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ function checkActive(): void {
bounds = addon.getWindowBounds(activeWindow.id);
}
}
} else {
active = false;
}
} else {
active = false;
}

if (orgActive !== active ||
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "poe-overlay",
"version": "0.6.14",
"version": "0.6.15",
"private": true,
"description": "A Overlay for Path of Exile. Built with Electron and Angular.",
"main": "main.js",
Expand Down Expand Up @@ -107,8 +107,7 @@
"linux"
],
"arches": [
"x64",
"ia32"
"x64"
]
}
}
22 changes: 20 additions & 2 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,33 @@
import { NgModule } from '@angular/core';
import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, HTTP_INTERCEPTORS } from '@angular/common/http';
import { Injectable, NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { BookmarkModule } from '@modules/bookmark/bookmark.module';
import { CommandModule } from '@modules/command/command.module';
import { EvaluateModule } from '@modules/evaluate/evaluate.module';
import { MapModule } from '@modules/map/map.module';
import { MiscModule } from '@modules/misc/misc.module';
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { Observable } from 'rxjs';
import { AppTranslationsLoader } from './app-translations.loader';
import { AppComponent } from './app.component';
import { LayoutModule } from './layout/layout.module';
import { OverlayComponent } from './layout/page/overlay/overlay.component';
import { UserSettingsComponent } from './layout/page/user-settings/user-settings.component';

@Injectable()
export class CacheInterceptor implements HttpInterceptor {
public intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
const httpRequest = req.clone({
setHeaders: {
'Cache-Control': 'no-cache',
Pragma: 'no-cache',
Expires: 'Sat, 01 Jan 2000 00:00:00 GMT'
}
});
return next.handle(httpRequest);
}
}

const routes: Routes = [
{
path: 'user-settings',
Expand Down Expand Up @@ -45,7 +61,9 @@ const routes: Routes = [
MiscModule,
BookmarkModule
],
providers: [],
providers: [
{ provide: HTTP_INTERCEPTORS, useClass: CacheInterceptor, multi: true }
],
bootstrap: [AppComponent]
})
export class AppModule { }
48 changes: 39 additions & 9 deletions src/app/data/poe-ninja/service/currency-overview-http.service.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { HttpClient, HttpParams } from '@angular/common/http';
import { HttpClient, HttpErrorResponse, HttpParams } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { BrowserService, LoggerService } from '@app/service';
import { environment } from '@env/environment';
import { Observable } from 'rxjs';
import { map, retry } from 'rxjs/operators';
import { Observable, of, throwError } from 'rxjs';
import { delay, flatMap, retryWhen } from 'rxjs/operators';
import { CurrencyOverviewResponse } from '../schema/currency-overview';

export enum CurrencyOverviewType {
Expand All @@ -15,33 +16,62 @@ const PATH_TYPE_MAP = {
[CurrencyOverviewType.Fragment]: 'fragments',
};

const RETRY_COUNT = 3;
const RETRY_DELAY = 100;

@Injectable({
providedIn: 'root'
})
export class CurrencyOverviewHttpService {
private readonly apiUrl: string;

constructor(private readonly httpClient: HttpClient) {
constructor(
private readonly httpClient: HttpClient,
private readonly browser: BrowserService,
private readonly logger: LoggerService) {
this.apiUrl = `${environment.poeNinja.baseUrl}/api/data/currencyoverview`;
}

public get(leagueId: string, type: CurrencyOverviewType): Observable<CurrencyOverviewResponse> {
const params = new HttpParams({
fromObject: {
league: leagueId,
type
type,
language: 'en',
t: `${Date.now()}`
}
});
return this.httpClient.get<CurrencyOverviewResponse>(this.apiUrl, {
params
}).pipe(
retry(3),
map(result => {
return {
...result,
retryWhen(errors => errors.pipe(
flatMap((response, count) => this.handleError(this.apiUrl, response, count))
)),
flatMap(response => {
if (!response.lines) {
this.logger.warn(`Got empty result from ${this.apiUrl} with ${leagueId} and ${type}.`, response);
return throwError(`Got empty result from ${this.apiUrl} with ${leagueId} and ${type}.`)
}

const result: CurrencyOverviewResponse = {
...response,
url: `${environment.poeNinja.baseUrl}/challenge/${PATH_TYPE_MAP[type]}`
}
return of(result);
})
);
}

private handleError(url: string, response: HttpErrorResponse, count: number): Observable<void> {
if (count >= RETRY_COUNT) {
return throwError(response);
}

switch (response.status) {
case 403:
return this.browser.retrieve(url);
default:
return of(null).pipe(delay(RETRY_DELAY));
}
}
}
50 changes: 40 additions & 10 deletions src/app/data/poe-ninja/service/item-overview-http.service.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { HttpClient, HttpParams } from '@angular/common/http';
import { HttpClient, HttpErrorResponse, HttpParams } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { BrowserService, LoggerService } from '@app/service';
import { environment } from '@env/environment';
import { Observable } from 'rxjs';
import { map, retry } from 'rxjs/operators';
import { Observable, of, throwError } from 'rxjs';
import { delay, flatMap, retryWhen } from 'rxjs/operators';
import { ItemOverviewResponse } from '../schema/item-overview';

export enum ItemOverviewType {
Expand Down Expand Up @@ -43,33 +44,62 @@ const PATH_TYPE_MAP = {
[ItemOverviewType.UniqueMap]: 'unique-maps',
};

const RETRY_COUNT = 3;
const RETRY_DELAY = 100;

@Injectable({
providedIn: 'root'
})
export class ItemOverviewHttpService {
private readonly apiUrl: string;

constructor(private readonly httpClient: HttpClient) {
constructor(
private readonly httpClient: HttpClient,
private readonly browser: BrowserService,
private readonly logger: LoggerService) {
this.apiUrl = `${environment.poeNinja.baseUrl}/api/data/itemoverview`;
}

public get(leagueId: string, type: ItemOverviewType): Observable<ItemOverviewResponse> {
const params = new HttpParams({
fromObject: {
league: leagueId,
type
type,
language: 'en',
t: `${Date.now()}`
}
});
return this.httpClient.get<ItemOverviewResponse>(this.apiUrl, {
params
}).pipe(
retry(3),
map(result => {
return {
...result,
url: `${environment.poeNinja.baseUrl}/challenge/${PATH_TYPE_MAP[type]}`
retryWhen(errors => errors.pipe(
flatMap((response, count) => this.handleError(this.apiUrl, response, count))
)),
flatMap(response => {
if (!response.lines) {
this.logger.warn(`Got empty result from ${this.apiUrl} with ${leagueId} and ${type}.`, response);
return throwError(`Got empty result from ${this.apiUrl} with ${leagueId} and ${type}.`)
}

const result: ItemOverviewResponse = {
...response,
url: `${environment.poeNinja.baseUrl}/challenge/${PATH_TYPE_MAP[type]}`
};
return of(result);
})
);
}

private handleError(url: string, response: HttpErrorResponse, count: number): Observable<void> {
if (count >= RETRY_COUNT) {
return throwError(response);
}

switch (response.status) {
case 403:
return this.browser.retrieve(url);
default:
return of(null).pipe(delay(RETRY_DELAY));
}
}
}
Loading

0 comments on commit 1b5bbc6

Please sign in to comment.