v3: follows, notifications, invite-only registration, unread markers

This commit is contained in:
khannurien
2026-03-21 18:42:47 +00:00
parent 7c098e7c4c
commit 608c6bc6a8
55 changed files with 4743 additions and 884 deletions

43
src/utils/visited.ts Normal file
View File

@@ -0,0 +1,43 @@
const DUMP_KEY = "visited_dumps";
const PLAYLIST_KEY = "visited_playlists";
const MAX_AGE_MS = 7 * 24 * 60 * 60 * 1000; // 7 days
function loadSet(key: string): Set<string> {
try {
const raw = localStorage.getItem(key);
return raw ? new Set(JSON.parse(raw) as string[]) : new Set();
} catch {
return new Set();
}
}
function saveSet(key: string, set: Set<string>): void {
try {
localStorage.setItem(key, JSON.stringify([...set]));
} catch { /* quota exceeded — ignore */ }
}
export function isDumpVisited(id: string): boolean {
return loadSet(DUMP_KEY).has(id);
}
export function isPlaylistVisited(id: string): boolean {
return loadSet(PLAYLIST_KEY).has(id);
}
export function markDumpVisited(id: string): void {
const set = loadSet(DUMP_KEY);
set.add(id);
saveSet(DUMP_KEY, set);
}
export function markPlaylistVisited(id: string): void {
const set = loadSet(PLAYLIST_KEY);
set.add(id);
saveSet(PLAYLIST_KEY, set);
}
/** Only items newer than MAX_AGE_MS are eligible to show the unread dot. */
export function isRecent(createdAt: Date): boolean {
return Date.now() - createdAt.getTime() < MAX_AGE_MS;
}