diff --git a/src/components/extensions/types.ts b/src/components/extensions/types.ts
index e08e2df20..cb8b1126d 100644
--- a/src/components/extensions/types.ts
+++ b/src/components/extensions/types.ts
@@ -1,5 +1,6 @@
import { PostContent, PostData } from '@subsocial/api/types'
import { ComponentType } from 'react'
+import { SuperLikeButtonProps } from '../content-staking/SuperLike'
export type ExtensionChatItemProps = {
message: PostData
@@ -8,8 +9,10 @@ export type ExtensionChatItemProps = {
chatId: string
hubId: string
enableProfileModal?: boolean
- bg?: 'background' | 'background-light'
+ bg?: 'background' | 'background-light' | 'background-lighter'
showApproveButton?: boolean
+ className?: string
+ dummySuperLike?: SuperLikeButtonProps
}
export type RepliedMessagePreviewPartProps = {
diff --git a/src/components/modals/LikeIntroModal.tsx b/src/components/modals/LikeIntroModal.tsx
index 0bd306603..82cebe9b3 100644
--- a/src/components/modals/LikeIntroModal.tsx
+++ b/src/components/modals/LikeIntroModal.tsx
@@ -1,15 +1,105 @@
+import Diamond from '@/assets/emojis/diamond.png'
import LikeButtonImage from '@/assets/graphics/like-button.png'
-import LikeDemoImage from '@/assets/graphics/like-message.png'
+import { getTokenomicsMetadataQuery } from '@/services/datahub/content-staking/query'
import { useSendEvent } from '@/stores/analytics'
import { LocalStorage } from '@/utils/storage'
+import { formatNumber } from '@/utils/strings'
+import { PostData } from '@subsocial/api/types'
+import dayjs from 'dayjs'
import Image from 'next/image'
-import { useEffect, useState } from 'react'
+import { useEffect, useMemo, useState } from 'react'
+import SlotCounter from 'react-slot-counter'
import Button from '../Button'
+import Card from '../Card'
+import ImageChatItem from '../extensions/image/ImageChatItem'
import Modal from './Modal'
const hasOpenedModal = new LocalStorage(() => 'has-opened-like-intro-modal')
+const DUMMY_MESSAGES: { message: PostData; superLikeCount: number }[] = [
+ {
+ message: {
+ id: '0x123',
+ struct: {
+ id: '0x123',
+ createdAtBlock: 0,
+ createdAtTime: dayjs().subtract(1, 'day').toDate().getTime(),
+ createdByAccount: '0x123',
+ downvotesCount: 0,
+ hidden: false,
+ isComment: true,
+ isRegularPost: true,
+ isSharedPost: false,
+ ownerId: '0x123',
+ rootPostId: '0x123',
+ upvotesCount: 0,
+ },
+ content: {
+ body: '',
+ canonical: '',
+ image: '',
+ isShowMore: false,
+ summary: '',
+ tags: [],
+ title: '',
+ extensions: [
+ {
+ id: 'subsocial-image',
+ properties: {
+ image:
+ 'bafybeia2mhukwxqb4gifjs63sgtoc5flcskizemmamwwc3eq6q7ftihlo4',
+ },
+ },
+ ],
+ },
+ },
+ superLikeCount: 52,
+ },
+ {
+ message: {
+ id: '0x123',
+ struct: {
+ id: '0x123',
+ createdAtBlock: 0,
+ createdAtTime: dayjs().subtract(1, 'day').toDate().getTime(),
+ createdByAccount: '0x123',
+ downvotesCount: 0,
+ hidden: false,
+ isComment: true,
+ isRegularPost: true,
+ isSharedPost: false,
+ ownerId: '0x123',
+ rootPostId: '0x123',
+ upvotesCount: 0,
+ },
+ content: {
+ body: '',
+ canonical: '',
+ image: '',
+ isShowMore: false,
+ summary: '',
+ tags: [],
+ title: '',
+ extensions: [
+ {
+ id: 'subsocial-image',
+ properties: {
+ image:
+ 'bafybeie3vdprrn4exypqyb36t3r3ua2jmv2fnh6oy5rh5knwcljij7q4h4',
+ },
+ },
+ ],
+ },
+ },
+ superLikeCount: 30,
+ },
+]
export default function LikeIntroModal() {
+ const [step, setStep] = useState(0)
+ const [pointsEarned, setPointsEarned] = useState(0)
+ const [hasILiked, setHasILiked] = useState(false)
+ const { data: tokenomics } = getTokenomicsMetadataQuery.useQuery(null)
+
const sendEvent = useSendEvent()
const [isOpenModal, setIsOpenModal] = useState(false)
useEffect(() => {
@@ -20,35 +110,108 @@ export default function LikeIntroModal() {
}
}, [sendEvent])
+ const splitted = useMemo(
+ () => formatNumber(pointsEarned).split(''),
+ [pointsEarned]
+ )
+ const current = DUMMY_MESSAGES[step]
+
+ const pointsPerLike = tokenomics
+ ? (tokenomics.likerRewardDistributionPercent / 100) *
+ Number(tokenomics.superLikeWeightPoints)
+ : 4000
+
+ const isFinished = !current
+
return (
undefined}
- title='Earn Points by liking memes!'
+ title={
+ isFinished ? 'Good job! Keep liking!' : 'Earn Points by liking memes!'
+ }
description={
-
- To get your Points for liking a meme, simply tap on{' '}
- {' '}
- below the meme.
-
+ isFinished ? null : (
+
+ To get your Points for liking a meme, simply tap on{' '}
+ {' '}
+ below the meme.
+
+ )
}
>
-
- {
- hasOpenedModal.set('true')
- setIsOpenModal(false)
- sendEvent('like_intro_modal_closed')
- }}
- >
- Got it!
-
+ {isFinished ? (
+
+
+
+ For liking 2 memes you earned:
+
+
+
+
+ {formatNumber(pointsPerLike * DUMMY_MESSAGES.length)}
+
+
+
+
{
+ sendEvent('finish_like_intro_modal')
+ setIsOpenModal(false)
+ }}
+ >
+ See More Memes
+
+
+ ) : (
+ <>
+ {
+ if (hasILiked) return
+
+ sendEvent('like_intro_modal_meme', { step: step + 1 })
+ setHasILiked(true)
+ setPointsEarned((prev) => prev + pointsPerLike)
+ setTimeout(() => {
+ setStep((prev) => prev + 1)
+ setHasILiked(false)
+ }, 1000)
+ },
+ }}
+ />
+
+
Points earned
+
+
+
+
+
+
+
+ >
+ )}
)
}
diff --git a/src/modules/points/PointsPreview.tsx b/src/modules/points/PointsPreview.tsx
index 792556d74..69e229531 100644
--- a/src/modules/points/PointsPreview.tsx
+++ b/src/modules/points/PointsPreview.tsx
@@ -33,6 +33,7 @@ function Points({
if (!withPointsAnimation) return
{splitValues}
+ // Slot counter needs to be inside a span with font-bold and text-xl or bigger to work properly, otherwise, it will always rerender
return (