Skip to content

Fix for bad gallery #179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

nerdyVanilla
Copy link

Came across a post that was supposed to be a gallery, but must have been removed as there was not data for the gallery. This cause an exception and the slideshow would not continue. Added a return false in an else statement and that seems to fix the issue.

Came across a post that was supposed to be a gallery, but must have been removed as there was not data for the gallery. This cause an exception and the slideshow would not continue. Added a return false in an else statement and that seems to fix the issue.
"TypeError: item.data.media_metadata[image.media_id].m is undefined"

Saw a gallery where one of the objects in the media_metadata had a status == "failed" and not other attributes. This caused an exception. Added check to skip processing the gallery image if bad.
Originally was checking to see if an attribute was missing. Changed to look for a failed status and forgot to remove the "!".
The post is a gallery, but has been removed by the moderators. The item.data will have is_gallery true but gallery_data is null. These posts should be skipped,
@ubershmekel
Copy link
Owner

ubershmekel commented Feb 7, 2025

Do you have an example URL with a bad gallery so I can compare before and after?

Also - thank you for this!

@nerdyVanilla
Copy link
Author

https://redditp.com/user/Sea_Rooster_3398/submitted/?sort=new

when you get to around to the 148 image the next api call cause a TypeError: item.data.gallery_data is null error. At this point no more API calls are made to get more posts.

This seems to be the bad post:
https://www.reddit.com/r/FeetInYourFace/comments/1ihzt4d/which_of_these_do_you_think_is_the_hottest/

@ubershmekel
Copy link
Owner

I got all the way up to 222 with no error. Then got this:

Redditp booboo: Uncaught TypeError: Cannot read properties of null (reading 'items')

Looking at this PR via https://deploy-preview-179--redditp.netlify.app/user/Sea_Rooster_3398/submitted/?sort=new

I made it to 295 and beyond. But at the 222 mark I think this error popped up in red:

invald data item, please alert ubershmekel on github

So I guess there is another error that happens, but redditp does survive and chug along with it.

@nerdyVanilla
Copy link
Author

Yes, the production version will have a TypeError: item.data.gallery_data is null error on that slideshow and the slideshow stops. I change the condition before addImageSlide to catch the bad gallery as well and it will note the error with invalid data item. Do you want the check to moved into it's own if condition with a a different error message?

I've included the JSON of the bad post that I been using as my test case.
badGallery.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants