diff --git a/src/components/MessageInput.tsx b/src/components/MessageInput.tsx index cde19699..36ce0cb4 100644 --- a/src/components/MessageInput.tsx +++ b/src/components/MessageInput.tsx @@ -17,7 +17,7 @@ const MessageInput = ({ conversationId, replyTo, onCancelReply }: MessageInputPr const [showEmojiPicker, setShowEmojiPicker] = useState(false); const textareaRef = useRef(null); const fileInputRef = useRef(null); - + const sendMessage = useSendMessage(); const { startTyping, stopTyping } = useTypingIndicator(conversationId); @@ -32,17 +32,17 @@ const MessageInput = ({ conversationId, replyTo, onCancelReply }: MessageInputPr // Typing indicator logic useEffect(() => { let typingTimeout: NodeJS.Timeout; - + if (message.trim()) { startTyping(); - + typingTimeout = setTimeout(() => { stopTyping(); }, 3000); } else { stopTyping(); } - + return () => { if (typingTimeout) clearTimeout(typingTimeout); stopTyping(); @@ -51,17 +51,17 @@ const MessageInput = ({ conversationId, replyTo, onCancelReply }: MessageInputPr const handleSend = async () => { if (!message.trim() || sendMessage.isPending) return; - + const messageContent = message.trim(); setMessage(''); - + try { await sendMessage.mutateAsync({ conversation_id: conversationId, content: messageContent, reply_to_id: replyTo?.id, }); - + if (onCancelReply) onCancelReply(); } catch (error) { console.error('Failed to send message:', error); @@ -78,25 +78,25 @@ const MessageInput = ({ conversationId, replyTo, onCancelReply }: MessageInputPr const handleFileUpload = async (file: File) => { if (!user) return; - + setIsUploading(true); - + try { const fileExt = file.name.split('.').pop(); const fileName = `${user.id}/${Date.now()}.${fileExt}`; - + const { error: uploadError } = await supabase.storage .from('message-files') .upload(fileName, file); - + if (uploadError) throw uploadError; - + const { data: { publicUrl } } = supabase.storage .from('message-files') .getPublicUrl(fileName); - + const messageType = file.type.startsWith('image/') ? 'image' : 'file'; - + await sendMessage.mutateAsync({ conversation_id: conversationId, content: messageType === 'image' ? '📷 Image' : `📎 ${file.name}`, @@ -105,7 +105,7 @@ const MessageInput = ({ conversationId, replyTo, onCancelReply }: MessageInputPr file_name: file.name, reply_to_id: replyTo?.id, }); - + if (onCancelReply) onCancelReply(); } catch (error) { console.error('Failed to upload file:', error); @@ -122,7 +122,7 @@ const MessageInput = ({ conversationId, replyTo, onCancelReply }: MessageInputPr }; const commonEmojis = [ - '😀', '😂', '😍', '🤔', '😢', '😡', '👍', '👎', + '😀', '😂', '😍', '🤔', '😢', '😡', '👍', '👎', '❤️', '🎉', '🔥', '💯', '👏', '🙏', '💪', '🎯' ]; @@ -179,7 +179,7 @@ const MessageInput = ({ conversationId, replyTo, onCancelReply }: MessageInputPr > - + - + {/* Search */}
@@ -84,7 +84,7 @@ const MessagingInterface = () => { placeholder="Search conversations..." value={searchQuery} onChange={(e) => setSearchQuery(e.target.value)} - className="w-full pl-10 pr-4 py-2 bg-slate-800/50 border border-slate-700 rounded-lg text-white placeholder-gray-400 focus:outline-none focus:border-cyan-400/50 focus:ring-1 focus:ring-cyan-400/50" + className="input-slate pl-10" />
@@ -125,7 +125,7 @@ const MessagingInterface = () => { ) : ( )} - + {/* Typing Indicators */} {typingUsers.length > 0 && (
@@ -135,12 +135,12 @@ const MessagingInterface = () => {
- {typingUsers.map(t => t.user?.user_metadata?.full_name || t.user?.user_metadata?.user_name).join(', ')} + {typingUsers.map(t => t.user?.user_metadata?.full_name || t.user?.user_metadata?.user_name).join(', ')} {typingUsers.length === 1 ? ' is' : ' are'} typing...
)} - +
diff --git a/src/components/PostDetail.tsx b/src/components/PostDetail.tsx index bcdb03a1..18b048fe 100644 --- a/src/components/PostDetail.tsx +++ b/src/components/PostDetail.tsx @@ -25,7 +25,7 @@ const fetchPost = async (postId: number): Promise => { .select('*') .eq('id', postId) .single(); - + if (error) { throw new Error("Error fetching post: " + error.message); } @@ -35,7 +35,7 @@ const fetchPost = async (postId: number): Promise => { const PostDetail = ({ postId }: PostDetailProps) => { const navigate = useNavigate(); const [likeCount, setLikeCount] = useState(0); - + const { data: post, error, isLoading } = useQuery({ queryKey: ["post", postId], queryFn: () => fetchPost(postId) @@ -43,7 +43,7 @@ const PostDetail = ({ postId }: PostDetailProps) => { if (isLoading) { return ( -
+
Loading post...
); @@ -51,7 +51,7 @@ const PostDetail = ({ postId }: PostDetailProps) => { if (error) { return ( -
+
Error loading post: {error.message}
); @@ -59,7 +59,7 @@ const PostDetail = ({ postId }: PostDetailProps) => { if (!post) { return ( -
+
Post not found
); @@ -86,7 +86,7 @@ const PostDetail = ({ postId }: PostDetailProps) => { {/* Back Button */}