From 9f632c8188f1155ea21b0d5e8c760598f3b0982a Mon Sep 17 00:00:00 2001 From: Nicklas Ronge Date: Wed, 24 Jun 2020 19:07:02 +0200 Subject: [PATCH] - fixed an issue parsing unicode item data --- CHANGELOG.md | 12 +++--- manifest.json | 2 +- package.json | 2 +- src/app/core/helper/base64.ts | 11 +++++ src/app/core/helper/index.ts | 1 + .../item-price-prediction-http.service.ts | 5 ++- .../settings-form/settings-form.component.ts | 12 ++---- .../market-exchange-bar.component.ts | 10 +++-- .../market-exchange.component.html | 2 +- .../market-exchange.component.ts | 2 +- .../market-item-search-bar.component.ts | 18 +++++---- .../market-item-search.component.html | 2 +- .../market-item-search.component.ts | 2 +- .../trade-message.component.html | 2 +- .../trade-settings.component.html | 18 ++++++++- .../trade-settings.component.ts | 2 +- .../trade/service/trade-window.service.ts | 12 ++++-- .../modules/trade/trade-feature-settings.ts | 1 + src/app/modules/trade/trade.module.ts | 3 +- .../trade-window/trade-window.component.scss | 2 +- .../shared/module/poe/chat/chat.service.ts | 2 +- .../item-clipboard-parser.service.ts | 1 + .../price/item-price-prediction.service.ts | 8 +++- .../poe/trade/fetch/trade-fetch.service.ts | 3 +- .../poe/trade/search/trade-search.pipe.ts | 26 ++++++------ .../module/poe/trade/search/trade-search.ts | 40 +++++++++---------- src/assets/i18n/english.json | 2 +- 27 files changed, 125 insertions(+), 78 deletions(-) create mode 100644 src/app/core/helper/base64.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index b1f3a91c..e8c150c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/manifest.json b/manifest.json index 646170e5..43955456 100644 --- a/manifest.json +++ b/manifest.json @@ -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", diff --git a/package.json b/package.json index 91183f17..e7596921 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/app/core/helper/base64.ts b/src/app/core/helper/base64.ts new file mode 100644 index 00000000..c5a2cd90 --- /dev/null +++ b/src/app/core/helper/base64.ts @@ -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('')); +} diff --git a/src/app/core/helper/index.ts b/src/app/core/helper/index.ts index 75b11dcc..1159a6fc 100644 --- a/src/app/core/helper/index.ts +++ b/src/app/core/helper/index.ts @@ -1 +1,2 @@ +export * from './base64'; export * from './roman'; diff --git a/src/app/data/poe-prices/service/item-price-prediction-http.service.ts b/src/app/data/poe-prices/service/item-price-prediction-http.service.ts index 42fd9903..a2ac4f95 100644 --- a/src/app/data/poe-prices/service/item-price-prediction-http.service.ts +++ b/src/app/data/poe-prices/service/item-price-prediction-http.service.ts @@ -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'; @@ -19,7 +20,7 @@ export class ItemPricePredictionHttpService { } public get(leagueId: string, stringifiedItem: string): Observable { - const base64Item = btoa(stringifiedItem); + const base64Item = b64EncodeUnicode(stringifiedItem); const encodedLeagueId = encodeURIComponent(leagueId); const encodedItem = encodeURIComponent(base64Item); @@ -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); diff --git a/src/app/layout/component/settings-form/settings-form.component.ts b/src/app/layout/component/settings-form/settings-form.component.ts index a7346edc..3e495a46 100644 --- a/src/app/layout/component/settings-form/settings-form.component.ts +++ b/src/app/layout/component/settings-form/settings-form.component.ts @@ -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); @@ -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 { @@ -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; diff --git a/src/app/modules/market/component/market-exchange-bar/market-exchange-bar.component.ts b/src/app/modules/market/component/market-exchange-bar/market-exchange-bar.component.ts index 7e4dfca0..10c42a0f 100644 --- a/src/app/modules/market/component/market-exchange-bar/market-exchange-bar.component.ts +++ b/src/app/modules/market/component/market-exchange-bar/market-exchange-bar.component.ts @@ -18,10 +18,10 @@ export class MarketExchangeBarComponent { public request: TradeExchangeRequest; @Output() - public highlight = new EventEmitter(); + public requestChange = new EventEmitter(); @Output() - public reset = new EventEmitter(); + public highlight = new EventEmitter(); @Output() public toggle = new EventEmitter(); @@ -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 { diff --git a/src/app/modules/market/component/market-exchange/market-exchange.component.html b/src/app/modules/market/component/market-exchange/market-exchange.component.html index 03ff2d9a..9adda71c 100644 --- a/src/app/modules/market/component/market-exchange/market-exchange.component.html +++ b/src/app/modules/market/component/market-exchange/market-exchange.component.html @@ -1,5 +1,5 @@ + (highlight)="onHighlight($event)" (requestChange)="onRequestChange($event)">
diff --git a/src/app/modules/market/component/market-exchange/market-exchange.component.ts b/src/app/modules/market/component/market-exchange/market-exchange.component.ts index ba066aa0..b264c594 100644 --- a/src/app/modules/market/component/market-exchange/market-exchange.component.ts +++ b/src/app/modules/market/component/market-exchange/market-exchange.component.ts @@ -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(); diff --git a/src/app/modules/market/component/market-item-search-bar/market-item-search-bar.component.ts b/src/app/modules/market/component/market-item-search-bar/market-item-search-bar.component.ts index d6a3dd3c..f4006298 100644 --- a/src/app/modules/market/component/market-item-search-bar/market-item-search-bar.component.ts +++ b/src/app/modules/market/component/market-item-search-bar/market-item-search-bar.component.ts @@ -41,13 +41,13 @@ export class MarketItemSearchBarComponent implements OnInit { } @Output() - public search = new EventEmitter(); + public requestChange = new EventEmitter(); @Output() - public toggle = new EventEmitter(); + public search = new EventEmitter(); @Output() - public reset = new EventEmitter(); + public toggle = new EventEmitter(); constructor(private readonly items: TradeItemsService) { } @@ -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 { @@ -95,7 +99,7 @@ export class MarketItemSearchBarComponent implements OnInit { setTimeout(() => { this.filterVisible$.next(false); this.update(); - }, 200) + }, 200); } private resetRequest(): void { @@ -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); diff --git a/src/app/modules/market/component/market-item-search/market-item-search.component.html b/src/app/modules/market/component/market-item-search/market-item-search.component.html index 328629eb..38253f1e 100644 --- a/src/app/modules/market/component/market-item-search/market-item-search.component.html +++ b/src/app/modules/market/component/market-item-search/market-item-search.component.html @@ -1,5 +1,5 @@ + (requestChange)="onRequestChange($event)">
diff --git a/src/app/modules/market/component/market-item-search/market-item-search.component.ts b/src/app/modules/market/component/market-item-search/market-item-search.component.ts index 34d3765c..85409610 100644 --- a/src/app/modules/market/component/market-item-search/market-item-search.component.ts +++ b/src/app/modules/market/component/market-item-search/market-item-search.component.ts @@ -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(); diff --git a/src/app/modules/trade/component/trade-message/trade-message.component.html b/src/app/modules/trade/component/trade-message/trade-message.component.html index 0e2f33a3..285ec494 100644 --- a/src/app/modules/trade/component/trade-message/trade-message.component.html +++ b/src/app/modules/trade/component/trade-message/trade-message.component.html @@ -6,7 +6,7 @@ pan_tool
-
{{message.name | truncateText: 20}}
+
{{message.name | truncateText: 30}}
{{message.timeReceived | timer | async}}
diff --git a/src/app/modules/trade/component/trade-settings/trade-settings.component.html b/src/app/modules/trade/component/trade-settings/trade-settings.component.html index fd2f4a4b..10338279 100644 --- a/src/app/modules/trade/component/trade-settings/trade-settings.component.html +++ b/src/app/modules/trade/component/trade-settings/trade-settings.component.html @@ -7,6 +7,20 @@
+
+
+
+ +
+ + +
+
+
+
@@ -75,10 +89,10 @@
-