full update

This commit is contained in:
payacom
2026-07-18 14:29:05 +03:30
parent 17f334d0f1
commit af5b27b610
239 changed files with 10283 additions and 3041 deletions

View File

@@ -0,0 +1,20 @@
export const DELETE_WINDOW_MS = 24 * 60 * 60 * 1000;
export function parseMessageCreatedAt(
createdAt?: string | null,
createdAtIso?: string | null
): Date | null {
const raw = createdAtIso || createdAt;
if (!raw) return null;
const d = new Date(String(raw));
return Number.isNaN(d.getTime()) ? null : d;
}
export function isMessageDeletable(
createdAt?: string | null,
createdAtIso?: string | null
): boolean {
const created = parseMessageCreatedAt(createdAt, createdAtIso);
if (!created) return false;
return Date.now() - created.getTime() <= DELETE_WINDOW_MS;
}

View File

@@ -28,10 +28,13 @@ export function getChatSocket(): Socket | null {
export function releaseChatSocket(): void {
refCount = Math.max(0, refCount - 1);
if (refCount === 0 && sharedSocket) {
sharedSocket.removeAllListeners();
}
export function disconnectChatSocket(): void {
if (sharedSocket) {
sharedSocket.disconnect();
sharedSocket = null;
refCount = 0;
}
}