feat: Add pm

This commit is contained in:
2026-04-27 00:45:16 +02:00
parent bc2fa7de22
commit 11c2588e45
65 changed files with 3653 additions and 214 deletions

View File

@@ -0,0 +1,49 @@
import { Injectable } from '@angular/core';
const STORAGE_PREFIX = 'metoyou_direct_message_queue';
@Injectable({ providedIn: 'root' })
export class OfflineQueueRepository {
async load(ownerId: string): Promise<string[]> {
return this.read(ownerId);
}
async enqueue(ownerId: string, messageId: string): Promise<void> {
this.write(ownerId, Array.from(new Set([...this.read(ownerId), messageId])));
}
async remove(ownerId: string, messageId: string): Promise<void> {
this.write(
ownerId,
this.read(ownerId).filter((entry) => entry !== messageId)
);
}
async clear(ownerId: string): Promise<void> {
this.write(ownerId, []);
}
private read(ownerId: string): string[] {
const rawValue = localStorage.getItem(this.key(ownerId));
if (!rawValue) {
return [];
}
try {
const parsed = JSON.parse(rawValue) as string[];
return Array.isArray(parsed) ? parsed.filter((entry) => typeof entry === 'string') : [];
} catch {
return [];
}
}
private write(ownerId: string, messageIds: string[]): void {
localStorage.setItem(this.key(ownerId), JSON.stringify(messageIds));
}
private key(ownerId: string): string {
return `${STORAGE_PREFIX}:${ownerId}`;
}
}