From c6bdf4b33145021dc7478a2e2d716582abf09756 Mon Sep 17 00:00:00 2001 From: Taso Date: Wed, 10 Mar 2021 21:04:59 -0500 Subject: [PATCH] fix(sellout/report): Fixed sellout discord reports --- .../sellout/components/SelloutList/ListingActions.tsx | 6 ++---- .../apps/sellout/components/SelloutList/SelloutItem.tsx | 2 +- resources/client/cl_sellout.ts | 2 +- resources/server/sv_sellout.ts | 8 ++------ 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/phone/src/apps/sellout/components/SelloutList/ListingActions.tsx b/phone/src/apps/sellout/components/SelloutList/ListingActions.tsx index e518aef..228cee5 100644 --- a/phone/src/apps/sellout/components/SelloutList/ListingActions.tsx +++ b/phone/src/apps/sellout/components/SelloutList/ListingActions.tsx @@ -17,7 +17,7 @@ const useStyles = makeStyles((theme: Theme) => ({ }, })); -export const ListingActions = (listing: MarketplaceListing) => { +export const ListingActions = ({ listing }: { listing: MarketplaceListing }) => { const classes = useStyles(); const { number: myNumber } = useSimcard(); const { t } = useTranslation(); @@ -30,9 +30,7 @@ export const ListingActions = (listing: MarketplaceListing) => { }; const handleReportListing = () => { - Nui.send('phone:reportListing', { - listing, - }); + Nui.send('phone:reportListing', listing); }; const handleCall = () => { diff --git a/phone/src/apps/sellout/components/SelloutList/SelloutItem.tsx b/phone/src/apps/sellout/components/SelloutList/SelloutItem.tsx index 059c0f6..e744660 100644 --- a/phone/src/apps/sellout/components/SelloutList/SelloutItem.tsx +++ b/phone/src/apps/sellout/components/SelloutList/SelloutItem.tsx @@ -62,7 +62,7 @@ export const SelloutItem = (listing: MarketplaceListing) => { {listing.description} - + diff --git a/resources/client/cl_sellout.ts b/resources/client/cl_sellout.ts index dacd83e..11cbc86 100644 --- a/resources/client/cl_sellout.ts +++ b/resources/client/cl_sellout.ts @@ -26,7 +26,7 @@ on(`__cfx_nui:${events.SELLOUT_DELETE_LISTING}`, (data: MarketplaceListing, cb: RegisterNuiCallbackType(events.SELLOUT_REPORT_LISTING); on(`__cfx_nui:${events.SELLOUT_REPORT_LISTING}`, (data: MarketplaceListing, cb: Function) => { - emitNet(events.SELLOUT_SEND_LISTING, data); + emitNet(events.SELLOUT_REPORT_LISTING, data); cb(); }); diff --git a/resources/server/sv_sellout.ts b/resources/server/sv_sellout.ts index 6cdc69e..e09232a 100644 --- a/resources/server/sv_sellout.ts +++ b/resources/server/sv_sellout.ts @@ -49,7 +49,6 @@ async function getListing(listingId: number): Promise { const [results] = await pool.query(query, [listingId]); const listings = results; const listing = listings[0]; - return listing; } @@ -61,8 +60,8 @@ async function reportListing(listingId: number, profile: string): Promise async function doesReportExist(listingId: number, profile: string): Promise { const query = `SELECT * FROM npwd_marketplace_reports WHERE listing_id = ? AND profile = ?`; - const results = await pool.query(query, [listingId, profile]); - const result = results; + const [results] = await pool.query(query, [listingId, profile]); + const result = results; return result.length > 0; } @@ -143,11 +142,9 @@ onNet(events.SELLOUT_REPORT_LISTING, async (listing: MarketplaceListing) => { // gets the player name (steam) of the player that is reporting const reportingPlayer = GetPlayerName(pSource); - if (reportExists) { // send an info alert selloutLogger.error(`This listing has already been reported`); - emitNet(events.SELLOUT_ACTION_RESULT, pSource, { message: 'MARKETPLACE_REPORT_LISTING_FAILED', type: 'info', @@ -155,7 +152,6 @@ onNet(events.SELLOUT_REPORT_LISTING, async (listing: MarketplaceListing) => { } else { await reportListing(rListing.id, rListing.name); await reportListingToDiscord(rListing, reportingPlayer); - emitNet(events.SELLOUT_ACTION_RESULT, pSource, { message: 'MARKETPLACE_REPORT_LISTING_SUCCESS', type: 'success',