Skip to content

Commit

Permalink
Merge pull request #500 from dappforce/improvement/ui-icons
Browse files Browse the repository at this point in the history
UI Improvements and Minor Fixes
  • Loading branch information
olehmell authored Dec 19, 2023
2 parents ae8168b + 82ae4f6 commit da60267
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 48 deletions.
6 changes: 3 additions & 3 deletions src/components/ProfilePreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { cx } from '@/utils/class-names'
import { ProfileSource } from '@/utils/profile'
import { ProfileContent } from '@subsocial/api/types'
import { ComponentProps } from 'react'
import { HiPencil } from 'react-icons/hi2'
import { LuPencil } from 'react-icons/lu'
import AddressAvatar from './AddressAvatar'
import AllIdentityIcons from './AllIdentityIcons'
import Button from './Button'
Expand Down Expand Up @@ -70,7 +70,7 @@ const ProfilePreview = ({
onClick={onEditClick}
>
<span>Edit</span>
<HiPencil />
<LuPencil />
</Button>
) : (
<PopOver
Expand All @@ -85,7 +85,7 @@ const ProfilePreview = ({
variant='transparent'
onClick={onEditClick}
>
<HiPencil />
<LuPencil />
</Button>
}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,32 +127,33 @@ function ConnectTelegramButton({ address }: ProfileModalContentProps) {
window.open(url, '_blank')
setOpenedTelegramBotLink(true)
sendEvent('open_tg_notifs_bot_link')
} else {
toast.custom(
(t) => (
<Toast
t={t}
title='Use this link to connect your Telegram'
description='You will be taken to the Grill bot.'
action={
<Button
size='circle'
className='text-lg'
href={url}
target='_blank'
onClick={() => {
toast.dismiss(t.id)
setOpenedTelegramBotLink(true)
}}
>
<HiArrowUpRight />
</Button>
}
/>
),
{ duration: Infinity }
)
}

toast.custom(
(t) => (
<Toast
t={t}
title='Use this link to connect your Telegram'
description='You will be taken to the Grill bot.'
action={
<Button
size='circle'
className='text-lg'
href={url}
target='_blank'
onClick={() => {
toast.dismiss(t.id)
setOpenedTelegramBotLink(true)
sendEvent('open_tg_notifs_bot_link')
}}
>
<HiArrowUpRight />
</Button>
}
/>
),
{ duration: Infinity }
)
},
})

