Skip to content

Commit

Permalink
- fixed an issue parsing unicode item data
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyusung4698 committed Jun 24, 2020
1 parent 98387bf commit 9f632c8
Show file tree
Hide file tree
Showing 27 changed files with 125 additions and 78 deletions.
12 changes: 7 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

## 1.0.6 (2020-06-25)

- added market search history
- added trade offer received timer
- added trade player name
- added trade go to hideout action
- added harvest seeds evaluate support
- added a history for the market search
- added a received timer at the trade message
- added the player name at the trade message
- added a new action to go to the hideout for outgoing trades
- added support for the new harvest seeds
- update the height of the trade window to be configurable
- fixed an issue parsing unicode item data
- fixed an issue at the market which resulted in crashing the app

## 1.0.5 (2020-06-23)
Expand Down
2 changes: 1 addition & 1 deletion 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.5",
"version": "1.0.6",
"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
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.5",
"version": "1.0.6",
"scripts": {
"watch": "ng build --watch",
"watch:prod": "ng build --watch --prod",
Expand Down
11 changes: 11 additions & 0 deletions src/app/core/helper/base64.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export function b64EncodeUnicode(str: string): string {
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, (_, p1) => {
return String.fromCharCode(parseInt(p1, 16));
}));
}

export function b64DecodeUnicode(str: string): string {
return decodeURIComponent(Array.prototype.map.call(atob(str), (c: string) => {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));
}
1 change: 1 addition & 0 deletions src/app/core/helper/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './base64';
export * from './roman';
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { HttpClient, HttpErrorResponse } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { b64EncodeUnicode } from '@app/helper';
import { environment } from '@env/environment';
import { Observable, of, throwError } from 'rxjs';
import { delay, flatMap, retryWhen } from 'rxjs/operators';
Expand All @@ -19,7 +20,7 @@ export class ItemPricePredictionHttpService {
}

public get(leagueId: string, stringifiedItem: string): Observable<ItemPricePredictionResponse> {
const base64Item = btoa(stringifiedItem);
const base64Item = b64EncodeUnicode(stringifiedItem);
const encodedLeagueId = encodeURIComponent(leagueId);
const encodedItem = encodeURIComponent(base64Item);

Expand Down Expand Up @@ -52,7 +53,7 @@ export class ItemPricePredictionHttpService {
form.set('max', `${max}`);
form.set('selector', selector);
form.set('currency', currencyId);
form.set('qitem_text', btoa(stringifiedItem));
form.set('qitem_text', b64EncodeUnicode(stringifiedItem));
form.set('debug', `${environment.production ? 0 : 1}`);
form.set('source', SOURCE);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import { BehaviorSubject } from 'rxjs';
changeDetection: ChangeDetectionStrategy.OnPush
})
export class SettingsFormComponent implements OnInit {
private language: Language;

public languages = new EnumValues(Language);
public uiLanguages = new EnumValues(UiLanguage);

Expand All @@ -32,11 +30,7 @@ export class SettingsFormComponent implements OnInit {
private readonly leagues: TradeLeaguesService) { }

public ngOnInit(): void {
const { language } = this.settings;
if (language && this.language !== language) {
this.language = language;
this.updateLeagues();
}
this.updateLeagues();
}

public onChange(): void {
Expand All @@ -49,8 +43,8 @@ export class SettingsFormComponent implements OnInit {
}

private updateLeagues(): void {
const { leagueId } = this.settings;
this.leagues.get(this.language).subscribe(leagues => {
const { leagueId, language } = this.settings;
this.leagues.get(language).subscribe(leagues => {
const selectedLeague = leagues.find(league => league.id === leagueId);
if (!selectedLeague) {
this.settings.leagueId = leagues[0].id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ export class MarketExchangeBarComponent {
public request: TradeExchangeRequest;

@Output()
public highlight = new EventEmitter<string>();
public requestChange = new EventEmitter<TradeExchangeRequest>();

@Output()
public reset = new EventEmitter<TradeExchangeRequest>();
public highlight = new EventEmitter<string>();

@Output()
public toggle = new EventEmitter<boolean>();
Expand All @@ -35,7 +35,11 @@ export class MarketExchangeBarComponent {

public onResetClick(request?: TradeExchangeRequest): void {
this.recordsVisible$.next(false);
this.reset.next(request);
if (request) {
this.requestChange.next(JSON.parse(JSON.stringify(request)));
} else {
this.requestChange.next();
}
}

public onToggleClick(): void {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<app-market-exchange-bar [request]="request" (search)="onSearch()" (toggle)="onToggle($event)"
(highlight)="onHighlight($event)" (reset)="onReset($event)">
(highlight)="onHighlight($event)" (requestChange)="onRequestChange($event)">
</app-market-exchange-bar>

<div class="content">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class MarketExchangeComponent implements OnInit, OnDestroy {
this.page$.next(this.page$.value + 1);
}

public onReset(request?: TradeExchangeRequest): void {
public onRequestChange(request?: TradeExchangeRequest): void {
this.request = request || DEFAULT_REQUEST();
this.initSearch();
this.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ export class MarketItemSearchBarComponent implements OnInit {
}

@Output()
public search = new EventEmitter<void>();
public requestChange = new EventEmitter<TradeSearchRequest>();

@Output()
public toggle = new EventEmitter<boolean>();
public search = new EventEmitter<void>();

@Output()
public reset = new EventEmitter<TradeSearchRequest>();
public toggle = new EventEmitter<boolean>();

constructor(private readonly items: TradeItemsService) { }

Expand All @@ -72,7 +72,11 @@ export class MarketItemSearchBarComponent implements OnInit {

public onResetClick(request?: TradeSearchRequest): void {
this.recordsVisible$.next(false);
this.reset.next(request);
if (request) {
this.requestChange.next(JSON.parse(JSON.stringify(request)));
} else {
this.requestChange.next();
}
}

public onItemClick(item: TradeItem): void {
Expand All @@ -95,7 +99,7 @@ export class MarketItemSearchBarComponent implements OnInit {
setTimeout(() => {
this.filterVisible$.next(false);
this.update();
}, 200)
}, 200);
}

private resetRequest(): void {
Expand Down Expand Up @@ -124,8 +128,8 @@ export class MarketItemSearchBarComponent implements OnInit {
if (hasType || hasName) {
this.items.get().subscribe(items => {
let found = false;
for (let group of items) {
for (let item of group.items) {
for (const group of items) {
for (const item of group.items) {
if ((!hasType || item.type === type) && (!hasName || item.name === name)) {
found = true;
this.setViewValue(item.text);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<app-market-item-search-bar [request]="request" (search)="onSearch()" (toggle)="onToggle($event)"
(reset)="onReset($event)">
(requestChange)="onRequestChange($event)">
</app-market-item-search-bar>

<div class="content">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class MarketItemSearchComponent implements OnInit, OnDestroy {
this.page$.next(this.page$.value + 1);
}

public onReset(request?: TradeSearchRequest): void {
public onRequestChange(request?: TradeSearchRequest): void {
this.request = request || DEFAULT_REQUEST();
this.initSearch();
this.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<mat-icon (click)="onWait($event)" *ngIf="visible['wait']">pan_tool</mat-icon>
</div>
<div class="title">
<div class="name" [title]="message.name">{{message.name | truncateText: 20}}</div>
<div class="name" [title]="message.name">{{message.name | truncateText: 30}}</div>
<div class="spacer"></div>
<div class="timer">{{message.timeReceived | timer | async}}</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@
</mat-slide-toggle>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="value-range">
<label class="label"> {{'trade.height' | translate}}:
{{displayWithPercentage(settings.tradeHeight)}}
</label>
<div class="slider">
<mat-slider min="10" max="100" step="5" tickInterval="2" [displayWith]="displayWithPercentage"
[(value)]="settings.tradeHeight" (valueChange)="onChange()">
</mat-slider>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-6">
<mat-form-field>
Expand Down Expand Up @@ -75,10 +89,10 @@
<div class="col-12">
<div class="value-range">
<label class="label"> {{'trade.sound.volume' | translate}}:
{{displayWithVolume(settings.tradeSoundVolume)}}
{{displayWithPercentage(settings.tradeSoundVolume)}}
</label>
<div class="slider">
<mat-slider min="0" max="100" step="5" tickInterval="2" [displayWith]="displayWithVolume"
<mat-slider min="0" max="100" step="5" tickInterval="2" [displayWith]="displayWithPercentage"
[(value)]="settings.tradeSoundVolume" (valueChange)="onChange()">
</mat-slider>
<button mat-raised-button color="primary" (click)="onPlay()">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class TradeSettingsComponent extends FeatureSettingsComponent<TradeFeatur

public layouts = new EnumValues(TradeLayout);
public filters = new EnumValues(TradeFilter);
public displayWithVolume = (volume: number) => `${volume}%`;
public displayWithPercentage = (volume: number) => `${volume}%`;

public load(): void { }

Expand Down
12 changes: 9 additions & 3 deletions src/app/modules/trade/service/trade-window.service.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Injectable } from '@angular/core';
import { WindowName } from '@app/config';
import { EventEmitter } from '@app/event';
import { OWWindow } from '@app/odk';
import { OWGames, OWWindow } from '@app/odk';
import { ProcessStorageService } from '@app/storage';
import { TradeExchangeMessage } from '@shared/module/poe/trade/chat';
import { Observable } from 'rxjs';
import { TradeFeatureSettings } from '../trade-feature-settings';
import { flatMap } from 'rxjs/operators';
import { TradeFeatureSettings } from '../trade-feature-settings';

const WINDOW_DATA_KEY = 'TRADE_WINDOW_DATA';

Expand Down Expand Up @@ -41,7 +41,13 @@ export class TradeWindowService {
data.settings = settings;
this.data$.next(data);
return this.window.restore().pipe(
flatMap(() => this.window.changeSize(310, 400))
flatMap(() => OWGames.getRunningGameInfo().pipe(
flatMap(({ height }) => {
const newHeight = Math.round(height * settings.tradeHeight / 100);
console.log(newHeight);
return this.window.changeSize(310, newHeight);
})
))
);
}

Expand Down
1 change: 1 addition & 0 deletions src/app/modules/trade/trade-feature-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ export interface TradeFeatureSettings extends FeatureSettings {
tradeSoundVolume: number;
tradeFilter: TradeFilter;
tradeLayout: TradeLayout;
tradeHeight: number;
}
3 changes: 2 additions & 1 deletion src/app/modules/trade/trade.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ export class TradeModule implements FeatureModule<TradeFeatureSettings> {
tradeSoundEnabled: true,
tradeSoundVolume: 75,
tradeFilter: TradeFilter.IncomingOutgoing,
tradeLayout: TradeLayout.TopToBottom
tradeLayout: TradeLayout.TopToBottom,
tradeHeight: 30
}
};
return config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
.messages {
display: flex;
flex-direction: column;
min-height: 370px;
min-height: calc(100vh - 30px);
margin-right: 10px;

&.reverse {
Expand Down
2 changes: 1 addition & 1 deletion src/app/shared/module/poe/chat/chat.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class ChatService {
this.queue$.next({ message, send: true });
}

public hideout(name: string): void {
public hideout(name: string): void {
const message = this.generateMessage('/hideout', name);
this.queue$.next({ message, send: true });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export class ItemClipboardParserService {
];
}

// TODO: get the language via rarity
public parse(
content: string,
parse?: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Injectable } from '@angular/core';
import { ItemPricePredictionHttpService } from '@data/poe-prices';
import { forkJoin, Observable } from 'rxjs';
import { Language } from '@data/poe/schema';
import { forkJoin, Observable, throwError } from 'rxjs';
import { flatMap, map } from 'rxjs/operators';
import { ContextService } from '../context';
import { CurrencyConverterService, CurrencySelectService, CurrencySelectStrategy } from '../currency';
Expand All @@ -23,6 +24,11 @@ export class ItemPricePredictionService {
leagueId = leagueId || this.context.get().leagueId;

// TODO: translate item source
const language = this.context.get().language;
if (language !== Language.English) {
return throwError('evaluate.prediction.language');
}

const { content } = item;
return this.prediction.provide(leagueId, content).pipe(
flatMap(prediction => forkJoin(
Expand Down
3 changes: 2 additions & 1 deletion src/app/shared/module/poe/trade/fetch/trade-fetch.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Injectable } from '@angular/core';
import { StorageCacheService } from '@app/cache';
import { b64DecodeUnicode } from '@app/helper';
import { TradeFetchHttpResult } from '@data/poe/schema';
import { TradeHttpService } from '@data/poe/service';
import moment from 'moment';
Expand Down Expand Up @@ -166,7 +167,7 @@ export class TradeFetchService {
},
item: {
icon: item.icon.replace(/\\/g, ''),
text: text ? atob(text) : '',
text: text ? b64DecodeUnicode(text) : '',
hashes: Object
.getOwnPropertyNames(hashes || {})
.reduce((a, b) => a.concat(hashes[b].map(([hash]) => hash)), [])
Expand Down
Loading

0 comments on commit 9f632c8

Please sign in to comment.