diff --git a/src/components/channel/ChannelTopBarContent.tsx b/src/components/channel/ChannelTopBarContent.tsx index 3ef5f07..9f98540 100644 --- a/src/components/channel/ChannelTopBarContent.tsx +++ b/src/components/channel/ChannelTopBarContent.tsx @@ -6,7 +6,7 @@ import useThemeColors from '@/hooks/useThemeColors'; import { toggleChannelMembers } from '@/store/slices/collapsiblesSlice'; import { ChannelTypes } from '@/types/enums/ChannelTypes'; import type { Channel } from '@/types/interfaces/Channel'; -import { Center, Flex, Icon, IconButton, Spacer, useDisclosure } from '@chakra-ui/react'; +import { Flex, Icon, IconButton, Spacer, useDisclosure } from '@chakra-ui/react'; import { useState } from 'react'; import { MdAlternateEmail, MdMenu, MdNumbers, MdPeople, MdPhone, MdSearch, MdVideocam } from 'react-icons/md'; import { useDispatch } from 'react-redux'; @@ -21,7 +21,12 @@ export type UserTopBarProps = { channelRef: any; }; -export default function ChannelTopBarContent({ channel, userSidebarRef, channelFlexRef, channelRef }: Readonly) { +export default function ChannelTopBarContent({ + channel, + userSidebarRef, + channelFlexRef, + channelRef +}: Readonly) { const dispatch = useDispatch(); const { getColorValue } = useThemeColors(); const recipient = client.users.resolve(channel.type === ChannelTypes.DirectMessage ? channel.recipient : ''); @@ -32,126 +37,110 @@ export default function ChannelTopBarContent({ channel, userSidebarRef, channelF return ( <> - + {isMobile && ( -
- } - onClick={() => { - if (mobileShowSidebar) { - channelFlexRef.current?.scrollIntoView({ - behavior: 'smooth' - }); - setMobileShowSidebar(false); - } else { - channelRef.current?.scrollIntoView({ - behavior: 'smooth' - }); - setMobileShowSidebar(true); - } - }} - /> -
- )} -
- -
-
- {channel.type === ChannelTypes.DirectMessage ? ( - - ) : null} - } + onClick={() => { + if (mobileShowSidebar) { + channelFlexRef.current?.scrollIntoView({ + behavior: 'smooth' + }); + setMobileShowSidebar(false); + } else { + channelRef.current?.scrollIntoView({ + behavior: 'smooth' + }); + setMobileShowSidebar(true); + } }} - onClick={channel.type === ChannelTypes.DirectMessage ? onOpen : undefined} - > - {channel.type === ChannelTypes.DirectMessage ? recipient.username : channel.name} - -
- {channel.type === ChannelTypes.DirectMessage ? ( -
+ /> + )} + + {channel.type === ChannelTypes.DirectMessage && ( + + )} + + {channel.type === ChannelTypes.DirectMessage ? recipient.username : channel.name} + + {channel.type === ChannelTypes.DirectMessage && ( + <> -
- ) : null} - {channel.type === ChannelTypes.DirectMessage && recipient.presence ? ( -
- - {recipient.presence} - -
- ) : null} + {recipient.presence && ( + + {recipient.presence} + + )} + + )}
{(channel.type === ChannelTypes.DirectMessage || channel.type === ChannelTypes.Group) && ( <> -
- } - /> -
-
- } - /> -
- - )} - {channel.type === ChannelTypes.Group || channel.type === ChannelTypes.Text ? ( -
{ - if (!isMobile) { - dispatch(toggleChannelMembers()); - } else { - if (mobileShowUsers) { - userSidebarRef.current?.scrollIntoView({ - behavior: 'smooth' - }); - setMobileShowUsers(false); - } else { - channelRef.current?.scrollIntoView({ - behavior: 'smooth' - }); - setMobileShowUsers(true); - } - } - }} - icon={} + icon={} + /> + } /> -
- ) : null} -
+ + )} + {(channel.type === ChannelTypes.Group || channel.type === ChannelTypes.Text) && ( } + onClick={() => { + if (!isMobile) { + dispatch(toggleChannelMembers()); + } else { + if (mobileShowUsers) { + userSidebarRef.current?.scrollIntoView({ + behavior: 'smooth' + }); + setMobileShowUsers(false); + } else { + channelRef.current?.scrollIntoView({ + behavior: 'smooth' + }); + setMobileShowUsers(true); + } + } + }} + icon={} /> -
+ )} + } + />
); diff --git a/src/components/layout/MainSidebar.tsx b/src/components/layout/MainSidebar.tsx index a3d8779..9bbe47d 100644 --- a/src/components/layout/MainSidebar.tsx +++ b/src/components/layout/MainSidebar.tsx @@ -102,27 +102,29 @@ export function DirectChannelLink({ channel, isSelected }: Readonly - + - + {channel.type === ChannelTypes.DirectMessage ? recipient.username : channel.name} - {channel.type === ChannelTypes.DirectMessage ? ( - recipient.presence ? ( - - {recipient.presence} - - ) : null - ) : channel.type === ChannelTypes.Group ? ( - {channel.recipients.length} Members - ) : null} + {channel.type === ChannelTypes.DirectMessage + ? recipient.presence && ( + + {recipient.presence} + + ) + : channel.type === ChannelTypes.Group && ( + + {channel.recipients.length} Members + + )} {isHovering ? ( diff --git a/src/components/layout/ProfileBox.tsx b/src/components/layout/ProfileBox.tsx index ed9257f..75bb4bc 100644 --- a/src/components/layout/ProfileBox.tsx +++ b/src/components/layout/ProfileBox.tsx @@ -1,12 +1,14 @@ import { client } from '@/client'; -import { Box, Center, Flex, IconButton, Spacer, useDisclosure } from '@chakra-ui/react'; +import { Box, Flex, IconButton, Spacer, useDisclosure } from '@chakra-ui/react'; import { MdSettings } from 'react-icons/md'; import OverflownText from '../misc/OverflownText'; import SettingsModal from '../modals/SettingsModal'; import Avatar from '../user/Avatar'; import StatusIndicator from '../user/StatusIndicator'; +import useThemeColors from '@/hooks/useThemeColors'; export default function ProfileBox() { + const { getColorValue } = useThemeColors(); const { isOpen, onOpen, onClose } = useDisclosure(); const user = client.user; @@ -14,34 +16,36 @@ export default function ProfileBox() { -
+ } /> -
-
- + + + {user.username} - {user.presence ? {user.presence} : null} + {user.presence && ( + + {user.presence} + + )} -
+
- + -
- } - /> -
+ } + />
diff --git a/src/components/layout/UsersSidebar.tsx b/src/components/layout/UsersSidebar.tsx index d66ebd2..08a476c 100644 --- a/src/components/layout/UsersSidebar.tsx +++ b/src/components/layout/UsersSidebar.tsx @@ -46,11 +46,16 @@ export function UserListItem({ user, onClick }: Readonly) { {user.username} - {user.presence ? ( - + {user.presence && ( + {user.presence} - ) : null} + )} diff --git a/src/components/modals/SettingsModal.tsx b/src/components/modals/SettingsModal.tsx index d5b6f9e..c278aa5 100644 --- a/src/components/modals/SettingsModal.tsx +++ b/src/components/modals/SettingsModal.tsx @@ -13,7 +13,6 @@ import { ModalHeader, ModalOverlay, Stack, - Switch, Text } from '@chakra-ui/react'; import { MdKeyboardArrowDown } from 'react-icons/md'; diff --git a/src/components/modals/UserProfileModal.tsx b/src/components/modals/UserProfileModal.tsx index 3a58130..a87a7c7 100644 --- a/src/components/modals/UserProfileModal.tsx +++ b/src/components/modals/UserProfileModal.tsx @@ -52,11 +52,15 @@ export default function UserProfileModal({ @{user.username} - {user.presence ? ( - + {user.presence && ( + {user.presence} - ) : null} + )}