Skip to content

Commit

Permalink
Merge branch 'deploy/epic' of https://github.com/dappforce/grillchat
Browse files Browse the repository at this point in the history
…into deploy/epic
  • Loading branch information
teodorus-nathaniel committed Jul 15, 2024
2 parents 5097c10 + 74f890d commit 6a3201e
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 26 deletions.
9 changes: 8 additions & 1 deletion src/components/chats/ChatItem/ChatItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export type ChatItemProps = Omit<ComponentProps<'div'>, 'children'> & {
hubId: string
bg?: 'background-light' | 'background'
showApproveButton?: boolean
disableSuperLike?: boolean
menuIdPrefix?: string
}

Expand All @@ -41,6 +42,7 @@ export default function ChatItem({
enableChatMenu = true,
chatId,
hubId,
disableSuperLike,
bg = 'background-light',
showApproveButton,
enableProfileModal = true,
Expand Down Expand Up @@ -99,6 +101,7 @@ export default function ChatItem({
config={config}
superLikeProps={props}
messageBubbleId={messageBubbleId}
disableSuperLike={disableSuperLike}
>
{extensions && extensions.length > 0 ? (
<ChatItemWithExtension
Expand All @@ -107,6 +110,7 @@ export default function ChatItem({
isMyMessage={isMyMessage}
chatId={chatId}
hubId={hubId}
disableSuperLike={disableSuperLike}
enableProfileModal={enableProfileModal}
bg={bg}
showApproveButton={showApproveButton}
Expand All @@ -116,6 +120,7 @@ export default function ChatItem({
message={message}
isMyMessage={isMyMessage}
scrollToMessage={scrollToMessage}
disableSuperLike={disableSuperLike}
chatId={chatId}
enableProfileModal={enableProfileModal}
hubId={hubId}
Expand Down Expand Up @@ -154,6 +159,7 @@ type ChatItemMenuWrapperProps = {
postRewards?: PostRewards | undefined | null
}
children: React.ReactNode
disableSuperLike?: boolean
messageBubbleId?: string
}

Expand Down Expand Up @@ -185,6 +191,7 @@ const ChatItemMenuWrapper = ({
superLikeProps,
children,
messageBubbleId,
disableSuperLike,
}: ChatItemMenuWrapperProps) => {
const containerRef = useRef<HTMLDivElement>(null)
const { toggleDisplay, referenceProps } = config || {}
Expand Down Expand Up @@ -238,7 +245,7 @@ const ChatItemMenuWrapper = ({
e.preventDefault()
e.stopPropagation()

if (!isDisabled && !hasILiked) {
if (!isDisabled && !disableSuperLike && !hasILiked) {
haptic?.result?.impactOccurred('medium')
handleClick()
animateHeart(e.clientX, e.clientY)
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 @@ -17,6 +17,7 @@ export type ChatItemWithMenuProps = {
hubId: string
enableProfileModal?: boolean
showBlockedMessage?: boolean
disableSuperLike?: boolean
scrollToMessage?: ScrollToMessage
showApproveButton?: boolean
menuIdPrefix?: string
Expand All @@ -28,6 +29,7 @@ function InnerChatItemWithMenu({
hubId,
enableProfileModal = true,
showBlockedMessage,
disableSuperLike,
scrollToMessage,
showApproveButton,
menuIdPrefix,
Expand All @@ -50,6 +52,7 @@ function InnerChatItemWithMenu({
message={message}
showBlockedMessage={showBlockedMessage}
messageBubbleId={getMessageElementId(message.id)}
disableSuperLike={disableSuperLike}
enableProfileModal={enableProfileModal}
scrollToMessage={scrollToMessage}
showApproveButton={showApproveButton}
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
4 changes: 3 additions & 1 deletion src/components/content-staking/SuperLike.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export type SuperLikeProps = ComponentProps<'div'> & {
postRewardClassName?: string
isMyMessage?: boolean
showWhenZero?: boolean
disabled?: boolean
}

export function SuperLikeWrapper({
Expand Down Expand Up @@ -223,6 +224,7 @@ export default function SuperLike({
isMyMessage,
withPostReward,
showWhenZero,
disabled,
...props
}: SuperLikeProps) {
const myAddress = useMyMainAddress()
Expand Down Expand Up @@ -263,7 +265,7 @@ export default function SuperLike({
? { backgroundPosition: '-1px', backgroundSize: '105%' }
: {}
}
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 @@ -77,6 +77,7 @@ export default function CommonChatItem({
hubId,
bg = 'background',
showApproveButton,
disableSuperLike,
dummySuperLike,
}: CommonChatItemProps) {
const { inView, ref } = useInView({
Expand Down Expand Up @@ -381,6 +382,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 6a3201e

Please sign in to comment.