Skip to content

Commit

Permalink
update variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
GODrums committed Dec 19, 2024
1 parent a652c77 commit 6923b43
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/lib/page_scripts/trade_offers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ async function fetchTradeOffers(steam_id: string, isSentPage: boolean) {
const g_steamTrades = JSON.parse(localStorage.getItem('g_steamTrades') || '{}') as FetchSteamTradesResponse;
let refetchRequired = true;
if (g_steamTrades.sent || g_steamTrades.received) {
const latestTradeId = Number.parseInt(g_steamTrades[isSentPage ? 'sent' : 'received']?.[0].tradeofferid);
const latestTradeIDFromPage = Number.parseInt(document.querySelector('.tradeoffer')?.id.split('_')[1] ?? '0');
const latestTradeOfferID = Number.parseInt(g_steamTrades[isSentPage ? 'sent' : 'received']?.[0].tradeofferid);
const latestTradeOfferIDFromPage = Number.parseInt(document.querySelector('.tradeoffer')?.id.split('_')[1] ?? '0');

refetchRequired = Number.isNaN(latestTradeId) || latestTradeId !== latestTradeIDFromPage;
refetchRequired = Number.isNaN(latestTradeOfferID) || latestTradeOfferID !== latestTradeOfferIDFromPage;
}

if (!refetchRequired) {
Expand Down Expand Up @@ -59,10 +59,10 @@ async function annotateTradeOfferItemElements() {
const tradeOfferID = tradeOffer.id.split('_')[1];
const tradeItemElements = tradeOffer.querySelectorAll('.trade_item');

const trade = isSentPage
const tradeOfferAPI = isSentPage
? steamTrades.sent.find((t) => t.tradeofferid === tradeOfferID)
: steamTrades.received.find((t) => t.tradeofferid === tradeOfferID);
if (!trade) {
if (!tradeOfferAPI) {
continue;
}

Expand All @@ -85,13 +85,13 @@ async function annotateTradeOfferItemElements() {
}

let isOwnItem = true;
let apiItem = trade?.items_to_give?.find((a) => a.classid === classId && a.instanceid === instanceId);
let apiItem = tradeOfferAPI?.items_to_give?.find((a) => a.classid === classId && a.instanceid === instanceId);
if (!apiItem) {
isOwnItem = false;
apiItem = trade?.items_to_receive?.find((a) => a.classid === classId && a.instanceid === instanceId);
apiItem = tradeOfferAPI?.items_to_receive?.find((a) => a.classid === classId && a.instanceid === instanceId);
}

const ownerId = isOwnItem ? steam_id : convertToSteamID64(trade.accountid_other);
const ownerId = isOwnItem ? steam_id : convertToSteamID64(tradeOfferAPI.accountid_other);

if (ownerId) {
tradeItemElement.setAttribute('data-csfloat-owner-steamid', ownerId);
Expand Down

0 comments on commit 6923b43

Please sign in to comment.