ULOG #25: Adding @giftgiver Delegation Support

in #ulog5 years ago

image.png

This closes issue #259 in github. It integrates @giftgiver's delegation support to users with low RC as described in its introductory post.

@giftgiver, a project by @rishi556 to help with part of the on-boarding process for new STEEM users.

This also contains some feature requests made by Terry for Ulog Stories.

1. Repository

https://github.com/surpassinggoogle/UlogsV2

2. Task Request/Issue

https://github.com/surpassinggoogle/UlogsV2/issues/295

3. Pull Requests

https://github.com/surpassinggoogle/UlogsV2/pull/256
https://github.com/surpassinggoogle/UlogsV2/pull/257
https://github.com/surpassinggoogle/UlogsV2/pull/273

4. Testing

These were the tests manually done in Chrome:

  1. Filter Tags + Ulog Stories posted in the last three days
    • Visit the home page (https://ulogs.org/ or http://localhost:3000)
      • Ulog stories displayed should contain any of the defined ulog sub-tags or ulog or ulogs
      • Ulog stories displayed should be posted in that last three days; posts older than that should not be displayed
  2. @giftgiver Delegation Support
    1. Visit a post
    2. Submit a comment (user's Resource Credits (RC) should be low enough to trigger an insufficient RC error)
      • Low RC notification should display
      • If successful, @giftgiver delegation support notification should display
      • If failed, only low RC notification should display; reason for failed @giftgiver delegation should display to console

5. Implementation

5.1. Only Display Ulog Stories with Ulog Tags

  1. src/client/components/Sidebar/UlogStories.js - import the supported ulog tags from helper constants, then for each post from a certified ulogger, filter out posts that do not contain any of the valid ulog tags;
    image.png
  2. src/client/components/UlogStoryEditor/UlogStoryEditorFooter.js - code refactor to use constants helper
    image.png
  3. src/client/helpers/constants.js - extracted supported ulog subtags and declared them as a constant string array
    image.png

5.2. Only Display Ulog Stories Posted in the Last Three Days

A simple feature request from Terry to only display ulog stories posted in the last three days.

  1. src/client/components/Sidebar/UlogStories.js - add date filter
    image.png

5.3. Add @giftgiver Auto-Delegation Support

  1. src/client/components/Comments/Comments.js - added the giftGiver() function that submits the POST request for delegation; the delegation request will only be triggered when the user's comment submission fails due to insufficient RC;
    image.png
  2. src/server/app.js - for server-side rendering; as advised by @rishi556, to prevent the CORS (Cross-Origin Resource Sharing) related errors, I had to add a new express server POST API support to submit the delegation request
    image.png

6. Feature in Action

For this to work, please add the GIFT_GIVER_KEY environment variable.

STEEMCONNECT_CLIENT_ID=STEEM_CONNECT_ACCOUNT_HERE
STEEMCONNECT_REDIRECT_URL=http://localhost:3000/callback
STEEMJS_URL=https://api.steemit.com
SIGNUP_URL=https://signup.steemit.com/?ref=ulogs
WITNESS_VOTE=https://steemconnect.com/sign/account-witness-vote?witness=steemgigs&approve=true
GIFT_GIVER_KEY=GIFT_GIVER_KEY_HERE

The key used in the video below is still a test key so no actual delegation was done. I'm still waiting for the live key from @rishi556.

gift-giver.gif

7. Lesson Learned

There were two issues I took time to resolve: the first was figuring out how to make cross-site requests, and the second was how to read isomorphic-fetch responses.

The second, I was able to resolve by myself, but for the first, I needed the help of @rishi556.

image.png

I raised this issue with him over discord and he simply informed me that "the request should be done server side." The lesson I learned here was:

TO GET THE RIGHT ANSWER, YOU NEED TO ASK THE RIGHT QUESTION TO THE RIGHT PERSON.

8. GitHub Account

https://github.com/eastmaels

This post was made from https://ulogs.org

Sort:  
  • Great article with code samples, explanation coding of choices and an image.
  • Good commit messages and code comments.
  • I love the wisdom bits. ;-)

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Chat with us on Discord.

[utopian-moderator]

Thank you for the feedback. I love writing the wisdom bits. I feel they're more important than the code contributions.

Posted using Partiko Android

Thank you for your review, @helo! Keep up the good work!

Hi @eastmael!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server

Hey, @eastmael!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Coin Marketplace

STEEM 0.18
TRX 0.14
JST 0.029
BTC 57956.22
ETH 3126.99
USDT 1.00
SBD 2.45