добавление логирования для ленты и фото

This commit is contained in:
Professional 2025-05-22 00:15:54 +07:00
parent bc7f101f55
commit 7146611dc3

View File

@ -35,7 +35,7 @@
<img :src="photo.url"
class="d-block w-100 user-photo"
:alt="'Фото ' + currentUserToSwipe.name + ' ' + (index + 1)"
@error="onImageError($event, currentUserToSwipe, photo)">
@error="onImageError($event, currentUserToSwipe, photo, 'carousel')">
</div>
</div>
<button v-if="currentUserToSwipe.photos.length > 1" class="carousel-control-prev" type="button" :data-bs-target="`#carouselUserPhotos-${currentUserToSwipe._id}`" data-bs-slide="prev">
@ -62,7 +62,7 @@
<img :src="currentUserToSwipe.mainPhotoUrl"
class="d-block w-100 user-photo single-main-photo-img"
:alt="'Фото ' + currentUserToSwipe.name"
@error="onImageError($event, currentUserToSwipe, { url: currentUserToSwipe.mainPhotoUrl, _id: 'main_photo_fallback', isProfilePhoto: true })">
@error="onImageError($event, currentUserToSwipe, { url: currentUserToSwipe.mainPhotoUrl, _id: 'main_photo_fallback', isProfilePhoto: true }, 'mainPhotoUrl_fallback')">
</div>
<!-- Option 3: Placeholder if no photos and no mainPhotoUrl -->
<div v-else class="no-photo-placeholder d-flex align-items-center justify-content-center">
@ -111,7 +111,14 @@ const matchOccurred = ref(false);
const currentUserToSwipe = computed(() => {
if (suggestions.value.length > 0 && currentIndex.value < suggestions.value.length) {
return suggestions.value[currentIndex.value];
const currentUser = suggestions.value[currentIndex.value];
// Log for specific user if needed for deep debugging
if (currentUser && currentUser._id === "682df5f8892811c317d4c43f") { // User "Денис" ID
console.log("[SwipeView DEBUG] currentUserToSwipe for Денис:", JSON.parse(JSON.stringify(currentUser)));
console.log("[SwipeView DEBUG] Денис.mainPhotoUrl:", currentUser.mainPhotoUrl);
console.log("[SwipeView DEBUG] Денис.photos:", currentUser.photos);
}
return currentUser;
}
return null;
});
@ -230,34 +237,28 @@ const formatGender = (gender) => {
return ''; // Возвращаем пустую строку, если пол не указан, чтобы не было "Пол не указан"
};
const onImageError = (event, userOnError, photoWithError) => { // MODIFIED: signature and content
const onImageError = (event, userOnError, photoInfo, sourceType) => {
console.warn(
"SwipeView: Не удалось загрузить изображение.",
`SwipeView: Не удалось загрузить изображение (Источник: ${sourceType}).`,
{
src: event.target.src,
user: userOnError.name,
photo_id: photoWithError._id,
photo_url: photoWithError.url,
isProfilePhoto: photoWithError.isProfilePhoto,
userId: userOnError._id,
photo_id: photoInfo._id,
photo_url: photoInfo.url,
isProfilePhotoFlag: photoInfo.isProfilePhoto,
// Log the state of relevant properties of userOnError at the time of error
currentUser_mainPhotoUrl_at_error_time: userOnError.mainPhotoUrl,
currentUser_photos_at_error_time: userOnError.photos ? JSON.parse(JSON.stringify(userOnError.photos)) : 'not present',
event_target_attributes: {
naturalWidth: event.target.naturalWidth,
naturalHeight: event.target.naturalHeight,
complete: event.target.complete,
},
errorEventDetails: event
errorEventDetails_type: event.type
}
);
// For debugging, let's NOT hide the image for now.
// This will show the browser's default broken image icon.
// event.target.style.display = 'none';
// The logic to update userInSuggestions.mainPhotoUrl is outdated.
// const userInSuggestions = suggestions.value.find(u => u._id === userOnError._id);
// if (userInSuggestions && userInSuggestions.photos) {
// if (!userInSuggestions.photos.some(p => p.url)) {
// // userInSuggestions.mainPhotoUrl = null; // Outdated line
// }
// }
// event.target.style.display = 'none'; // Keep commented for debugging to see broken image icon
};
</script>