mirror of
https://github.com/colanode/colanode.git
synced 2025-12-16 11:47:47 +01:00
31 lines
807 B
TypeScript
31 lines
807 B
TypeScript
import { LocalMessageNode } from '@colanode/client/types';
|
|
import { useWorkspace } from '@colanode/ui/contexts/workspace';
|
|
import { useLiveQuery } from '@colanode/ui/hooks/use-live-query';
|
|
import { cn } from '@colanode/ui/lib/utils';
|
|
|
|
interface MessageAuthorNameProps {
|
|
message: LocalMessageNode;
|
|
className?: string;
|
|
}
|
|
|
|
export const MessageAuthorName = ({
|
|
message,
|
|
className,
|
|
}: MessageAuthorNameProps) => {
|
|
const workspace = useWorkspace();
|
|
|
|
const userGetQuery = useLiveQuery({
|
|
type: 'user.get',
|
|
accountId: workspace.accountId,
|
|
workspaceId: workspace.id,
|
|
userId: message.createdBy,
|
|
});
|
|
|
|
if (userGetQuery.isPending || !userGetQuery.data) {
|
|
return null;
|
|
}
|
|
|
|
const user = userGetQuery.data;
|
|
return <span className={cn('font-medium', className)}>{user.name}</span>;
|
|
};
|