This commit is contained in:
2025-10-19 20:31:29 +03:00
Unverified
parent 66f0b756a0
commit f5527ca14e
67 changed files with 891 additions and 902 deletions
-6
View File
@@ -504,13 +504,10 @@ async def edit_message(
if not message:
raise HTTPException(status_code=404, detail="Message not found")
if message.user_id != current_user.id:
raise HTTPException(status_code=403, detail="You can only edit your own messages")
if not request.content.strip():
raise HTTPException(status_code=400, detail="Message content cannot be empty")
message.content = request.content.strip()
message.is_edited = True
@@ -641,7 +638,6 @@ async def add_dm_reaction(
# Broadcast reaction update to both participants
try:
from .messaging import messagingManager
await messagingManager.broadcast({
"type": "dmReactionUpdate",
"data": {
@@ -1103,7 +1099,6 @@ class MessaggingSocketManager:
if not current_user:
raise HTTPException(401)
import time
self.typing_users[current_user.id] = time.time()
# Broadcast to all connected users
@@ -1146,7 +1141,6 @@ class MessaggingSocketManager:
raise HTTPException(401)
recipient_id = int(data["data"]["recipientId"])
import time
if current_user.id not in self.dm_typing_users:
self.dm_typing_users[current_user.id] = {}
+1 -1
View File
@@ -296,7 +296,7 @@ export function ProfileDialog() {
)}
{/* Online Status */}
{currentData.userId && !currentData.isOwnProfile && (
{currentData?.userId && (
<div className="online-status-section">
<OnlineStatus userId={currentData.userId} />
</div>
@@ -9,19 +9,14 @@ import { useAppState } from "@/pages/chat/state";
interface OnlineStatusProps {
userId: number;
className?: string;
showLastSeen?: boolean;
}
export function OnlineStatus({ userId, className = "", showLastSeen = false }: OnlineStatusProps) {
const { chat } = useAppState();
const status = chat.onlineStatuses.get(userId);
export function OnlineStatus({ userId, showLastSeen = false }: OnlineStatusProps) {
const { chat, user } = useAppState();
const status = userId === user.currentUser?.id ? { online: true, lastSeen: new Date().toISOString() } : chat.onlineStatuses.get(userId);
if (!status) {
return null;
}
const formatLastSeen = (lastSeen: string): string => {
function formatLastSeen(lastSeen: string): string {
const date = new Date(lastSeen);
const now = new Date();
const diffMs = now.getTime() - date.getTime();
@@ -40,15 +35,15 @@ export function OnlineStatus({ userId, className = "", showLastSeen = false }: O
} else {
return date.toLocaleDateString();
}
};
}
return (
<div className={`online-status ${className}`}>
<div className={`status-dot ${status.online ? "online" : "offline"}`}></div>
<div className="online-status">
<div className={`status-dot ${status?.online ? "online" : "offline"}`}></div>
<span className="status-text">
{status.online ? "В сети" : "Не в сети"}
{!status ? "Загрузка..." : status?.online ? "В сети" : "Не в сети"}
</span>
{showLastSeen && !status.online && (
{showLastSeen && status && !status.online && (
<span className="last-seen">
{formatLastSeen(status.lastSeen)}
</span>