This commit is contained in:
2025-06-03 11:44:51 +03:00
parent 074d6674b8
commit 8c42b7dadd
18 changed files with 6923 additions and 190 deletions

View File

@@ -10,7 +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, 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";
@@ -28,68 +28,67 @@ export default function ChatMessageAttachment({ file }: ChatMessageAttachmentPro
function GenericFileAttachment({ file }: ChatMessageAttachmentProps) {
return (
<TooltipProvider delayDuration={100}>
<div className="flex items-center gap-3 rounded-lg border bg-card p-3 shadow-sm ">
<div className="flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-md">
<FileIcon className="h-8 w-8 text-muted-foreground" contentType={file.contentType} />
</div>
<div className="flex-1 overflow-hidden">
<p className="truncate text-sm font-medium text-card-foreground">{file.filename}</p>
<p className="text-xs text-muted-foreground">{formatFileSize(file.size)}</p>
</div>
<div className="flex items-center gap-1">
<Tooltip>
<TooltipTrigger asChild>
<Button variant="ghost" size="icon" asChild>
<a href={file.url} target="_blank" rel="noreferrer" download={file.filename}>
<Download className="h-4 w-4" />
<span className="sr-only">Download</span>
</a>
</Button>
</TooltipTrigger>
<TooltipContent>Download</TooltipContent>
</Tooltip>
<Tooltip>
<TooltipTrigger asChild>
<Button variant="ghost" size="icon" asChild>
<a href={file.url} target="_blank" rel="noreferrer">
<ExternalLink className="h-4 w-4" />
<span className="sr-only">Open in new tab</span>
</a>
</Button>
</TooltipTrigger>
<TooltipContent>Open in new tab</TooltipContent>
</Tooltip>
</div>
<div className="flex items-center gap-3 rounded-lg border bg-card p-3 shadow-sm ">
<div className="flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-md">
<FileIcon className="h-8 w-8 text-muted-foreground" contentType={file.contentType} />
</div>
</TooltipProvider>
<div className="flex-1 overflow-hidden">
<p className="truncate text-sm font-medium text-card-foreground">{file.filename}</p>
<p className="text-xs text-muted-foreground">{formatFileSize(file.size)}</p>
</div>
<div className="flex items-center gap-1">
<Tooltip disableHoverableContent>
<TooltipTrigger asChild>
<Button variant="ghost" size="icon" asChild>
<a href={file.url} target="_blank" rel="noreferrer" download={file.filename}>
<Download className="h-4 w-4" />
<span className="sr-only">Download</span>
</a>
</Button>
</TooltipTrigger>
<TooltipContent>Download</TooltipContent>
</Tooltip>
<Tooltip disableHoverableContent>
<TooltipTrigger asChild>
<Button variant="ghost" size="icon" asChild>
<a href={file.url} target="_blank" rel="noreferrer">
<ExternalLink className="h-4 w-4" />
<span className="sr-only">Open in new tab</span>
</a>
</Button>
</TooltipTrigger>
<TooltipContent>Open in new tab</TooltipContent>
</Tooltip>
</div>
</div>
);
}
function ImageAttachment({ file }: ChatMessageAttachmentProps) {
return (
<Dialog>
<TooltipProvider delayDuration={100}>
<div className="group relative w-48 cursor-pointer sm:w-64">
<DialogTrigger asChild>
<AspectRatio ratio={16 / 9} className="overflow-hidden rounded-lg border bg-muted">
<img
src={file.url}
alt={file.filename}
className="h-full w-full object-cover transition-transform duration-300 group-hover:scale-105"
/>
<div className="absolute inset-0 flex items-center justify-center bg-black/30 opacity-0 transition-opacity group-hover:opacity-100">
<Maximize className="h-8 w-8 text-white" />
</div>
</AspectRatio>
</DialogTrigger>
<div className="mt-1">
<p className="truncate text-xs text-muted-foreground">
{file.filename} ({formatFileSize(file.size)})
</p>
</div>
<div className="relative w-48 sm:w-64">
<DialogTrigger asChild>
<AspectRatio
ratio={16 / 9}
className="group cursor-pointer overflow-hidden rounded-lg border bg-muted"
>
<img
src={file.url}
alt={file.filename}
className="h-full w-full object-cover transition-transform duration-300 group-hover:scale-105"
/>
<div className="absolute inset-0 flex items-center justify-center bg-black/30 opacity-0 transition-opacity group-hover:opacity-100">
<Maximize className="h-8 w-8 text-white" />
</div>
</AspectRatio>
</DialogTrigger>
<div className="mt-1">
<p className="truncate text-xs text-muted-foreground">
{file.filename} ({formatFileSize(file.size)})
</p>
</div>
</TooltipProvider>
</div>
<DialogContent className="max-w-3xl p-0">
<DialogHeader className="p-4 pb-0">

View File

@@ -3,6 +3,7 @@ import { NavLink } from "react-router";
import type { Server } from "~/lib/api/types";
import { cn, getFirstLetters } from "~/lib/utils";
import { Button } from "../ui/button";
import { Tooltip, TooltipContent, TooltipTrigger } from "../ui/tooltip";
export interface ServerButtonProps {
server: Server;
@@ -12,14 +13,25 @@ export function ServerButton({ server }: ServerButtonProps) {
return (
<NavLink to={`/app/server/${server.id}`}>
{({ isActive }) => (
<Button variant="outline" size="none" className={cn("overflow-hidden", isActive ? "bg-accent" : "")}>
<div className="flex items-center justify-center size-12">
<Avatar className="rounded-none">
<AvatarImage src={server.iconUrl} className="rounded-none" />
<AvatarFallback>{getFirstLetters(server.name, 4)}</AvatarFallback>
</Avatar>
</div>
</Button>
<Tooltip disableHoverableContent>
<TooltipTrigger asChild>
<Button
variant="outline"
size="none"
className={cn("overflow-hidden", isActive ? "bg-accent" : "")}
>
<div className="flex items-center justify-center size-12">
<Avatar className="rounded-none">
<AvatarImage src={server.iconUrl} className="rounded-none" />
<AvatarFallback>{getFirstLetters(server.name, 4)}</AvatarFallback>
</Avatar>
</div>
</Button>
</TooltipTrigger>
<TooltipContent side="right">
<p className="text-xs">{server.name}</p>
</TooltipContent>
</Tooltip>
)}
</NavLink>
);

View File

@@ -35,7 +35,7 @@ export function WebRTCConnectionManager() {
voiceState.leaveVoiceChannel();
unsubscribe();
};
});
}, []);
useEffect(() => {
if (webrtc.status === ConnectionState.DISCONNECTED) {

View File

@@ -7,7 +7,7 @@ import type { Uuid } from "~/lib/api/types"; // Adjust path
import { cn, formatFileSize } from "~/lib/utils"; // Adjust path
import TextBox from "./custom-ui/text-box"; // Adjust path, assuming TextBox is in ./custom-ui/
import { Button } from "./ui/button"; // Adjust path
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "./ui/tooltip"; // Adjust path
import { Tooltip, TooltipContent, TooltipTrigger } from "./ui/tooltip"; // Adjust path
export interface MessageBoxProps {
channelId: string;
@@ -96,28 +96,26 @@ export default function MessageBox({ channelId }: MessageBoxProps) {
>
<FileIcon contentType={file.type} className="h-7 w-7 flex-shrink-0 text-muted-foreground" />
<div className="min-w-0 flex-1">
<p className="truncate font-medium text-card-foreground">{file.name}</p>
<p className="font-medium text-card-foreground">{file.name}</p>
<p className="text-xs text-muted-foreground">{formatFileSize(file.size)}</p>
</div>
<TooltipProvider delayDuration={100}>
<Tooltip>
<TooltipTrigger asChild>
<Button
variant="ghost"
size="icon"
className="h-7 w-7 flex-shrink-0 text-muted-foreground hover:text-destructive"
onClick={() => removeAttachment(i)}
disabled={isLoading}
aria-label={`Remove ${file.name}`}
>
<X className="h-4 w-4" />
</Button>
</TooltipTrigger>
<TooltipContent side="top">
<p>Remove attachment</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
<Tooltip disableHoverableContent>
<TooltipTrigger asChild>
<Button
variant="ghost"
size="icon"
className="h-7 w-7 flex-shrink-0 text-muted-foreground hover:text-destructive"
onClick={() => removeAttachment(i)}
disabled={isLoading}
aria-label={`Remove ${file.name}`}
>
<X className="h-4 w-4" />
</Button>
</TooltipTrigger>
<TooltipContent side="top">
<p>Remove attachment</p>
</TooltipContent>
</Tooltip>
</div>
))}
</div>
@@ -133,40 +131,38 @@ export default function MessageBox({ channelId }: MessageBoxProps) {
gridTemplateRows: "auto 1fr",
}}
>
<TooltipProvider delayDuration={100}>
<Tooltip>
<TooltipTrigger asChild>
<div className="self-start row-start-1 col-start-1 row-span-2 col-span-1">
<input
type="file"
multiple
className="hidden"
ref={fileInputRef}
onChange={onFileChange}
accept="image/*,application/pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.txt,.zip,.rar,audio/*,video/*"
disabled={isLoading}
/>
<Button
type="button"
size="icon"
variant="ghost"
onClick={addAttachment}
disabled={attachments.length >= 10 || isLoading}
aria-label="Add attachment"
>
<Paperclip className="h-5 w-5" />
</Button>
</div>
</TooltipTrigger>
<TooltipContent side="top">
{attachments.length >= 10 ? (
<p>Maximum 10 attachments</p>
) : (
<p>Add attachment ({attachmentsRemaining} remaining)</p>
)}
</TooltipContent>
</Tooltip>
</TooltipProvider>
<Tooltip disableHoverableContent>
<TooltipTrigger asChild>
<div className="self-start row-start-1 col-start-1 row-span-2 col-span-1">
<input
type="file"
multiple
className="hidden"
ref={fileInputRef}
onChange={onFileChange}
accept="image/*,application/pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.txt,.zip,.rar,audio/*,video/*"
disabled={isLoading}
/>
<Button
type="button"
size="icon"
variant="ghost"
onClick={addAttachment}
disabled={attachments.length >= 10 || isLoading}
aria-label="Add attachment"
>
<Paperclip className="h-5 w-5" />
</Button>
</div>
</TooltipTrigger>
<TooltipContent side="top">
{attachments.length >= 10 ? (
<p>Maximum 10 attachments</p>
) : (
<p>Add attachment ({attachmentsRemaining} remaining)</p>
)}
</TooltipContent>
</Tooltip>
<div className="self-center row-start-1 col-start-2 row-span-2 col-span-1">
<TextBox

View File

@@ -12,7 +12,7 @@ export default function DeleteServerConfirmModal() {
};
const onConfirm = async () => {
await import("~/lib/api/client/server").then((m) => m.default.delet((data as { serverId: string }).serverId));
await import("~/lib/api/client/server").then((m) => m.default.deleteServer((data as { serverId: string }).serverId));
onClose();
};