Updates on Roar! Like feature complete

in roar •  13 days ago

    Hi everyone

    So I implemented the like feature,, and there wont' be any dislike/downvote/flag feature
    .. that's and evil feature :p according to me

    Here were the steps

    1. implement like method in the back end (GraphQL)
    2. integrate on front end.

    Where a user likes a post, it does a few things

    1. calls the method to post the like
    2. get the updated post, since after the like was submitted, rewards, etc things changed. so need to get the updated post

    fetching the post, and updating it at first I thought would be tricky,
    since you need to cast the like, get the post, find the post in existing array, and they update the existing array, then rerender the page.. which was bad way to do it.

    ... with my clever mind guys :p
    I only cast the like, and fetch and display the updated post,
    don't update the array, so technically the array still holds the old data.. but the data which user sees, is updated,

    for people who don't liek the technical details here are the photos
    Screenshot from 2020-06-28 21-40-02.png

    Screenshot from 2020-06-28 21-40-14.png

    Screenshot from 2020-06-28 21-40-24.png

    Screenshot from 2020-06-28 21-40-39.png

    and it seemlessly updates


      Authors get paid when people like you upvote their post.
      If you enjoyed what you read here, create your account today and start earning FREE BEARS!