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