From dda2b5e0ba4c317dcd9fb3416303501b3271c363 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Istv=C3=A1n=20Kreisz?= Date: Thu, 29 Jul 2021 00:53:12 +0200 Subject: [PATCH] 1.1.6 --- electron/databaseCoordinator.ts | 8 +++++++- electron/main.ts | 6 ++++-- package.json | 4 ++-- src/Components/ItemDetail.tsx | 16 ++++++++++------ yarn.lock | 18 +++++++++--------- 5 files changed, 32 insertions(+), 20 deletions(-) diff --git a/electron/databaseCoordinator.ts b/electron/databaseCoordinator.ts index 84dc2b5..faf33d5 100644 --- a/electron/databaseCoordinator.ts +++ b/electron/databaseCoordinator.ts @@ -124,7 +124,13 @@ const databaseCoordinator = () => { ) { return exchangeRates; } else { - return { usd: 1.1891, gbp: 0.8567, chf: 1.0954, nok: 10.2673 }; + return { + usd: 1.1891, + gbp: 0.8567, + chf: 1.0954, + nok: 10.2673, + updated: new Date().getTime(), + }; } }; diff --git a/electron/main.ts b/electron/main.ts index b7e0741..2c7249a 100644 --- a/electron/main.ts +++ b/electron/main.ts @@ -2,6 +2,7 @@ import { app, BrowserWindow } from 'electron'; import * as path from 'path'; import { nodeAPI, + calculatePrices, promiseAllSkippingErrors, isOlderThan, itemBestPrice, @@ -256,7 +257,7 @@ const updatePrices = async (forced: boolean = false) => { nodeAPI .getItemPrices(item, apiConfig()) .then((result) => { - resolve(result); + resolve(calculatePrices(result, apiConfig())); }) .catch((err) => { reject(err); @@ -281,7 +282,8 @@ const updatePrices = async (forced: boolean = false) => { const fetchAndSave = async (item: Item) => { const settings = getSettings(); - const newItem = await nodeAPI.getItemPrices(item, apiConfig()); + let newItem = await nodeAPI.getItemPrices(item, apiConfig()); + newItem = calculatePrices(newItem, apiConfig()); updateItem(newItem, !app.isPackaged); return newItem; }; diff --git a/package.json b/package.json index 18684dc..0d81ae5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "CopDeck", - "version": "1.1.5", + "version": "1.1.6", "author": "CopDeck", "description": "CopDeck Sneaker Monitor", "homepage": ".", @@ -14,7 +14,7 @@ "@craco/craco": "^6.1.2", "@headlessui/react": "^1.2.0", "@heroicons/react": "^1.0.1", - "@istvankreisz/copdeck-scraper": "1.2.6", + "@istvankreisz/copdeck-scraper": "^1.3.1", "@tailwindcss/forms": "^0.3.2", "@tailwindcss/line-clamp": "^0.2.1", "@types/node": "^15.6.1", diff --git a/src/Components/ItemDetail.tsx b/src/Components/ItemDetail.tsx index a136b53..77b43a7 100644 --- a/src/Components/ItemDetail.tsx +++ b/src/Components/ItemDetail.tsx @@ -128,13 +128,17 @@ const ItemDetail = (prop: { .find((s) => s.store.id === store.id) ?.inventory.find((inventoryItem) => inventoryItem.size === size); const storeInfo = prop.selectedItem.storeInfo.find((s) => s.store.id === store.id); - const ask = prices?.lowestAsk; - const bid = prices?.highestBid; - let askPrice: number | null | undefined = ask?.noFees; - let bidPrice: number | null | undefined = bid?.noFees; + let askPrice: number | null | undefined = prices?.lowestAsk; + let bidPrice: number | null | undefined = prices?.highestBid; if (feeType !== 'None') { - askPrice = feeType === 'Buy' ? ask?.withBuyerFees : ask?.withSellerFees; - bidPrice = feeType === 'Buy' ? bid?.withBuyerFees : bid?.withSellerFees; + askPrice = + feeType === 'Buy' + ? prices?.lowestAskWithBuyerFees + : prices?.lowestAskWithSellerFees; + bidPrice = + feeType === 'Buy' + ? prices?.highestBidWithBuyerFees + : prices?.highestBidWithSellerFees; } const askInfo: [string, number] = askPrice ? [prop.currency.symbol + askPrice, askPrice] diff --git a/yarn.lock b/yarn.lock index b068b55..af86fc1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1622,16 +1622,16 @@ resolved "https://registry.yarnpkg.com/@istanbuljs/schema/-/schema-0.1.3.tgz" integrity sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA== -"@istvankreisz/copdeck-scraper@1.2.6": - version "1.2.6" - resolved "https://registry.yarnpkg.com/@istvankreisz/copdeck-scraper/-/copdeck-scraper-1.2.6.tgz#6da612b855a7b9ea3bdc9e0a7abca014dd5ca1b2" - integrity sha512-ZLgE82LhrwM5X8HpT9K1jaqjKR2GMeOJwSyPar8lClVgn9Juoe9SxQbBdFMX1HKd5pDQeks4qjffHD5FKUoLZA== +"@istvankreisz/copdeck-scraper@^1.3.1": + version "1.3.1" + resolved "https://registry.yarnpkg.com/@istvankreisz/copdeck-scraper/-/copdeck-scraper-1.3.1.tgz#bf5018f76c4df896074c5d9cc34e94b94dae87b4" + integrity sha512-5nrvf4e7E2WqSbqesIYYXYxTp7Z/zvJUMvpaHoN6ftI6+ig1kLQ25sXGOvtvuu0NMW8zcFvqBXSB9ou+AIJGhg== dependencies: fast-xml-parser "^3.19.0" https-proxy-agent "^5.0.0" node-fetch "^2.6.1" superstruct "^0.15.2" - user-agents "^1.0.681" + user-agents "^1.0.726" "@jest/console@^26.6.2": version "26.6.2" @@ -12644,10 +12644,10 @@ use@^3.1.0: resolved "https://registry.yarnpkg.com/use/-/use-3.1.1.tgz" integrity sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ== -user-agents@^1.0.681: - version "1.0.709" - resolved "https://registry.yarnpkg.com/user-agents/-/user-agents-1.0.709.tgz#bdef0a16e726a9f76c305addb5887f9dd6a95862" - integrity sha512-QveBZyUhLLzK/mU8JTLFRmk+ZOXts98EJycEzsfZ5wpGMay2rMdmArg2CouaOdpNQ7a/F7v1PyRyNH72Xc7KlQ== +user-agents@^1.0.726: + version "1.0.726" + resolved "https://registry.yarnpkg.com/user-agents/-/user-agents-1.0.726.tgz#9a22bcc6197551653e64c75ac2c0458ad8ddb39a" + integrity sha512-FZknASSz6EizoHoLGXbkfE9rgj0PH2grJ/BmMM9Fffd8pL3qBDpWhp0hqcA2XYlRL1vXfq5/W9RcSPKtcdhIzQ== dependencies: dot-json "^1.2.2" lodash.clonedeep "^4.5.0"