Expand Down
10 changes: 3 additions & 7 deletions src/components/chats/ChatItem/ChatItemMenus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,9 @@ import { useRouter } from 'next/router'
import { useEffect, useRef, useState } from 'react'
import { toast } from 'react-hot-toast'
import { BiGift } from 'react-icons/bi'
import {
BsFillPencilFill,
BsFillPinAngleFill,
BsFillReplyFill,
} from 'react-icons/bs'
import { BsFillPinAngleFill, BsFillReplyFill } from 'react-icons/bs'
import { HiChevronRight, HiCircleStack, HiLink } from 'react-icons/hi2'
import { LuShield } from 'react-icons/lu'
import { LuPencil, LuShield } from 'react-icons/lu'
import { MdContentCopy } from 'react-icons/md'
import { RiCopperCoinLine } from 'react-icons/ri'
import urlJoin from 'url-join'
Expand Down Expand Up @@ -179,7 +175,7 @@ export default function ChatItemMenus({
}
const editItem: FloatingMenusProps['menus'][number] = {
text: 'Edit',
icon: BsFillPencilFill,
icon: LuPencil,
onClick: () => setMessageToEdit(messageId),
}
const showDonateMenuItem = messageOwnerEvmAddress && canSendMessage
Expand Down
11 changes: 6 additions & 5 deletions src/components/chats/ChatRoom/ActionDetailBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import Button from '@/components/Button'
import { getPostQuery } from '@/services/api/query'
import { useMessageData } from '@/stores/message'
import { ComponentProps } from 'react'
import { BsFillPencilFill, BsFillReplyFill } from 'react-icons/bs'
import { BsFillReplyFill } from 'react-icons/bs'
import { HiXMark } from 'react-icons/hi2'
import { LuPencil } from 'react-icons/lu'
import RepliedMessagePreview from '../ChatItem/RepliedMessagePreview'
import usePinnedMessage from '../hooks/usePinnedMessage'
import { getMessageElementId, scrollToMessageElement } from '../utils'
Expand Down Expand Up @@ -44,12 +45,12 @@ export default function ActionDetailBar({
onClick={() => onMessageClick(replyTo)}
>
{replyTo ? (
<div className='flex-shrink-0 pl-2 pr-3 text-text-muted'>
<BsFillReplyFill className='text-2xl' />
<div className='flex-shrink-0 pl-2 pr-4 text-text-muted'>
<BsFillReplyFill className='text-lg' />
</div>
) : (
<div className='flex-shrink-0 pl-2 pr-3 text-text-muted'>
<BsFillPencilFill className='text-2xl' />
<div className='flex-shrink-0 pl-2 pr-4 text-text-muted'>
<LuPencil className='text-lg' />
</div>
)}
<RepliedMessagePreview
Expand Down
5 changes: 2 additions & 3 deletions src/components/modals/about/AboutChatModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ import {
HiCircleStack,
HiOutlineEye,
HiOutlineEyeSlash,
HiPencilSquare,
HiQrCode,
} from 'react-icons/hi2'
import { LuShield } from 'react-icons/lu'
import { LuPencil, LuShield } from 'react-icons/lu'
import { RxEnter, RxExit } from 'react-icons/rx'
import urlJoin from 'url-join'
import ConfirmationModal from '../ConfirmationModal'
Expand Down Expand Up @@ -144,7 +143,7 @@ export default function AboutChatModal({
if (chatOwner === address) {
additionalMenus.push({
text: 'Edit',
icon: HiPencilSquare,
icon: LuPencil,
iconClassName: cx('text-text-muted'),
onClick: () => {
setOpenedModalType('edit')
Expand Down
3 changes: 0 additions & 3 deletions src/hooks/useIsMessageBlocked.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { getPostQuery } from '@/services/api/query'
import { getLinkedIdentityQuery } from '@/services/datahub/identity/query'
import { getBlockedResourcesQuery } from '@/services/datahub/moderation/query'
import { isMessageBlocked } from '@/utils/chat'
import { getAppId } from '@/utils/env/client'
Expand Down Expand Up @@ -41,8 +40,6 @@ export default function useIsMessageBlocked(
spaceId: hubId,
})
const { data: chat } = getPostQuery.useQuery(chatId)
const ownerId = chat?.struct.ownerId
const { data: identity } = getLinkedIdentityQuery.useQuery(ownerId ?? '')

const entityId = chat?.entityId ?? ''
const { data: chatModerationData } = getBlockedResourcesQuery.useQuery({
Expand Down
8 changes: 6 additions & 2 deletions src/hooks/useLoginAndRequestToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default function useLoginAndRequestToken(
) {
const { mutateAsync: requestToken } = useRequestToken()
const login = useMyAccount((state) => state.login)
const currentAddress = useMyAccount((state) => state.address)
const loginAsTemporaryAccount = useMyAccount(
(state) => state.loginAsTemporaryAccount
)
Expand All @@ -16,8 +17,11 @@ export default function useLoginAndRequestToken(
const loginFunc = config?.asTemporaryAccount
? loginAsTemporaryAccount
: login
const address = await loginFunc()
if (!address) throw new Error('Failed to login')
let address: string | false | null = currentAddress
if (!address) {
address = await loginFunc()
if (!address) throw new Error('Failed to login')
}

await requestToken({ address })

Expand Down
7 changes: 7 additions & 0 deletions src/services/datahub/identity/subscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ import { getLinkedIdentityQuery } from './query'
export function useDatahubIdentitySubscriber() {
const queryClient = useQueryClient()
const unsubRef = useRef<(() => void) | undefined>()
const subState = useSubscriptionState(
(state) => state.subscriptionState['identity']
)

useEffect(() => {
if (subState === 'always-sub') unsubRef.current = subscription(queryClient)
}, [subState, queryClient])

useEffect(() => {
if (!getDatahubConfig()) return
Expand Down
7 changes: 7 additions & 0 deletions src/services/datahub/posts/subscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ import {
export function useDatahubPostSubscriber(subscribedPostId?: string) {
const queryClient = useQueryClient()
const unsubRef = useRef<(() => void) | undefined>()
const subState = useSubscriptionState(
(state) => state.subscriptionState['identity']
)

useEffect(() => {
if (subState === 'always-sub') unsubRef.current = subscription(queryClient)
}, [subState, queryClient])

useEffect(() => {
if (!getDatahubConfig()) return
Expand Down

0 comments on commit da60267

Please sign in to comment.