twindle-co / twindle

Twindle - an open source project for beginners. Converting twitter threads to pdf, epub, and mobi format to be read by Kindle.
https://www.twindle.co
MIT License
134 stars 133 forks source link

Clean up responseJSON #713

Closed PuruVJ closed 3 years ago

PuruVJ commented 3 years ago

We should introduce a function to clean up unneeded data (like contexts, annotations) responseJSON that's returned from the fetch requests.

Why

676 is all about introducing JSDoc typings. It is to provide typescript like intellisense experience while editing. You press Ctrl + Space, you get all the properties, their types, descriptions, whether they are optional or not. This alone will reduce lot of bugs during coding.

And as all these types will be defined in another file, which will just be full of comments , so nothing will break, no cognitive load for anyone else(due to the fact that these would be in a separate file).

responseJSON returned by the Twitter API contains way too much stuff. We are using only a fraction of those, so we need to get rid of others.

responseJSON = cleanupResponse(responseJSON) would work perfectly, and should happen in the fetch util itself.

How

While @johnjacobkenny and @Mira-Alf are doing the refactoring, I will make myself useful by introducing the cleanup function and JSDoc typings.

johnjacobkenny commented 3 years ago

You can add it to the branch @PuruVJ, I think the refactor is essentially done, except for checking your changes.

PuruVJ commented 3 years ago

My changes are barely anything. They don't change a bit.

And yes, I'm gonna do it in the branch only.

PuruVJ commented 3 years ago

No need for cleanup. I've set up typings for the fields that we'd need.

johnjacobkenny commented 3 years ago

Great