Add tweet URL column and seen tracking system

This commit is contained in:
Francisco Pessano
2025-07-13 20:59:15 -03:00
committed by GitHub
parent 7426c3d8a2
commit 2875936f12
5 changed files with 347 additions and 35 deletions

View File

@@ -7,6 +7,7 @@ export interface TwitterProject {
created_at: string;
project_description: string;
project_url: string | null;
original_tweet_url: string | null;
media_type: string | null;
media_thumbnail: string | null;
media_original: string | null;

View File

@@ -0,0 +1,42 @@
/**
* Utility functions for tracking seen projects using localStorage
*/
const SEEN_PROJECTS_KEY = 'twitter-projects-seen';
export function getSeenProjects(): Set<string> {
if (typeof window === 'undefined') return new Set();
try {
const stored = localStorage.getItem(SEEN_PROJECTS_KEY);
return stored ? new Set(JSON.parse(stored)) : new Set();
} catch {
return new Set();
}
}
export function markProjectAsSeen(projectId: string): void {
if (typeof window === 'undefined') return;
const seenProjects = getSeenProjects();
seenProjects.add(projectId);
localStorage.setItem(SEEN_PROJECTS_KEY, JSON.stringify([...seenProjects]));
}
export function markProjectAsUnseen(projectId: string): void {
if (typeof window === 'undefined') return;
const seenProjects = getSeenProjects();
seenProjects.delete(projectId);
localStorage.setItem(SEEN_PROJECTS_KEY, JSON.stringify([...seenProjects]));
}
export function isProjectSeen(projectId: string): boolean {
if (typeof window === 'undefined') return false;
return getSeenProjects().has(projectId);
}
export function clearAllSeenProjects(): void {
if (typeof window === 'undefined') return;
localStorage.removeItem(SEEN_PROJECTS_KEY);
}