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

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" <img :src="photo.url"
class="d-block w-100 user-photo" class="d-block w-100 user-photo"
:alt="'Фото ' + currentUserToSwipe.name + ' ' + (index + 1)" :alt="'Фото ' + currentUserToSwipe.name + ' ' + (index + 1)"
@error="onImageError($event, currentUserToSwipe, photo)"> @error="onImageError($event, currentUserToSwipe, photo, 'carousel')">
</div> </div>
</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"> <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" <img :src="currentUserToSwipe.mainPhotoUrl"
class="d-block w-100 user-photo single-main-photo-img" class="d-block w-100 user-photo single-main-photo-img"
:alt="'Фото ' + currentUserToSwipe.name" :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> </div>
<!-- Option 3: Placeholder if no photos and no mainPhotoUrl --> <!-- Option 3: Placeholder if no photos and no mainPhotoUrl -->
<div v-else class="no-photo-placeholder d-flex align-items-center justify-content-center"> <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(() => { const currentUserToSwipe = computed(() => {
if (suggestions.value.length > 0 && currentIndex.value < suggestions.value.length) { 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; return null;
}); });
@ -230,34 +237,28 @@ const formatGender = (gender) => {
return ''; // Возвращаем пустую строку, если пол не указан, чтобы не было "Пол не указан" return ''; // Возвращаем пустую строку, если пол не указан, чтобы не было "Пол не указан"
}; };
const onImageError = (event, userOnError, photoWithError) => { // MODIFIED: signature and content const onImageError = (event, userOnError, photoInfo, sourceType) => {
console.warn( console.warn(
"SwipeView: Не удалось загрузить изображение.", `SwipeView: Не удалось загрузить изображение (Источник: ${sourceType}).`,
{ {
src: event.target.src, src: event.target.src,
user: userOnError.name, user: userOnError.name,
photo_id: photoWithError._id, userId: userOnError._id,
photo_url: photoWithError.url, photo_id: photoInfo._id,
isProfilePhoto: photoWithError.isProfilePhoto, 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: { event_target_attributes: {
naturalWidth: event.target.naturalWidth, naturalWidth: event.target.naturalWidth,
naturalHeight: event.target.naturalHeight, naturalHeight: event.target.naturalHeight,
complete: event.target.complete, complete: event.target.complete,
}, },
errorEventDetails: event errorEventDetails_type: event.type
} }
); );
// For debugging, let's NOT hide the image for now. // event.target.style.display = 'none'; // Keep commented for debugging to see broken image icon
// 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
// }
// }
}; };
</script> </script>