Skip to content

Commit

Permalink
Only query location on sweeps contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
IanPhilips committed Sep 18, 2024
1 parent 24c307e commit 0e9d258
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
11 changes: 1 addition & 10 deletions web/components/contract/twomba-contract-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { ContractMetric } from 'common/contract-metric'
import { base64toPoints } from 'common/edge/og'
import { HOUSE_BOT_USERNAME, SPICE_MARKET_TOOLTIP } from 'common/envs/constants'
import { getTopContractMetrics } from 'common/supabase/contract-metrics'
import { parseJsonContentToText } from 'common/util/parse'
import { DAY_MS } from 'common/util/time'
import { UserBetsSummary } from 'web/components/bet/bet-summary'
import { ScrollToTopButton } from 'web/components/buttons/scroll-to-top-button'
Expand Down Expand Up @@ -207,14 +206,6 @@ export function TwombaContractPageContent(props: ContractParams) {
const [justNowReview, setJustNowReview] = useState<null | Rating>(null)
const userReview = useReview(props.contract.id, user?.id)
const userHasReviewed = userReview || justNowReview
const [justBet, setJustBet] = useState(false)
useEffect(() => {
if (!user || !user.lastBetTime) return
const hasJustBet = user.lastBetTime > Date.now() - 3000
setJustBet(hasJustBet)
}, [user?.lastBetTime])
const showRelatedMarketsBelowBet =
parseJsonContentToText(props.contract.description).trim().length >= 200

const isSpiceMarket = !!liveContract.isSpicePayout
const isCashContract = liveContract.token === 'CASH'
Expand Down Expand Up @@ -520,7 +511,7 @@ export function TwombaContractPageContent(props: ContractParams) {
</Row>

<ScrollToTopButton className="fixed bottom-16 right-2 z-20 lg:bottom-2 xl:hidden" />
<LocationModal user={user} />
<LocationModal contract={liveContract} user={user} />
</>
)
}
Expand Down
10 changes: 7 additions & 3 deletions web/components/gidx/location-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,21 @@ import { useMonitorStatus } from 'web/hooks/use-monitor-status'
import { useEvent } from 'web/hooks/use-event'
import { User } from 'common/user'
import { Col } from '../layout/col'
import { Contract } from 'common/contract'

export const LocationModal = (props: { user: User | undefined | null }) => {
const { user } = props
export const LocationModal = (props: {
contract: Contract
user: User | undefined | null
}) => {
const { user, contract } = props
const [isOpen, setIsOpen] = useState(false)
const {
fetchMonitorStatus,
requestLocation,
loading,
monitorStatus,
monitorStatusMessage,
} = useMonitorStatus(true, user, () => setIsOpen(true))
} = useMonitorStatus(contract.token === 'CASH', user, () => setIsOpen(true))
const getLocation = useEvent(() => {
requestLocation((location) => {
if (!location) {
Expand Down

0 comments on commit 0e9d258

Please sign in to comment.