Profile avatar resize crop eklendi. Hatalar fixlendi.

This commit is contained in:
2025-12-04 21:29:20 +03:00
parent 3d67900557
commit bbc245ced1
9 changed files with 880 additions and 11 deletions

View File

@@ -17,6 +17,7 @@
import { refreshTvShowCount } from "./stores/tvStore.js";
import { refreshMusicCount } from "./stores/musicStore.js";
import { fetchTrashItems } from "./stores/trashStore.js";
import { setAvatarUrl } from "./stores/avatarStore.js";
const token = getAccessToken();
@@ -41,6 +42,34 @@
}, 400);
};
const loadUserProfile = async () => {
try {
const response = await fetch(`${API}/api/profile`, {
method: 'GET',
headers: {
'Authorization': `Bearer ${getAccessToken()}`,
'Content-Type': 'application/json'
}
});
if (response.ok) {
const profileData = await response.json();
if (profileData?.avatarExists) {
const token = getAccessToken();
if (token) {
const avatarUrl = `${API}/api/profile/avatar?token=${token}&v=${Date.now()}`;
setAvatarUrl(avatarUrl);
}
} else {
setAvatarUrl(null);
}
}
} catch (error) {
console.warn('Profil bilgileri yüklenemedi:', error);
setAvatarUrl(null);
}
};
// Menü aç/kapat (hamburger butonuyla)
const toggleMenu = () => {
menuOpen = !menuOpen;
@@ -57,6 +86,7 @@
refreshTvShowCount();
refreshMusicCount();
fetchTrashItems();
loadUserProfile();
const authToken = getAccessToken();
if (authToken) {
const wsUrl = `${API.replace("http", "ws")}?token=${authToken}`;