Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 32 additions & 3 deletions src/pages/Matchmaker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,43 @@
const [rateLimited, setRateLimited] = useState(false);

// Bookmarks State (Stored locally)
const safeLoadBookmarks = (key) => {
try {
const raw = localStorage.getItem(key);
if (!raw) return [];
const parsed = JSON.parse(raw);
return Array.isArray(parsed) ? parsed : [];
} catch {
localStorage.removeItem(key);
return [];
}
};

const [bookmarks, setBookmarks] = useState(() => {
const cached = localStorage.getItem(`matchmaker_bookmarks_${user?.uid || "guest"}`);
return cached ? JSON.parse(cached) : [];
const userKey = `matchmaker_bookmarks_${user?.uid || "guest"}`;
if (user?.uid) {
const saved = safeLoadBookmarks(userKey);
if (saved.length === 0) {
const guestSaved = safeLoadBookmarks("matchmaker_bookmarks_guest");
if (guestSaved.length > 0) {
localStorage.setItem(userKey, JSON.stringify(guestSaved));
localStorage.removeItem("matchmaker_bookmarks_guest");
return guestSaved;
}
}
return saved;
}
return safeLoadBookmarks(userKey);
});

// Save Bookmarks to localStorage when updated
useEffect(() => {
localStorage.setItem(`matchmaker_bookmarks_${user?.uid || "guest"}`, JSON.stringify(bookmarks));
const key = `matchmaker_bookmarks_${user?.uid || "guest"}`;
try {
localStorage.setItem(key, JSON.stringify(bookmarks));
} catch {
console.warn("Failed to save bookmarks to localStorage");
}
}, [bookmarks, user]);

// GitHub Search API Caller
Expand Down Expand Up @@ -160,7 +189,7 @@
} finally {
setLoading(false);
}
}, [selectedLanguage, selectedDifficulty, searchQuery, user, ghAccessToken]);

Check warning on line 192 in src/pages/Matchmaker.jsx

View workflow job for this annotation

GitHub Actions / Lint Check

React Hook useCallback has an unnecessary dependency: 'user'. Either exclude it or remove the dependency array

// Load issues on initial component mounting
useEffect(() => {
Expand Down
Loading