Skip to content

Commit

Permalink
Merge pull request #698 from Kyusung4698/develop
Browse files Browse the repository at this point in the history
0.6.28 (2020-05-09)
  • Loading branch information
Kyusung4698 authored May 9, 2020
2 parents c4c297c + 40898fc commit 20d73bb
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 51 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.28 (2020-05-09)

- added fetch count at the option menu (#692)
- fixed a rate limit issue which was caused by requests not getting marked as finished (#695)

## 0.6.27 (2020-05-08)

- updated rate limiting behavior (#678)
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.27
# PoE Overlay 0.6.28

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.27.exe` to install locally. This supports auto update/ auto launch.
2. `poe-overlay-0.6.27.exe` portable version. This does not support auto update/ auto launch.
1. `poe-overlay-Setup-0.6.28.exe` to install locally. This supports auto update/ auto launch.
2. `poe-overlay-0.6.28.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.27` in the bottom left corner
4. Wait until you can see `PoE Overlay 0.6.28` in the bottom left corner
5. Hit `f7` and set `Language` and `League` to meet your game settings

#### Shortcuts
Expand Down
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",
"version": "0.6.27",
"version": "0.6.28",
"private": true,
"description": "A Overlay for Path of Exile. Built with Electron and Angular.",
"main": "main.js",
Expand Down
46 changes: 30 additions & 16 deletions src/app/data/poe/service/trade-rate-limit.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HttpResponse } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable, of, throwError } from 'rxjs';
import { catchError, delay, flatMap, map, retryWhen } from 'rxjs/operators';
import { catchError, delay, finalize, flatMap, map, retryWhen } from 'rxjs/operators';

// 1 request
// x-rate-limit-ip: 12:4:10,16:12:300
Expand Down Expand Up @@ -62,9 +62,10 @@ interface TradeRateLimit {

enum TradeRateThrottle {
None = 1,
Stale = 2,
Reached = 3,
Limited = 4
NoRules = 2,
Stale = 3,
Reached = 4,
Limited = 5
}

@Injectable({
Expand All @@ -82,20 +83,22 @@ export class TradeRateLimitService {
switch (reason) {
case TradeRateThrottle.Limited:
return throwError('limited');
case TradeRateThrottle.NoRules:
case TradeRateThrottle.Reached:
case TradeRateThrottle.Stale:
return throwError('waiting');
default:
const request = this.createRequest(resource);
return getRequest().pipe(
return of(null).pipe(
flatMap(() => getRequest().pipe(
finalize(() => request.finished = Date.now())
)),
map(response => {
request.finished = Date.now();
this.updateRules(resource, response);
this.filterRequests(resource);
return response.body
}),
catchError(response => {
request.finished = Date.now();
if (response.status === 429) {
this.updateRules(resource, response);
}
Expand Down Expand Up @@ -129,15 +132,20 @@ export class TradeRateLimitService {
const { rules, requests, update } = this.getLimit(resource);

const inflight = requests.some(request => !request.finished);
if (!inflight) {
return TradeRateThrottle.None;
if (!rules) {
if (!inflight) {
// allow a new request to gather rules
return TradeRateThrottle.None;
}
// request made for gathering rules
// do not allow any further requests
return TradeRateThrottle.NoRules;
}

// only allow 1 request until
// > rules are filled
// > rules are fresh again
const now = Date.now();
if (!rules || (now - update) > RULE_FRESH_DURATION) {
if (inflight && (now - update) > RULE_FRESH_DURATION) {
// a request was made and data is stale
// wait for request to be finished before allowing further requests
return TradeRateThrottle.Stale;
}

Expand Down Expand Up @@ -173,16 +181,22 @@ export class TradeRateLimitService {

private filterRequests(resource: string): void {
const limit = this.getLimit(resource);

const { rules, requests } = limit;
if (!rules) {
return;
}

const now = Date.now();
limit.requests = limit.requests.filter(request => {
limit.requests = requests.filter(request => {
if (!request.finished) {
return true;
}
return limit.rules.some(rule => {
return rules.some(rule => {
const min = now - rule.period * 1000;
return request.finished >= min;
});
})
});
}

private updateRules(resource: string, response: HttpResponse<any>): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { StashPriceTagType } from '@shared/module/poe/service';
import { CurrencyService } from '@shared/module/poe/service/currency/currency.service';
import { Currency, Item, ItemCategory, ItemRarity, Language } from '@shared/module/poe/type';
import { BehaviorSubject, forkJoin, Observable, Subject } from 'rxjs';
import { buffer, debounceTime, shareReplay, delay } from 'rxjs/operators';
import { buffer, debounceTime, delay, shareReplay } from 'rxjs/operators';
import { EvaluateOptions } from '../evaluate-options/evaluate-options.component';
import { EvaluateUserSettings } from '../evaluate-settings/evaluate-settings.component';

Expand Down Expand Up @@ -47,12 +47,14 @@ export class EvaluateDialogComponent implements OnInit, AfterViewInit, OnDestroy
}

public ngOnInit(): void {
const { settings, item } = this.data;
this.options = {
indexed: this.data.settings.evaluateQueryIndexedRange,
online: this.data.settings.evaluateQueryOnline,
leagueId: this.data.settings.leagueId
indexed: settings.evaluateQueryIndexedRange,
online: settings.evaluateQueryOnline,
leagueId: settings.leagueId,
fetchCount: settings.evaluateQueryFetchCount
};
const { defaultItem, queryItem } = this.evaluateQueryItemProvider.provide(this.data.item, this.data.settings);
const { defaultItem, queryItem } = this.evaluateQueryItemProvider.provide(item, settings);
this.defaultItem = defaultItem;
this.queryItem = queryItem;
this.currencies$ = this.getCurrencies();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,30 @@
{{ leagues[options.leagueId] }}
</span>
</ng-container>
<span class="divider"></span>
</ng-container>

<!-- online -->
<ng-container *ngIf="options.online; else offline">
<span class="clickable" title="online" (click)="onToggleOnlineClick()">
<mat-icon>wifi</mat-icon>
</span>
</ng-container>
<ng-template #offline>
<span class="clickable" title="offline" (click)="onToggleOnlineClick()">
<mat-icon>wifi_off</mat-icon>
</span>
</ng-template>

<!-- online -->
<span class="clickable" title="online" (click)="onToggleOnlineClick()">
<mat-icon>{{options.online ? 'wifi' : 'wifi_off'}}</mat-icon>
</span>
<!-- indexed -->
<ng-container *ngIf="options.indexed">
<span class="option" (wheel)="onIndexedWheel($event)">
{{ options.indexed }}
</span>
<span class="divider"></span>
</ng-container>


<!-- fetch-count -->
<ng-container *ngIf="options.fetchCount">
<span class="option" (wheel)="onFetchCountWheel($event)">
{{ options.fetchCount }}
<span>{{'evaluate.count' | translate}}</span>
</span>
<span class="divider"></span>
</ng-container>

<!-- reset -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,12 @@
outline-width: 1px;
}
}

.divider{
border-bottom: 1px solid $light-grey;
width: 50%;
padding-top: 5px;
margin-bottom: 5px;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface EvaluateOptions {
online: boolean;
indexed: ItemSearchIndexed;
leagueId: string;
fetchCount: number;
}

type LeagueMap = {
Expand Down Expand Up @@ -53,11 +54,11 @@ export class EvaluateOptionsComponent implements OnInit {
this.optionsChange.emit(this.options);
}

public onIndexedWheel(event: WheelEvent): void {
public onLeaguesWheel(event: WheelEvent, leagues: LeagueMap): void {
const factor = event.deltaY > 0 ? -1 : 1;
const keys = Object.getOwnPropertyNames(ItemSearchIndexed);
const keys = Object.getOwnPropertyNames(leagues);

let index = keys.findIndex(x => ItemSearchIndexed[x] === this.options.indexed);
let index = keys.findIndex(id => id === this.options.leagueId);
index += factor;

if (index >= keys.length) {
Expand All @@ -67,15 +68,15 @@ export class EvaluateOptionsComponent implements OnInit {
}

const key = keys[index];
this.options.indexed = ItemSearchIndexed[key];
this.options.leagueId = key;
this.optionsChange.emit(this.options);
}

public onLeaguesWheel(event: WheelEvent, leagues: LeagueMap): void {
public onIndexedWheel(event: WheelEvent): void {
const factor = event.deltaY > 0 ? -1 : 1;
const keys = Object.getOwnPropertyNames(leagues);
const keys = Object.getOwnPropertyNames(ItemSearchIndexed);

let index = keys.findIndex(id => id === this.options.leagueId);
let index = keys.findIndex(x => ItemSearchIndexed[x] === this.options.indexed);
index += factor;

if (index >= keys.length) {
Expand All @@ -85,10 +86,26 @@ export class EvaluateOptionsComponent implements OnInit {
}

const key = keys[index];
this.options.leagueId = key;
this.options.indexed = ItemSearchIndexed[key];
this.optionsChange.emit(this.options);
}

public onFetchCountWheel(event: WheelEvent): void {
const factor = event.deltaY > 0 ? -1 : 1;

let fetchCount = this.options.fetchCount + factor * 10;
if (fetchCount > 100) {
fetchCount = 10;
} else if (fetchCount < 10) {
fetchCount = 100;
}

if (fetchCount !== this.options.fetchCount) {
this.options.fetchCount = fetchCount;
this.optionsChange.emit(this.options);
}
}

public onResetClick(): void {
this.resetTrigger.next();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core';
import { BrowserService, LoggerService } from '@app/service';
import { EvaluateResult } from '@modules/evaluate/type/evaluate.type';
import { ItemSearchAnalyzeResult, ItemSearchAnalyzeService, ItemSearchListing, ItemSearchResult, ItemSearchService } from '@shared/module/poe/service';
Expand All @@ -15,8 +15,10 @@ import { EvaluateResultView, EvaluateUserSettings, EVALUATE_QUERY_DEBOUNCE_TIME_
styleUrls: ['./evaluate-search.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class EvaluateSearchComponent implements OnInit {
export class EvaluateSearchComponent implements OnInit, OnDestroy {
private searchSubscription: Subscription;
private listSubscription: Subscription;
private analyzeSubscription: Subscription;

public graph: boolean;

Expand Down Expand Up @@ -60,6 +62,12 @@ export class EvaluateSearchComponent implements OnInit {
}
}

public ngOnDestroy(): void {
this.searchSubscription?.unsubscribe();
this.listSubscription?.unsubscribe();
this.analyzeSubscription?.unsubscribe();
}

public onSearchClick(): void {
this.initSearch();
}
Expand Down Expand Up @@ -145,20 +153,20 @@ export class EvaluateSearchComponent implements OnInit {
const options: ItemSearchOptions = {
...this.options
};
this.itemSearchService.search(item, options).pipe(
this.searchSubscription = this.itemSearchService.search(item, options).pipe(
takeUntil(this.queryItemChange)
).subscribe(search => {
this.search$.next(search);
if (search.total > 0) {
const count = Math.min(this.settings.evaluateQueryFetchCount, search.total);
const count = Math.min(this.options.fetchCount, search.total);
this.count$.next(count);
this.list(search);
}
}, error => this.handleError(error));
}

private list(search: ItemSearchResult): void {
this.listSubscription = this.itemSearchService.list(search, this.settings.evaluateQueryFetchCount).pipe(
this.listSubscription = this.itemSearchService.list(search, this.options.fetchCount).pipe(
takeUntil(this.queryItemChange)
).subscribe(listings => {
this.listings$.next(listings);
Expand All @@ -170,7 +178,7 @@ export class EvaluateSearchComponent implements OnInit {

private analyze(listings: ItemSearchListing[], currency?: Currency): void {
const currencies = currency ? [currency] : this.currencies;
this.itemSearchAnalyzeService.analyze(listings, currencies).pipe(
this.analyzeSubscription = this.itemSearchAnalyzeService.analyze(listings, currencies).pipe(
takeUntil(this.queryItemChange)
).subscribe(
result => this.result$.next(result),
Expand Down

0 comments on commit 20d73bb

Please sign in to comment.