Skip to content

Commit

Permalink
fix: market comparison launch bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
GODrums committed Feb 23, 2025
1 parent d4489c9 commit 75fec94
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "betterfloat",
"displayName": "BetterFloat",
"version": "3.1.0",
"version": "3.1.1",
"description": "Enhance your website experience on 9+ CS2 skin markets!",
"author": "Rums",
"license": "CC BY NC SA 4.0",
Expand Down
7 changes: 5 additions & 2 deletions src/lib/handlers/urlhandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,14 @@ export function dynamicUIHandler() {

callHandleChange(new URL(location.href));

// setTimeout(showUpdatePopup, 3000);
setTimeout(showUpdatePopup, 3000);
}

async function showUpdatePopup() {
const storageKey = `show-update-popup-${chrome.runtime.getManifest().version}`;
// minor updates don't receive a new popup
const version = chrome.runtime.getManifest().version.split('.').slice(0, 2).join('.') + '.0';
const storageKey = `show-update-popup-${version}`;
console.debug('[BetterFloat] Checking for update popup', storageKey);
const showUpdate = await ExtensionStorage.sync.get<boolean>(storageKey);
// show update popup
if (showUpdate !== false) {
Expand Down
20 changes: 8 additions & 12 deletions src/lib/inline/CSFMarketComparison.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@ interface APIMarketResponse {
[market: string]: Partial<MarketEntry>;
}

const InfoIcon: React.FC<React.SVGProps<SVGSVGElement>> = (props) => (
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" {...props}>
<circle cx="12" cy="12" r="10" />
<path d="M12 16v-4" />
<path d="M12 8h.01" />
</svg>
);
const CirclePlus: React.FC<React.SVGProps<SVGSVGElement>> = (props) => (
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 15 15" fill="none" width="19" height="19" {...props}>
<circle cx="7" cy="7.5" r="7" fill="#FD484A" fillOpacity="0.25"></circle>
Expand Down Expand Up @@ -112,7 +105,7 @@ const MarketCard: React.FC<{ listing: CSFloat.ListingData; entry: MarketEntry; c

const getHref = () => {
const market_id = getMarketID(item.market_hash_name, marketDetails.source);
const href = getMarketURL({ source: marketDetails.source, market_id, buff_name: item.market_hash_name });
const href = getMarketURL({ source: marketDetails.source, market_id, buff_name: item.market_hash_name, phase: item.phase });
return href;
};

Expand Down Expand Up @@ -180,8 +173,13 @@ const CSFMarketComparison: React.FC = () => {
console.error('No item data found');
return;
}

let buff_name = item.market_hash_name;
if (item.phase) {
buff_name += ` - ${item.phase}`;
}
try {
const response = await fetch(`${process.env.PLASMO_PUBLIC_BETTERFLOATAPI}/v1/price/${item.market_hash_name}`);
const response = await fetch(`${process.env.PLASMO_PUBLIC_BETTERFLOATAPI}/v1/price/${buff_name}`);
const data = (await response.json()) as APIMarketResponse;

let convertedData = Object.entries(data)
Expand Down Expand Up @@ -211,7 +209,7 @@ const CSFMarketComparison: React.FC = () => {
setLiquidity(Number(data.liquidity));
}

const sortedData = convertedData.sort((a, b) => (!b.ask ? -1 : (a.ask ?? 0) - b.ask));
const sortedData = convertedData.sort((a, b) => (!b.ask ? -1 : !a.ask ? 1 : a.ask - b.ask));
setMarketData(sortedData || []);
} catch (error) {
console.error('Error fetching market data:', error);
Expand All @@ -234,14 +232,12 @@ const CSFMarketComparison: React.FC = () => {
};

useEffect(() => {
console.log('User:', user);
if (user) {
initData();
}
}, [user]);

useEffect(() => {
console.log('Listing:', listing);
if (listing && marketData.length === 0) {
fetchMarketData()
.catch((error) => {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/util/helperfunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export function getMarketURL({ source, buff_name, market_id = 0, phase }: { sour
return `https://steamcommunity.com/market/listings/730/${encodeURIComponent(buff_name)}`;
case MarketSource.YouPin:
if (Number(market_id) > 0) {
return `https://youpin898.com/goodInfo?id=${market_id}`;
return `https://www.youpin898.com/market/goods-list?templateId=${market_id}`;
}
return `https://youpin898.com/market/csgo?gameId=730&search=${encodeURIComponent(buff_name)}`;
case MarketSource.C5Game: {
Expand Down

0 comments on commit 75fec94

Please sign in to comment.