Coder Social home page Coder Social logo

Comments (12)

pigi96 avatar pigi96 commented on June 20, 2024 1

@Bricktheworld, may I ask have you tried using the limit paramater?

Just wondering, because it used to take 3-5 seconds for mine too, before I noticed that default wasn't 100 but was 1000 (if I remember corretly, it actually called http a random amount of times, never looked into it though).

Setting limit to below 100 fetches data almost insantly otherwise I wouldn't know what would be actually wrong.

(edit) Actually read your above post and it seems you have set limits but still getting the delays? I'm actually trying a few stuff and everything seems to be working fine on my end.

(edit2) I looked at your code above... Considering that you said it's faster running with "flutter run --release" I'm guessing the setState() you are calling a bunch of times(for each new element added) may actually be slowing down the app.

Your repository is probably private, so I can't really help more.

from draw.

Bricktheworld avatar Bricktheworld commented on June 20, 2024 1

@bkonyi All good, stay safe :)

And I am currently in the process of adding documentation and fixing the comment length bug in a pull request!

from draw.

Bricktheworld avatar Bricktheworld commented on June 20, 2024

Nvm, apparently calling the currentUser = await redditTemp.user.me(); before fetching posts is not a good idea if it is not necessary because it caused a lot of lag time from requesting the updated reddit client and actually fetching the posts

Don't do this if not necessary

Althought if there was still one more thing I'd like to be improved in the project, is that the documentation for things such as fetching posts and all of the non OAuth stuff is quite lacking. If this could be improved that would be great!

Thank you!

from draw.

Bricktheworld avatar Bricktheworld commented on June 20, 2024

Nvm Nvm, that was not the issue. The issue still remains that getting "best()" takes a long time, like 10 seconds slow. I'm not sure what the issue is...

from draw.

michaelcerne avatar michaelcerne commented on June 20, 2024

Any updates?

from draw.

Bricktheworld avatar Bricktheworld commented on June 20, 2024

Hmmm, it seems like calling a simple .Hot() on all of the subreddits before actually listening in on the stream seems to help, but that does not fix the issue. It is still like a 3-5 second load time. Another thing i've noticed is that sometimes the load times are like 1 second and sometimes they are 10, it is very erratic and I can't seem to pinpoint the issue.

Also just in case it gets asked, I have a very descriptive user agent and changing it to something like "java" or "bot" did not increase or decrease the speeds surprisingly.

Is it possible this is just an issue with how my app is setup in reddit prefs? I'm not quite sure what else I can troubleshoot. If need be for replication, my codebase is on a github repository of mine called "apollo" if you need to take a look. Though I doubt it will help as almost all of the code is just taken from examples on here...

@bkonyi any idea what this is? or is this just on my end?

from draw.

Bricktheworld avatar Bricktheworld commented on June 20, 2024

Alright, new update @michaelcerne

The way to greatly improve this is through adding the "" in the android manifest.xml. This improves this and actually makes it possible to run the app in a compiled and installed mode lmao. I am going to keep this issue open because the delay is still like 1-2 seconds longer consistently compared to other android Reddit clients on android and I am looking to improve this speed. This might simply have to do with how fast https is with android in flutter but I'm not sure.

Thanks

from draw.

Bricktheworld avatar Bricktheworld commented on June 20, 2024

@pigi96

hmm, so I have tried that before, however it seems like this time it worked! Thank you so much!

However now I have another question, how do I continue to get more posts, if I can only get like 90 at a time? Do I literally just have to put the "hot()" method in a loop to continually get more posts? Because if so, that seems like a super messy solution, but it could work!

Also I do have the set state so it only happens in multiples of 100, that way it does not slow down the app.

Thank you so much for your help again, hugely improved performance!

Also woops, will fix the private repo right now, just have to push some changes!

Edit: Okay repo has been fixed: https://github.com/Bricktheworld/Apollo-for-android
Edit 2: Okay so the important code is in "subreddit_post_view.dart" on line 37, that is where I fetch a bunch of posts for a particular subreddit

from draw.

pigi96 avatar pigi96 commented on June 20, 2024

Yeah that should work as expected.

As for your other question... I do it in a way, that I only load more elements if user scrolled to/near the bottom of a page, so there is no unnecessary loads...
stream = _reddit.subreddit(subredditTitle).top( limit: 25, after: after); List<Submission> submissions = List<Submission>(); await for (final value in stream) { submissions.add(value); }

So as you are currently doing, I catch 25 of them and show them. Then if the user scrolls to the bottom of the list I just call the method again. Also the after parameter is just...
submissions.last.fullname (last element's fullname)

from draw.

Bricktheworld avatar Bricktheworld commented on June 20, 2024

Gotcha, yeah the documentation for the after really confused me, so that helped me a lot!

Thank you, I'm now going to close this issue

For the devs of draw to see: You might want to further explain how the limit works and why it loads faster and also some more docmentation on this topic would help.

Thanks everyone!

from draw.

bkonyi avatar bkonyi commented on June 20, 2024

Sorry for the delay everyone. I've been pretty swamped with work and other efforts and haven't had a chance to respond here. @Bricktheworld I'll keep your feedback in mind and add more info when I can (I would be happy to accept a pull request for documentation explaining the limit parameter though :-)).

For future reference, if you ever run into issues with DRAW it might be worth checking out the documentation for PRAW as well, as this package's API is heavily inspired by PRAW and PRAW's documentation might be more descriptive in some cases (I've done my best to keep DRAW's up to par though!).

from draw.

bkonyi avatar bkonyi commented on June 20, 2024

Thanks, you too! :) Excellent, looking forward to it @Bricktheworld!

from draw.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.