Repository
Pull Request
Task Request
I've continued picking up task request from SteemLogs.info, and this one was for the load more and load all buttons, although I fixed a bit more that we had talked about.
Load More and Load All Buttons
The main part of the request was getting the load more button set up, and adding the load all button. The logic behind is this pretty easy; you just call the get_user_posts function I updated in the last task request, either a single time per button click for load more, or until you've got them all if they hit load all. Here's the load all view logic:
I set it up similarly to how the load more view logic was already implemented, but with a loop. The loop gets either 1000 (the max amount you can get at once) or next_entry_id posts at once, whichever is smaller. This should make it the fastest possible time to load all posts in most cases. It maybe could get a bit faster, but that would require loading less information about each post, which may not be preferable.
I also added a 'load_all_posts.js' file and load_all_posts function in the static js files, which do a similar job as the load_posts.js file and load_posts function, which is what the load more button calls. I added some comments to each file for clarity of what they were doing for future people (since I had to think some to figure out the old code). This also included added a url for load all into the urls.py file.
Other changes
I updated beem to 0.20.20 because it was pretty far behind for some reason, looks like only one or two more task requests until steem-py is no longer required. I also fixed a bug in dev mode that caused the load button to not work in dev mode, not sure if there were other issues with it but that one made it impossible to test anyways. To load static files in dev mode, you have to add some code to the app's urls file, so that there's something that points to the static file. This is done pretty easily, by adding an import and a line in app/urls.py
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
# add the static file patterns to url patterns
urlpatterns += staticfiles_urlpatterns()
I also had to change STATIC_ROOT to '/static/' in settings.py, but not sure what that was connected to. It's the same as STATIC_URL now, so maybe you only need one, but I couldn't find a lot of info on it.
I added comments for all the code I changed, and also removed some that don't relate to the code anymore.
Vote For Me as Your Witness
Cheers, thanks for reading! If you like my tools and content and would like to see more, Vote for me as witness or proxy your votes and I'll pick the best witnesses for you!
My Projects
Pjtaggartv2- My website, built in React Typescript with Redux and dSteem, with more info about me as well as some Steem utilities you can use!
Pywit- A witness tool-kit built in Python on top of Holger80's Beempy.