soscripted / sox

Stack Overflow Extras: a userscript for the Stack Exchange websites to add a bunch of optional toggle-able features
http://stackapps.com/q/6091/
MIT License
72 stars 15 forks source link

optimization: use filters throughout #345

Closed GaurangTandon closed 6 years ago

GaurangTandon commented 6 years ago

I also noticed there are a lot of occurrences sox.helpers.getFromAPI method (but not all occurrences are like that, which I found a bit inconsistent). Can I get a link to the documentation for it? I might be interested in optimizing it to use filters as well.

shu8 commented 6 years ago

@GaurangTandon the only real documentation we ever wrote for that was:

sox.helpers.getFromAPI(type, id, sitename, callback, sortby, asyncYesNo): sends a AJAX GET request to the API with the type type with id(s) id on site sitename, passing the data back to callback. sortby and asyncYesNo are optional and can be left out.

on https://github.com/soscripted/sox/wiki/Contributing. Admittedly, it's not a great helper function because it doesn't let you use stuff like filters like you mention, and the callback ideally would be last instead of in the middle! If you get time we'd appreciate optimising it! :)

GaurangTandon commented 6 years ago

@shu8 I'm done with the code rewrite, which turned out to be way larger than expected (I ended up refactoring not just for filters in the API calls, but everything around those API calls also - because it was necessary to completely understand the code in those methods).

I will perform the testing tomorrow, and make a new PR most probably within the next two days.