Skip to content

Commit

Permalink
Disable widget animation on the tap page
Browse files Browse the repository at this point in the history
  • Loading branch information
samchuk-vlad committed Jun 14, 2024
1 parent 2c6eb5c commit 0323efb
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
22 changes: 17 additions & 5 deletions src/modules/points/PointsWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ import { FaChevronDown } from 'react-icons/fa'
import { HiChevronRight, HiXMark } from 'react-icons/hi2'
import SlotCounter from 'react-slot-counter'

export default function PointsWidget(
props: ComponentProps<'div'> & { isNoTgScroll?: boolean }
) {
export default function PointsWidget({
withPointsAnimation = true,
...props
}: ComponentProps<'div'> & {
isNoTgScroll?: boolean
withPointsAnimation?: boolean
}) {
const [isOpen, setIsOpen] = useState(false)
const isMounted = useIsMounted()
const sendEvent = useSendEvent()
Expand Down Expand Up @@ -70,7 +74,7 @@ export default function PointsWidget(
<div className='flex items-center gap-2'>
<Image className='h-7 w-7' src={Diamond} alt='' />
<span className='flex items-center text-xl font-bold'>
<Points />
<Points withPointsAnimation={withPointsAnimation} />
</span>
<FaChevronDown className='relative' />
</div>
Expand Down Expand Up @@ -292,7 +296,13 @@ function LikeCount({ shorten }: { shorten?: boolean }) {
return <span>{formatNumber(data?.count ?? '0', { shorten })}</span>
}

function Points({ shorten }: { shorten?: boolean }) {
function Points({
shorten,
withPointsAnimation = true,
}: {
shorten?: boolean
withPointsAnimation?: boolean
}) {
const isInitializedProxy = useMyAccount.use.isInitializedProxy()
const myAddress = useMyMainAddress()
const { data, isLoading } = getBalanceQuery.useQuery(myAddress || '')
Expand All @@ -306,6 +316,8 @@ function Points({ shorten }: { shorten?: boolean }) {
return <Skeleton className='inline-block w-12' />
}

if (!withPointsAnimation) return <span>{splitValues}</span>

return (
<SlotCounter
containerClassName='relative -top-0.5'
Expand Down
6 changes: 5 additions & 1 deletion src/modules/telegram/TapPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ const TapPage = () => {
className='relative'
style={{ minHeight: '100dvh' }}
>
<PointsWidget isNoTgScroll className='sticky top-0' />
<PointsWidget
isNoTgScroll
withPointsAnimation={false}
className='sticky top-0'
/>
<TapPageContent />
<WelcomeModal />
<RewardPerDayModal />
Expand Down
4 changes: 0 additions & 4 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ export type AppCommonProps = {
}

export default function App(props: AppProps<AppCommonProps>) {
useEffect(() => {
import('eruda').then((lib) => lib.default.init())
}, [])

return (
<SessionProvider
basePath={
Expand Down
4 changes: 3 additions & 1 deletion src/pages/api/telegram-image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ const getPhotoPath = async (userId: string) => {
const photos = await getUserProfilePhotos(userId)
if (!photos?.result?.photos) return

const fileId = photos.result.photos[0][0].file_id
const fileId = photos.result.photos[0]?.[0].file_id

if (!fileId) return

try {
const res = await axios.get(`${telegramApiUrl}/getFile?file_id=${fileId}`)
Expand Down

0 comments on commit 0323efb

Please sign in to comment.