diff --git a/.prettierrc b/.prettierrc index 0a02bce..1ca0506 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,3 +1,9 @@ { - "tabWidth": 4 + "tabWidth": 4, + "useTabs": false, + "endOfLine": "lf", + "trailingComma": "all", + "bracketSameLine": false, + "printWidth": 120, + "bracketSpacing": true } diff --git a/app/app.css b/app/app.css index 724d84f..81294ea 100644 --- a/app/app.css +++ b/app/app.css @@ -5,8 +5,8 @@ @theme { --font-sans: - "Inter", ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", - "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; + "Inter", ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", + "Noto Color Emoji"; } :root { @@ -48,16 +48,11 @@ --radius: 0.375rem; --shadow-2xs: 0 1px 3px 0px hsl(0 0% 0% / 0.05); --shadow-xs: 0 1px 3px 0px hsl(0 0% 0% / 0.05); - --shadow-sm: - 0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 1px 2px -1px hsl(0 0% 0% / 0.1); - --shadow: - 0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 1px 2px -1px hsl(0 0% 0% / 0.1); - --shadow-md: - 0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 2px 4px -1px hsl(0 0% 0% / 0.1); - --shadow-lg: - 0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 4px 6px -1px hsl(0 0% 0% / 0.1); - --shadow-xl: - 0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 8px 10px -1px hsl(0 0% 0% / 0.1); + --shadow-sm: 0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 1px 2px -1px hsl(0 0% 0% / 0.1); + --shadow: 0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 1px 2px -1px hsl(0 0% 0% / 0.1); + --shadow-md: 0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 2px 4px -1px hsl(0 0% 0% / 0.1); + --shadow-lg: 0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 4px 6px -1px hsl(0 0% 0% / 0.1); + --shadow-xl: 0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 8px 10px -1px hsl(0 0% 0% / 0.1); --shadow-2xl: 0 1px 3px 0px hsl(0 0% 0% / 0.25); } @@ -100,16 +95,11 @@ --radius: 0.375rem; --shadow-2xs: 0 1px 3px 0px hsl(0 0% 0% / 0.05); --shadow-xs: 0 1px 3px 0px hsl(0 0% 0% / 0.05); - --shadow-sm: - 0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 1px 2px -1px hsl(0 0% 0% / 0.1); - --shadow: - 0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 1px 2px -1px hsl(0 0% 0% / 0.1); - --shadow-md: - 0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 2px 4px -1px hsl(0 0% 0% / 0.1); - --shadow-lg: - 0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 4px 6px -1px hsl(0 0% 0% / 0.1); - --shadow-xl: - 0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 8px 10px -1px hsl(0 0% 0% / 0.1); + --shadow-sm: 0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 1px 2px -1px hsl(0 0% 0% / 0.1); + --shadow: 0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 1px 2px -1px hsl(0 0% 0% / 0.1); + --shadow-md: 0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 2px 4px -1px hsl(0 0% 0% / 0.1); + --shadow-lg: 0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 4px 6px -1px hsl(0 0% 0% / 0.1); + --shadow-xl: 0 1px 3px 0px hsl(0 0% 0% / 0.1), 0 8px 10px -1px hsl(0 0% 0% / 0.1); --shadow-2xl: 0 1px 3px 0px hsl(0 0% 0% / 0.25); } diff --git a/app/components/app-layout.tsx b/app/components/app-layout.tsx index bc44d4b..7dcb8ba 100644 --- a/app/components/app-layout.tsx +++ b/app/components/app-layout.tsx @@ -14,9 +14,7 @@ interface AppLayoutProps { } export default function AppLayout({ children }: AppLayoutProps) { - let servers = Object.values( - useServerListStore(useShallow((state) => state.servers)), - ); + let servers = Object.values(useServerListStore(useShallow((state) => state.servers))); const matches = useMatches(); @@ -58,9 +56,7 @@ export default function AppLayout({ children }: AppLayoutProps) { -
- {list} -
+
{list}
diff --git a/app/components/channel-area.tsx b/app/components/channel-area.tsx index a584906..991b876 100644 --- a/app/components/channel-area.tsx +++ b/app/components/channel-area.tsx @@ -1,7 +1,4 @@ -import { - useInfiniteQuery, - type QueryFunctionContext, -} from "@tanstack/react-query"; +import { useInfiniteQuery, type QueryFunctionContext } from "@tanstack/react-query"; import type { Channel, Message, MessageId } from "~/lib/api/types"; import ChatMessage from "./chat-message"; import MessageBox from "./message-box"; @@ -17,33 +14,18 @@ export default function ChannelArea({ channel }: ChannelAreaProps) { const fetchMessages = async ({ pageParam }: QueryFunctionContext) => { return await import("~/lib/api/client/channel").then((m) => - m.default.paginatedMessages( - channelId, - 50, - pageParam as MessageId | undefined, - ), + m.default.paginatedMessages(channelId, 50, pageParam as MessageId | undefined), ); }; - const { - data, - error, - fetchNextPage, - hasNextPage, - isFetching, - isFetchingNextPage, - isPending, - status, - } = useInfiniteQuery({ - queryKey: ["messages", channelId], - initialPageParam: undefined, - queryFn: fetchMessages, - getNextPageParam: (lastPage) => - lastPage.length < 50 - ? undefined - : lastPage[lastPage.length - 1]?.id, - staleTime: Infinity, - }); + const { data, error, fetchNextPage, hasNextPage, isFetching, isFetchingNextPage, isPending, status } = + useInfiniteQuery({ + queryKey: ["messages", channelId], + initialPageParam: undefined, + queryFn: fetchMessages, + getNextPageParam: (lastPage) => (lastPage.length < 50 ? undefined : lastPage[lastPage.length - 1]?.id), + staleTime: Infinity, + }); const fetchNextPageVisible = () => { if (!isFetchingNextPage && hasNextPage) fetchNextPage(); @@ -63,10 +45,7 @@ export default function ChannelArea({ channel }: ChannelAreaProps) {
{status === "success" && renderMessages(data.pages)} - +
); @@ -75,12 +54,8 @@ export default function ChannelArea({ channel }: ChannelAreaProps) { return ( <>
-
- {channel?.name} -
-
- {messageArea} -
+
{channel?.name}
+
{messageArea}
@@ -95,22 +70,13 @@ function renderMessages(pages: Message[][]) { const formatMessageDate = (date: Date) => { const now = new Date(); - const today = new Date( - now.getFullYear(), - now.getMonth(), - now.getDate(), - ); + const today = new Date(now.getFullYear(), now.getMonth(), now.getDate()); const yesterday = new Date(today); yesterday.setDate(yesterday.getDate() - 1); - const messageDate = new Date( - date.getFullYear(), - date.getMonth(), - date.getDate(), - ); + const messageDate = new Date(date.getFullYear(), date.getMonth(), date.getDate()); - const capitalize = (str: string) => - str.charAt(0).toUpperCase() + str.slice(1); + const capitalize = (str: string) => str.charAt(0).toUpperCase() + str.slice(1); if (messageDate.getTime() === today.getTime()) { const rtf = new Intl.RelativeTimeFormat(undefined, { diff --git a/app/components/chat-message-attachment.tsx b/app/components/chat-message-attachment.tsx index 3896abe..ed751b2 100644 --- a/app/components/chat-message-attachment.tsx +++ b/app/components/chat-message-attachment.tsx @@ -10,12 +10,7 @@ import { DialogTitle, DialogTrigger, } from "~/components/ui/dialog"; // Shadcn UI Dialog -import { - Tooltip, - TooltipContent, - TooltipProvider, - TooltipTrigger, -} from "~/components/ui/tooltip"; // Shadcn UI Tooltip +import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "~/components/ui/tooltip"; // Shadcn UI Tooltip import type { UploadedFile } from "~/lib/api/types"; // Adjust path as needed import { formatFileSize } from "~/lib/utils"; // Adjust path import { FileIcon } from "./file-icon"; @@ -24,9 +19,7 @@ interface ChatMessageAttachmentProps { file: UploadedFile; } -export default function ChatMessageAttachment({ - file, -}: ChatMessageAttachmentProps) { +export default function ChatMessageAttachment({ file }: ChatMessageAttachmentProps) { if (file.contentType.startsWith("image/")) { return ; } @@ -38,29 +31,17 @@ function GenericFileAttachment({ file }: ChatMessageAttachmentProps) {
- +
-

- {file.filename} -

-

- {formatFileSize(file.size)} -

+

{file.filename}

+

{formatFileSize(file.size)}

@@ -97,10 +72,7 @@ function ImageAttachment({ file }: ChatMessageAttachmentProps) {
- + {file.filename} - - {file.filename} - + {file.filename}
-
- {message.content} -
+
{message.content}
{message.attachments.map((file, i) => (
diff --git a/app/components/custom-ui/channel-list-item.tsx b/app/components/custom-ui/channel-list-item.tsx index f23b272..61fb4c5 100644 --- a/app/components/custom-ui/channel-list-item.tsx +++ b/app/components/custom-ui/channel-list-item.tsx @@ -10,12 +10,7 @@ import { useGatewayStore } from "~/stores/gateway-store"; import { useUsersStore } from "~/stores/users-store"; import { useVoiceStateStore } from "~/stores/voice-state-store"; import { Button } from "../ui/button"; -import { - ContextMenu, - ContextMenuContent, - ContextMenuItem, - ContextMenuTrigger, -} from "../ui/context-menu"; +import { ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuTrigger } from "../ui/context-menu"; import UserAvatar from "../user-avatar"; interface ChannelListItemProps { @@ -41,11 +36,8 @@ function ServerCategory({ channel }: ChannelListItemProps) { function ServerVoice({ channel }: ChannelListItemProps) { const updateVoiceState = useGatewayStore((state) => state.updateVoiceState); - const voiceStateChannel = useVoiceStateStore( - (state) => state.activeChannel, - ); - const channelVoiceState = - useChannelsVoiceStateStore((state) => state.channels[channel.id]) || {}; + const voiceStateChannel = useVoiceStateStore((state) => state.activeChannel); + const channelVoiceState = useChannelsVoiceStateStore((state) => state.channels[channel.id]) || {}; const userIds = Object.keys(channelVoiceState.users ?? {}); const { users, fetchUsersIfNotPresent } = useUsersStore( @@ -55,21 +47,14 @@ function ServerVoice({ channel }: ChannelListItemProps) { })), ); - const channelUsers = React.useMemo( - () => userIds.map((userId) => users[userId]).filter(Boolean), - [userIds, users], - ); + const channelUsers = React.useMemo(() => userIds.map((userId) => users[userId]).filter(Boolean), [userIds, users]); React.useEffect(() => { fetchUsersIfNotPresent(userIds); }, [userIds]); const onClick = () => { - if ( - voiceStateChannel?.serverId === channel.serverId && - voiceStateChannel.channelId === channel.id - ) - return; + if (voiceStateChannel?.serverId === channel.serverId && voiceStateChannel.channelId === channel.id) return; updateVoiceState(channel.serverId, channel.id); }; @@ -78,12 +63,7 @@ function ServerVoice({ channel }: ChannelListItemProps) { <> - - onDeleteChannel(channel)} - > + onDeleteChannel(channel)}> Delete @@ -104,10 +81,7 @@ function ServerVoice({ channel }: ChannelListItemProps) { {channelUsers.length > 0 && (
{channelUsers.map((user) => ( -
+
{user.displayName || user.username}
@@ -120,10 +94,7 @@ function ServerVoice({ channel }: ChannelListItemProps) { function ServerText({ channel }: ChannelListItemProps) { return ( - + {({ isActive }) => ( @@ -132,9 +103,7 @@ function ServerText({ channel }: ChannelListItemProps) { size="sm" className={cn( "justify-start w-full", - isActive - ? "bg-accent hover:bg-accent" - : "bg-secondary", + isActive ? "bg-accent hover:bg-accent" : "bg-secondary", )} >
@@ -146,10 +115,7 @@ function ServerText({ channel }: ChannelListItemProps) { - onDeleteChannel(channel)} - > + onDeleteChannel(channel)}> Delete @@ -159,9 +125,7 @@ function ServerText({ channel }: ChannelListItemProps) { ); } -export default function ServerChannelListItem({ - channel, -}: ChannelListItemProps) { +export default function ServerChannelListItem({ channel }: ChannelListItemProps) { switch (channel.type) { case ChannelType.SERVER_CATEGORY: return ; diff --git a/app/components/custom-ui/create-server-button.tsx b/app/components/custom-ui/create-server-button.tsx index c77d156..783a9a6 100644 --- a/app/components/custom-ui/create-server-button.tsx +++ b/app/components/custom-ui/create-server-button.tsx @@ -7,11 +7,7 @@ export function CreateServerButton() { const onOpen = useModalStore((state) => state.onOpen); return ( - ); diff --git a/app/components/custom-ui/home-button.tsx b/app/components/custom-ui/home-button.tsx index 4725a38..b3f2786 100644 --- a/app/components/custom-ui/home-button.tsx +++ b/app/components/custom-ui/home-button.tsx @@ -6,12 +6,7 @@ export function HomeButton() { return ( {({ isActive }) => ( -