Skip to content

Commit 68bdc7b

Browse files
committed
Final: Enhance app functionalities (#196)
1 parent ec26be6 commit 68bdc7b

File tree

1 file changed

+1
-48
lines changed

1 file changed

+1
-48
lines changed

MovieVerse-Mobile/www/MovieVerse-Frontend/js/user-profile.js

+1-48
Original file line numberDiff line numberDiff line change
@@ -475,9 +475,6 @@ async function displayUserList(listType, userEmail) {
475475
const listRef = collection(db, 'profiles', userEmail, listType);
476476
const userListSpan = document.getElementById(`${listType}List`);
477477

478-
const CACHE_KEY = `movieVerseUserListCache_${listType}_${userEmail}`;
479-
const CACHE_EXPIRATION_MS = 24 * 60 * 60 * 1000; // 24 hours
480-
481478
let loadingInterval;
482479
function startLoadingAnimation() {
483480
let dots = '';
@@ -492,46 +489,6 @@ async function displayUserList(listType, userEmail) {
492489
userListSpan.innerHTML = '';
493490
}
494491

495-
function loadFromCache() {
496-
const cachedData = localStorage.getItem(CACHE_KEY);
497-
if (cachedData) {
498-
const parsedCache = JSON.parse(cachedData);
499-
if (Date.now() - parsedCache.timestamp < CACHE_EXPIRATION_MS) {
500-
return parsedCache.data;
501-
}
502-
}
503-
return null;
504-
}
505-
506-
function saveToCache(data) {
507-
const cacheEntry = {
508-
data: data,
509-
timestamp: Date.now(),
510-
};
511-
localStorage.setItem(CACHE_KEY, JSON.stringify(cacheEntry));
512-
}
513-
514-
const cachedData = loadFromCache();
515-
if (cachedData) {
516-
userListSpan.innerHTML = '';
517-
cachedData.forEach(userData => {
518-
const userLink = document.createElement('a');
519-
userLink.textContent = userData.username;
520-
userLink.href = '#';
521-
userLink.id = 'userLink';
522-
userLink.style.cursor = 'pointer';
523-
userLink.onclick = () => loadProfile(userData.id);
524-
525-
userListSpan.appendChild(userLink);
526-
userListSpan.appendChild(document.createTextNode(', '));
527-
});
528-
529-
if (userListSpan.lastChild) {
530-
userListSpan.removeChild(userListSpan.lastChild);
531-
}
532-
return;
533-
}
534-
535492
startLoadingAnimation();
536493

537494
try {
@@ -541,14 +498,11 @@ async function displayUserList(listType, userEmail) {
541498
if (snapshot.empty) {
542499
userListSpan.textContent = 'N/A';
543500
} else {
544-
const fetchedData = [];
545-
546501
for (let docSnapshot of snapshot.docs) {
547502
const userRef = doc(db, 'profiles', docSnapshot.id);
548503
const userSnap = await getDoc(userRef);
549504
if (userSnap.exists()) {
550505
const userData = userSnap.data();
551-
fetchedData.push({ id: docSnapshot.id, username: userData.username });
552506

553507
const userLink = document.createElement('a');
554508
userLink.textContent = userData.username;
@@ -565,8 +519,6 @@ async function displayUserList(listType, userEmail) {
565519
if (userListSpan.lastChild) {
566520
userListSpan.removeChild(userListSpan.lastChild);
567521
}
568-
569-
saveToCache(fetchedData);
570522
}
571523
} catch (error) {
572524
console.error('Error fetching user list:', error);
@@ -608,6 +560,7 @@ async function saveProfileChanges() {
608560
favoriteActor: document.getElementById('editFavoriteActor').value,
609561
favoriteDirector: document.getElementById('editFavoriteDirector').value,
610562
personalQuote: document.getElementById('editPersonalQuote').value,
563+
profileImage: currentProfile?.profileImage || '',
611564
};
612565

613566
try {

0 commit comments

Comments
 (0)