Skip to content

Commit

Permalink
- added fetch count at the option menu (#692)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyusung4698 committed May 9, 2020
1 parent 74f8c24 commit 97a6350
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 26 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 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)
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
Expand Up @@ -158,15 +158,15 @@ export class EvaluateSearchComponent implements OnInit, OnDestroy {
).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 Down

0 comments on commit 97a6350

Please sign in to comment.