Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialStone Preston
42,016 Pointshow to update badge value in ribbit based on read/unread messages
how could we update the badge value of the inbox tab in ribbit based on read/unread messages? Im struggling with coming up with a way to do this. How would you determine what number to set the badge to? any ideas Ben Jakuben?
Stone Preston
42,016 Pointsyes thats true. But im trying to make mine a bit more like snapchat, where you can view them for 10 seconds. so they only get destroyed after the user has looked at them for 10 seconds. He can open it for 3 seconds, then a few days later open it for 7 etc, not just 10 seconds after the first open and then they are gone.
eirikvaa
18,015 PointsTotal amount of unread messages would be the amount of messages in your inbox regardsless of how long the user has looked at the messages (as long as it is below the allowed time). The challenge would be to store how long time has passed on the individual messages so you know when to destroy them. I'm not exactly sure how one would implement this in the context of the Ribbit app (that's why I'm not replying with an answer, only a comment). Maybe you can store this information on the Parse server?
Stone Preston
42,016 Points"Total amount of unread messages would be the amount of messages in your inbox regardsless of how long the user has looked at the messages (as long as it is below the allowed time)." thats not how id like to implement it. If a user opens a message. mark it as read (or "opened" etc) , if not, mark it as unread.
eirikvaa
18,015 PointsAh, now I get what you're saying. Sorry, my bad. It's late at night here in Norway. Then I'm not really sure. We should wait for the veterans. I would be interested in seeing how one could implement it.
Stone Preston
42,016 Pointsno worries.
Rashii Henry
16,433 PointsI'm trying to fully understand your question.
are you trying to keep track of the unread and the read messages simultaneously?
&& what are you using right now to display/track the badge value ?(if you are displaying it)
1 Answer
Patrick Cooney
12,216 PointsOne potential solution would be to add a "viewed" boolean in Parse. Pull that down (that being the key for viewed), do some math and set the badge value equal to the total minus read.
Stone Preston
42,016 PointsAh good idea. Although with the message class using the recipient ids as an array it would need to be a readByID array containing the recipients that have read it. But the principle remains the same, thanks!
Dee Greene
8,508 PointsStone Preston did you ever get this resolved? trying to implement it myself. i created a "readBy" column in Parse.com and add the user id to that array once they click on the message. the badge number updates correctly however when i try to do both queries at the same time i get:
"Warning: A long-running operation is being executed on the main thread. Break on warnBlockingOperationOnMainThread() to debug."
eirikvaa
18,015 Pointseirikvaa
18,015 PointsSince read messages are destroyed, aren't the total amount of unread messages just the number of messages in your inbox?