mirror of
https://github.com/FranP-code/format_twitter_projects_accounts_tweets.git
synced 2025-10-13 00:32:19 +00:00
Add tweet URL column and seen tracking system
This commit is contained in:
committed by
GitHub
parent
7426c3d8a2
commit
2875936f12
@@ -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;
|
||||
|
||||
42
astro-app/src/lib/seen-projects.ts
Normal file
42
astro-app/src/lib/seen-projects.ts
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user