Skip to content

Commit

Permalink
Disable super like button if contest ended
Browse files Browse the repository at this point in the history
  • Loading branch information
samchuk-vlad committed Jul 14, 2024
1 parent 6b8904d commit 070fe68
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 27 deletions.
4 changes: 4 additions & 0 deletions src/components/chats/ChatItem/ChatItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export type ChatItemProps = Omit<ComponentProps<'div'>, 'children'> & {
hubId: string
bg?: 'background-light' | 'background'
showApproveButton?: boolean
disableSuperLike?: boolean
menuIdPrefix?: string
}

Expand All @@ -34,6 +35,7 @@ export default function ChatItem({
enableChatMenu = true,
chatId,
hubId,
disableSuperLike,
bg = 'background-light',
showApproveButton,
enableProfileModal = true,
Expand Down Expand Up @@ -105,6 +107,7 @@ export default function ChatItem({
chatId={chatId}
hubId={hubId}
enableProfileModal={enableProfileModal}
disableSuperLike={disableSuperLike}
bg={bg}
showApproveButton={showApproveButton}
/>
Expand All @@ -116,6 +119,7 @@ export default function ChatItem({
chatId={chatId}
enableProfileModal={enableProfileModal}
hubId={hubId}
disableSuperLike={disableSuperLike}
bg={bg}
/>
)}
Expand Down
26 changes: 2 additions & 24 deletions src/components/chats/ChatItem/variants/DefaultChatItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default function DefaultChatItem({
hubId,
message,
isMyMessage,
disableSuperLike,
scrollToMessage,
enableProfileModal = true,
bg = 'background',
Expand Down Expand Up @@ -101,30 +102,6 @@ export default function DefaultChatItem({
<Linkify
options={{
render: ({ content, attributes }) => {
// const href = attributes.href || ''
// const baseUrl = 'https://epicapp.net'
// if (href.startsWith(baseUrl)) {
// content = content.replace(/(https?:\/\/)?(www\.)?/, '')
// }

// const messageLinkRegex =
// /^(https?:\/\/)?(www\.)?epicapp\.net\/([^\/?#]+)\/([^\/?#]+)\/([^\/?#]+)\/?$/i
// const match = href.match(messageLinkRegex)
// const messageId = match?.[5]
// if (messageId) {
// return (
// <MessageLink
// attributes={attributes as any}
// isMyMessage={isMyMessage}
// content={content}
// chatId={chatId}
// messageId={messageId}
// hubId={hubId}
// scrollToMessage={scrollToMessage}
// />
// )
// }

return (
<LinkRedirect
attributes={attributes as any}
Expand Down Expand Up @@ -171,6 +148,7 @@ export default function DefaultChatItem({
isMyMessage={isMyMessage}
withPostReward
postId={message.id}
disabled={disableSuperLike}
/>
<span className='pointer-events-none ml-4 select-none opacity-0'>
{relativeTime()}
Expand Down
2 changes: 2 additions & 0 deletions src/components/chats/ChatItem/variants/EmojiChatItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default function EmojiChatItem({
isMyMessage,
scrollToMessage,
chatId,
disableSuperLike,
enableProfileModal = true,
hubId,
...props
Expand Down Expand Up @@ -132,6 +133,7 @@ export default function EmojiChatItem({
<SuperLike
isMyMessage={isMyMessage}
withPostReward
disabled={disableSuperLike}
className={cx(
!isMyMessage && 'mt-1.5',
isMyMessage && 'flex-row-reverse'
Expand Down
1 change: 1 addition & 0 deletions src/components/chats/ChatItem/variants/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export type ChatItemContentProps = ComponentProps<'div'> & {
chatId: string
hubId: string
message: PostData
disableSuperLike?: boolean
isMyMessage: boolean
scrollToMessage?: ScrollToMessage
bg?: 'background-light' | 'background'
Expand Down
3 changes: 3 additions & 0 deletions src/components/chats/ChatList/ChatItemContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type ChatItemContainerProps = Omit<ChatItemProps, 'isMyMessage'> & {
enableProfileModal?: boolean
showBlockedMessage?: boolean
chatId: string
disableSuperLike?: boolean
hubId: string
showApproveButton?: boolean
}
Expand All @@ -25,6 +26,7 @@ function ChatItemContainer(
hubId,
showBlockedMessage,
enableProfileModal = true,
disableSuperLike,
showApproveButton,
...props
}: ChatItemContainerProps,
Expand Down Expand Up @@ -75,6 +77,7 @@ function ChatItemContainer(
chatId={chatId}
isMyMessage={isMyMessage}
enableProfileModal={enableProfileModal}
disableSuperLike={disableSuperLike}
hubId={hubId}
showApproveButton={showApproveButton}
/>
Expand Down
3 changes: 3 additions & 0 deletions src/components/chats/ChatList/ChatItemWithMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type ChatItemWithMenuProps = {
hubId: string
enableProfileModal?: boolean
showBlockedMessage?: boolean
disableSuperLike?: boolean
scrollToMessage?: ScrollToMessage
showApproveButton?: boolean
menuIdPrefix?: string
Expand All @@ -25,6 +26,7 @@ function InnerChatItemWithMenu({
hubId,
enableProfileModal = true,
showBlockedMessage,
disableSuperLike,
scrollToMessage,
showApproveButton,
menuIdPrefix,
Expand Down Expand Up @@ -54,6 +56,7 @@ function InnerChatItemWithMenu({
hubId={hubId}
chatId={chatId}
message={message}
disableSuperLike={disableSuperLike}
showBlockedMessage={showBlockedMessage}
messageBubbleId={getMessageElementId(message.id)}
enableProfileModal={enableProfileModal}
Expand Down
3 changes: 3 additions & 0 deletions src/components/chats/ChatList/ChatList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export type ChatListProps = ComponentProps<'div'> & {
scrollContainerRef?: React.RefObject<HTMLDivElement>
scrollableContainerClassName?: string
hubId: string
disableSuperLike?: boolean
chatId: string
onlyDisplayUnapprovedMessages?: boolean
newMessageNoticeClassName?: string
Expand Down Expand Up @@ -55,6 +56,7 @@ function ChatListContent({
hubId,
chatId,
scrollContainerRef: _scrollContainerRef,
disableSuperLike,
newMessageNoticeClassName,
onlyDisplayUnapprovedMessages,
...props
Expand Down Expand Up @@ -210,6 +212,7 @@ function ChatListContent({
chatId={chatId}
hubId={hubId}
message={message}
disableSuperLike={disableSuperLike}
scrollToMessage={scrollToMessage}
showApproveButton={onlyDisplayUnapprovedMessages}
/>
Expand Down
3 changes: 3 additions & 0 deletions src/components/chats/ChatRoom/ChatRoom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type ChatRoomProps = ComponentProps<'div'> & {
asContainer?: boolean
scrollableContainerClassName?: string
customAction?: ReactNode
disableSuperLike?: boolean
chatId: string
hubId: string
topElement?: ReactNode
Expand All @@ -31,6 +32,7 @@ export default function ChatRoom({
scrollableContainerClassName,
customAction,
chatId,
disableSuperLike,
hubId,
topElement,
onlyDisplayUnapprovedMessages,
Expand All @@ -46,6 +48,7 @@ export default function ChatRoom({
onlyDisplayUnapprovedMessages={onlyDisplayUnapprovedMessages}
topElement={topElement}
hubId={hubId}
disableSuperLike={disableSuperLike}
newMessageNoticeClassName={cx(replyTo && 'bottom-2')}
chatId={chatId}
asContainer={asContainer}
Expand Down
6 changes: 3 additions & 3 deletions src/components/content-staking/SuperLike.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ export type SuperLikeProps = ComponentProps<'div'> & {
postRewardClassName?: string
isMyMessage?: boolean
showWhenZero?: boolean
disabled?: boolean
}

export function SuperLikeWrapper({
postId,
children,
withPostReward,
}: {
postId: string
withPostReward: boolean
Expand Down Expand Up @@ -161,6 +161,7 @@ export default function SuperLike({
isMyMessage,
withPostReward,
showWhenZero,
disabled,
...props
}: SuperLikeProps) {
const myAddress = useMyMainAddress()
Expand All @@ -175,7 +176,6 @@ export default function SuperLike({
disabledCause,
hasILiked,
superLikeCount,
postRewards,
}) => {
if (superLikeCount <= 0 && !showWhenZero) return null
const button = (
Expand All @@ -193,7 +193,7 @@ export default function SuperLike({
})
handleClick()
}}
disabled={isDisabled}
disabled={isDisabled || disabled}
/>
)
return (
Expand Down
2 changes: 2 additions & 0 deletions src/components/extensions/common/CommonChatItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export default function CommonChatItem({
hubId,
bg = 'background',
showApproveButton,
disableSuperLike,
dummySuperLike,
}: CommonChatItemProps) {
const { inView, ref } = useInView()
Expand Down Expand Up @@ -349,6 +350,7 @@ export default function CommonChatItem({
showWhenZero={showSuperLikeWhenZero}
withPostReward
postId={message.id}
disabled={disableSuperLike}
className='mb-1.5 ml-2.5 mt-1 self-start'
/>
) : (
Expand Down
1 change: 1 addition & 0 deletions src/components/extensions/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export type ExtensionChatItemProps = {
isMyMessage?: boolean
scrollToMessage?: (messageId: string) => Promise<void>
chatId: string
disableSuperLike?: boolean
hubId: string
enableProfileModal?: boolean
bg?: 'background' | 'background-light' | 'background-lighter'
Expand Down
1 change: 1 addition & 0 deletions src/modules/chat/HomePage/ChatContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export default function ChatContent({ className }: Props) {
chatId={chatId}
hubId={env.NEXT_PUBLIC_MAIN_SPACE_ID}
className='overflow-hidden'
disableSuperLike={selectedTab === 'contest' && !!isContestEnded}
onlyDisplayUnapprovedMessages={shouldShowUnapproved}
customAction={
isCannotPost ? (
Expand Down

0 comments on commit 070fe68

Please sign in to comment.