|
|
|
|
@ -27,8 +27,10 @@ import { |
|
|
|
|
const countryCode = getLocalStorageItem(COUNTRY) |
|
|
|
|
|
|
|
|
|
export const useAd = ({ ad }: AdComponentType) => { |
|
|
|
|
const [isOpenAd, setIsOpenAd] = useState(true) |
|
|
|
|
const [isNeedToShow, setIsNeedToShow] = useState(true) |
|
|
|
|
const isMatch = isMatchPage() |
|
|
|
|
|
|
|
|
|
const [isOpenAd, setIsOpenAd] = useState(isMatch) |
|
|
|
|
const [isNeedToShow, setIsNeedToShow] = useState(isMatch) |
|
|
|
|
const [shownTime, setShownTime] = useState(0) |
|
|
|
|
|
|
|
|
|
const { isFullscreen } = useMatchPageStore() |
|
|
|
|
@ -72,7 +74,7 @@ export const useAd = ({ ad }: AdComponentType) => { |
|
|
|
|
|
|
|
|
|
const handleClose = () => { |
|
|
|
|
setIsOpenAd(false) |
|
|
|
|
isMatchPage() && setIsNeedToShow(false) |
|
|
|
|
isMatch && setIsNeedToShow(false) |
|
|
|
|
sendBannerClickEvent(EventGA.CLOSE) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -89,7 +91,7 @@ export const useAd = ({ ad }: AdComponentType) => { |
|
|
|
|
useEffect(() => { |
|
|
|
|
setShownTime(0) |
|
|
|
|
|
|
|
|
|
if (isMatchPage()) { |
|
|
|
|
if (isMatch) { |
|
|
|
|
const interval = setInterval(() => { |
|
|
|
|
setIsNeedToShow(true) |
|
|
|
|
setIsOpenAd(true) |
|
|
|
|
@ -105,6 +107,7 @@ export const useAd = ({ ad }: AdComponentType) => { |
|
|
|
|
isNeedToShow, |
|
|
|
|
views?.HOME, |
|
|
|
|
isNeedBanner, |
|
|
|
|
isMatch, |
|
|
|
|
]) |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
@ -136,14 +139,18 @@ export const useAd = ({ ad }: AdComponentType) => { |
|
|
|
|
]) |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
if (!isNeedToShow || (!isMatchPage() && !isNeedBanner)) return |
|
|
|
|
if (!isNeedToShow || (!isMatch && !isNeedBanner)) return |
|
|
|
|
|
|
|
|
|
(async () => { |
|
|
|
|
await updateAdsView({ adv_id: id }) |
|
|
|
|
})() |
|
|
|
|
sendBannerClickEvent(EventGA.DISPLAY) |
|
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
|
}, [id, isNeedToShow]) |
|
|
|
|
}, [ |
|
|
|
|
id, |
|
|
|
|
isNeedToShow, |
|
|
|
|
isMatch, |
|
|
|
|
]) |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
handleClose, |
|
|
|
|
|