Skip to content

Commit

Permalink
Merge branch 'epic-base' into deploy/epic
Browse files Browse the repository at this point in the history
  • Loading branch information
samchuk-vlad committed Jun 27, 2024
2 parents 5d57202 + 669e3c8 commit ca397a9
Show file tree
Hide file tree
Showing 18 changed files with 157 additions and 128 deletions.
73 changes: 48 additions & 25 deletions src/components/chats/ChatItem/ChatItemMenus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ import { useSendEvent } from '@/stores/analytics'
import { useChatMenu } from '@/stores/chat-menu'
import { useMyMainAddress } from '@/stores/my-account'
import { cx } from '@/utils/class-names'
import { getIpfsContentUrl } from '@/utils/ipfs'
import { estimatedWaitTime } from '@/utils/network'
import { copyToClipboard } from '@/utils/strings'
import { Transition } from '@headlessui/react'
import { PostData } from '@subsocial/api/types'
import { ImageProperties, PostData } from '@subsocial/api/types'
import { SocialCallDataArgs } from '@subsocial/data-hub-sdk'
import { useEffect, useState } from 'react'
import { BsFillPinAngleFill } from 'react-icons/bs'
Expand All @@ -38,6 +40,7 @@ import {
} from 'react-icons/hi2'
import { IoDiamondOutline } from 'react-icons/io5'
import { LuShield } from 'react-icons/lu'
import { MdContentCopy } from 'react-icons/md'
import { useInView } from 'react-intersection-observer'
import { toast } from 'sonner'
import usePinnedMessage from '../hooks/usePinnedMessage'
Expand Down Expand Up @@ -252,32 +255,52 @@ export default function ChatItemMenus({
<SuperLikeWrapper postId={messageId} withPostReward={false}>
{({ isDisabled, handleClick, hasILiked, disabledCause }) => {
if (hasILiked) return null
const menus: FloatingMenusProps['menus'] = [
{
icon: IoDiamondOutline,
text: 'Like Message',
disabled: isDisabled,
onClick: () => {
sendEventWithRef(myAddress ?? '', (refId) => {
sendEvent(
'click_superlike',
{
eventSource: 'message_menu',
postId: messageId,
},
{ ref: refId }
)
})
handleClick()
setIsOpenChatMenu(null)
},
},
]

const imageExt = message?.content?.extensions?.find(
(ext) => ext.id === 'subsocial-image'
)
if (imageExt && isAuthorized) {
menus.push({
text: 'Copy Image URL',
icon: MdContentCopy,
onClick: () => {
copyToClipboard(
getIpfsContentUrl(
(imageExt.properties as ImageProperties).image
)
)
toast.custom((t) => (
<Toast t={t} title='Image URL copied to clipboard!' />
))
setIsOpenChatMenu(null)
},
})
}

const menuList = (
<div className='relative w-full'>
<MenuList
size='sm'
menus={[
{
icon: IoDiamondOutline,
text: 'Like Message',
disabled: isDisabled,
onClick: () => {
sendEventWithRef(myAddress ?? '', (refId) => {
sendEvent(
'click_superlike',
{
eventSource: 'message_menu',
postId: messageId,
},
{ ref: refId }
)
})
handleClick()
setIsOpenChatMenu(null)
},
},
]}
/>
<MenuList size='sm' menus={menus} />
<div className='absolute bottom-0 flex w-full flex-col'>
<div className='mx-4 border-b border-border-gray' />
</div>
Expand Down
3 changes: 1 addition & 2 deletions src/components/chats/ChatItem/variants/DefaultChatItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import ChatRelativeTime from '../ChatRelativeTime'
import LinkPreview from '../LinkPreview'
import MessageStatusIndicator from '../MessageStatusIndicator'
import RepliedMessagePreview from '../RepliedMessagePreview'
import SubTeamLabel from '../SubTeamLabel'
import { ChatItemContentProps } from './types'

export type DefaultChatItemProps = ChatItemContentProps
Expand Down Expand Up @@ -78,7 +77,7 @@ export default function DefaultChatItem({
address={ownerId}
className={cx('text-sm font-medium text-text-secondary')}
/>
<SubTeamLabel address={ownerId} />
{/* <SubTeamLabel address={ownerId} /> */}
</div>
)}
{repliedMessageId && (
Expand Down
3 changes: 1 addition & 2 deletions src/components/chats/ChatItem/variants/EmojiChatItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { getRepliedMessageId } from '../../utils'
import ChatRelativeTime from '../ChatRelativeTime'
import MessageStatusIndicator from '../MessageStatusIndicator'
import RepliedMessagePreview from '../RepliedMessagePreview'
import SubTeamLabel from '../SubTeamLabel'
import { ChatItemContentProps } from './types'

export type EmojiChatItemProps = ChatItemContentProps
Expand Down Expand Up @@ -72,7 +71,7 @@ export default function EmojiChatItem({
address={ownerId}
className={cx('mr-2 text-sm font-medium text-text-secondary')}
/>
<SubTeamLabel address={ownerId} className='!bg-background-light/50' />
{/* <SubTeamLabel address={ownerId} className='!bg-background-light/50' /> */}
</div>
)}
<div
Expand Down
5 changes: 0 additions & 5 deletions src/components/chats/ChatList/ChatList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,6 @@ function ChatListContent({
sendMessageToParentWindow('totalMessage', (totalDataCount ?? 0).toString())
}, [totalDataCount])

// useLoadMoreIfNoScroll(loadMore, messageIds?.length ?? 0, {
// scrollContainer: scrollContainerRef,
// innerContainer: innerRef,
// })

const pinnedMessageId = usePinnedMessage(chatId)
const scrollToMessage = useScrollToMessage(
scrollContainerRef,
Expand Down
1 change: 1 addition & 0 deletions src/components/chats/ChatList/PinnedMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default function PinnedMessage({
if (!message) return null

const Component = asContainer ? Container<'div'> : 'div'

return (
<div className='sticky top-0 z-10 border-b border-border-gray bg-background-light text-sm'>
<Component className='flex' onClick={() => scrollToMessage(message.id)}>
Expand Down
5 changes: 2 additions & 3 deletions src/components/extensions/common/CommonChatItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { useModerateWithSuccessToast } from '@/components/chats/ChatItem/ChatIte
import ChatRelativeTime from '@/components/chats/ChatItem/ChatRelativeTime'
import MessageStatusIndicator from '@/components/chats/ChatItem/MessageStatusIndicator'
import RepliedMessagePreview from '@/components/chats/ChatItem/RepliedMessagePreview'
import SubTeamLabel from '@/components/chats/ChatItem/SubTeamLabel'
import { getRepliedMessageId } from '@/components/chats/utils'
import SuperLike from '@/components/content-staking/SuperLike'
import useAuthorizedForModeration from '@/hooks/useAuthorizedForModeration'
Expand Down Expand Up @@ -66,7 +65,7 @@ export default function CommonChatItem({
bg = 'background',
}: CommonChatItemProps) {
const myAddress = useMyMainAddress()
const { isAuthorized } = useAuthorizedForModeration(myAddress ?? '')
const { isAuthorized } = useAuthorizedForModeration(chatId)
const { mutate: moderate, isLoading: loadingModeration } =
useModerateWithSuccessToast(message.id)
const { data: reasons } = getModerationReasonsQuery.useQuery(null)
Expand Down Expand Up @@ -189,7 +188,7 @@ export default function CommonChatItem({
color={textColor}
className={cx('text-sm font-medium text-text-secondary')}
/>
<SubTeamLabel address={ownerId} />
{/* <SubTeamLabel address={ownerId} /> */}
{othersMessage.checkMark === 'top' &&
otherMessageCheckMarkElement()}
</div>
Expand Down
24 changes: 12 additions & 12 deletions src/components/layouts/MobileNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,6 @@ type Tab = {
}

const tabs: Tab[] = [
{
id: 'memes',
text: 'Memes',
Icon: (props: ComponentProps<'div'>) => (
<div {...props} className={cx('relative', props.className)}>
<TopMemes />
<NewMemeNotice />
</div>
),
href: '/tg/memes',
},
{
id: 'friends',
text: `Friends`,
Expand All @@ -50,6 +39,17 @@ const tabs: Tab[] = [
id: 'tap',
text: 'Tap',
Icon: Tap,
href: '/tg/tap',
},
{
id: 'memes',
text: 'Memes',
Icon: (props: ComponentProps<'div'>) => (
<div {...props} className={cx('relative', props.className)}>
<TopMemes />
<NewMemeNotice />
</div>
),
href: '/tg',
},
{
Expand Down Expand Up @@ -151,7 +151,7 @@ function NewMemeNotice() {
const isMounted = useIsMounted()

if (
pathname !== '/tg/memes' &&
pathname !== '/tg' &&
isMounted &&
lastMessage &&
getLastReadTime() < lastMessage.struct.createdAtTime
Expand Down
11 changes: 7 additions & 4 deletions src/components/modals/DailyRewardModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@ export default function DailyRewardModal({
close()
}

const [selectedClaim, setSelectedClaim] = useState<
DailyRewardClaim | undefined
>()
useEffect(() => {
if (isOpen) {
setIsOpenAnimation(false)
setSelectedClaim(undefined)
}
}, [isOpen])

Expand All @@ -40,9 +44,6 @@ export default function DailyRewardModal({
const { data } = getDailyRewardQuery.useQuery(myAddress ?? '')
const { data: serverDay } = getServerDayQuery.useQuery(null)
const { mutate: claim, isLoading, error } = useClaimDailyReward()
const [selectedClaim, setSelectedClaim] = useState<
DailyRewardClaim | undefined
>()
useToastError(error, 'Failed to claim daily reward')

const claimable = data?.claims.find(
Expand Down Expand Up @@ -145,7 +146,9 @@ export default function DailyRewardModal({
disabled={!claimable}
isLoading={isLoading}
onClick={() => {
sendEvent('daily_reward_claimed')
sendEvent('daily_reward_claimed', {
value: claimable?.claimRewardPoints,
})
setSelectedClaim(claimable)
claim(undefined)
setIsOpenAnimation(true)
Expand Down
2 changes: 1 addition & 1 deletion src/modules/chat/HomePage/ChatContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type Props = {
className?: string
}

export default function ChatContent({ chatId, hubId, className }: Props) {
export default function ChatContent({ chatId, hubId }: Props) {
const [isOpenModal, setIsOpenModal] = useState(false)
const pinnedMessageId = usePinnedMessage(chatId)
const { data: message } = getPostQuery.useQuery(pinnedMessageId ?? '', {
Expand Down
4 changes: 2 additions & 2 deletions src/modules/points/PointsWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ const DrawerLinks = ({
<span className='text-center text-lg font-bold text-text-muted'>
How to earn Points:
</span>
<LinkWrapper close={onClose} href='/tg/memes'>
<LinkWrapper close={onClose} href='/tg'>
<Card className='flex w-full items-center gap-4 bg-background-light'>
<Image src={Laugh} alt='' className='h-14 w-14 flex-shrink-0' />
<div className='flex flex-col gap-1'>
Expand Down Expand Up @@ -348,7 +348,7 @@ const DrawerLinks = ({
</Button>
</Card>
</LinkWrapper>
<LinkWrapper close={onClose} href='/tg'>
<LinkWrapper close={onClose} href='/tg/tap'>
<Card className='flex w-full items-center gap-4 bg-background-light'>
<Image src={Pointup} alt='' className='h-14 w-14 flex-shrink-0' />
<div className='flex flex-col gap-1'>
Expand Down
2 changes: 1 addition & 1 deletion src/modules/telegram/TapPage/PointsClicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ const LikeMemesInfoMessage = ({
return (
<div className='absolute bottom-[75px] w-full animate-fade px-2 pb-2'>
<Link
href='/tg/memes'
href='/tg'
className='flex items-center gap-[10px] rounded-[20px] bg-slate-800 p-[10px] pr-4'
onClick={() => {
const { day } = getDayAndWeekTimestamp()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {

dayjs.extend(utc)

const INTERVAL_TIME = 10 * 1000
const INTERVAL_TIME = 30 * 1000

const useSaveTappedPointsAndEnergy = () => {
const { data: clickedPointsByDayRef, isLoading: isTappedPointsLoading } =
Expand Down
Loading

0 comments on commit ca397a9

Please sign in to comment.