Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

Posting to Steem #13

Merged
merged 8 commits into from
Apr 11, 2019
Merged

Posting to Steem #13

merged 8 commits into from
Apr 11, 2019

Conversation

KrNel
Copy link
Owner

@KrNel KrNel commented Apr 11, 2019

What's new

  • Added Posting of main Steem content

When logged into KURE, you will see the pencil icon. When you click on it, it brings you to the write page. Here you can compose your post. Just put in a title and a post body, as well as 1 to 5 tags, and you're set.

When you post a loading spinner will show up indicating the post is being processed and sent to the Steem blockchain. After about 3 seconds, the post will be successful and you will see your new post in front of you. When you go to your blog page, you can see your new post listed there as a post summary as well.

Once the data is passed to Redux, the data is processed more, such as creating the permlink to be used for the URL to access the post. Some options are added to the post, which include the author, permlink, and whether to allow votes and curation, and the payout type.

The last thing to do before sending the post away to Steem via SteemConnect, is to check if the user has posted 5 minutes earlier (from the same computer). I haven't thought about how to check if someone has posted another way. Maybe I should get their last post and the created time from there, that would be a better idea. For now, an error message about the 5 minute limit is sent if they use the same computer. If not, then the post simply won't go through anyways.


  • Added rewards option

being limited to one payout option would be a bummer. After I got posting to work I added all options. The default payout option for now is 50/50 SBD/STEEM split. But you can also choose 100% STEEM and Decline Payout, as I did here.

An array of values is iterated through and rendered as a option box for users to select from.

On the Redux side, if the default of 50/50 isn't the selection, a change is made to the reward value to be sent to Steem.


  • Added tag validation

When you write your post and pick tags, there is also some validation going on for the tags. When you submit your post and made an invalid tag choice, you will be told about it and need to change it before your post can be posted.

Tags are validated via regex according to certain matches. This includes tags being required, Maximum 5 tags., Tags must be shorter than 24 chars., Only one dash per tag, Only one dash per tag, Must be lowercase, Invalid characters, Must start with letter, and Must end with letter or number`.


Bug Fixes


  • Fixed initial logins not setting SteemConnect token

When logging into the app, and not a return authentication, the user token was not being reset in to the SteemConnect api. This shortcoming resulted in an inability to send Posts to the Steem blockhain via SteemConnect.

Instead, there was an error: The token has invalid role

With @fabien's help, he showed me that the authentication headers were not being set and therefore no token was being sent to SteemConnect to send the post to Steem.

Once I setAccessToken and verified the token with .me(), I was able to post to Steem, finally.


  • Fixed non-existent post request crashing page

When I made my first post on KURE, and added the rerouting to the post to show it after it was posted, I got a page crash. This was unexpected. At first I got this error when the posting wasn't working, but the permlink was created and forwarded to a page that doesn't exist.

Non existent posts being fetched were not being handled, only non-existent routes. I had to add some more checks before sending a post to the PostDetails component. If the post is not being fetched, and it has no length, then the post doesn't exist.


  • Fixed bug with revoked auth tokens not forcing logout

Related to the above issue with authentication, is another problem that I noticed when a token was no longer valid. Anyone who wass previously logged in and had a cookie set, had their token stored there. But, if the token expired or was revoked (as I did when I tested this), then the user would still be "logged in" to the app and see the Manage and Write menu pages to write a Steem post.

Yet, if they tried to write a Steem post, it would fail, because their token wasn't valid anymore. I needed to change the way the returning users were being authenticated. TO do so, I had to remove a default resolve() in the Promise for validateToken. This way when the me(0 function failed, that error would cascade up to Promise chain and be caught in a catch which dispatched an error to cancel the returning action and reducer.


  • Fixed unauthorized pages stuck on loader

Unauthorized access to the Manage page would show a message saying that the user needed to login. But after I made some changes, it stopped working and would show the loading spinner forever.

With the recent changes in the authentication of the SteemConnect token, the Redux action wasn't being canceled, so the loading spinner stayed in a state of true indefinitely. Dispatching an action on error to change the state to false fixed the issue.


  • Fixed posting time limit error, label alignment and early fetch

Sending an error message when a post is submitted less than 5 minutes after a post was sent, still had the post trying to be sent to Steem. I added a conditional return.

The error label for time limit was showing up under the Submit button, instead of beside it. By putting the button and label in a Semantic-React UI Form.Group made them related and the alignment of the label worked.

Trying to fetch data right after a post, was sometimes done too quickly and returned no results. By adding a 1 second delay after a post was sent, it ensured the lookup wasn't done too quickly, and when the lookup was done that the post would exist for it to find.


  • Fixed comments header showing on posts with no comments

Lastly, an empty post would still show the Comments header and the sorting option box. This was pointless and added to a negative UI/UX design. Wrapping the comments section in a conditional to test for comments.length prevented it from showing when there were no comments. Note the double negation !!. If you don't put that, then a 0 is outputted to the page when there are no comments.

The crucial ability to post main content to the Steem blockchain is now working. Pock a title, write something, and put in some tags, and you're ready to post and view it on the blockchain.
Posting main content to Steem can be done with 3 payout options: 50/50 SBD?STEEM split, 100% STEEM, or no payout at all.
Tags are validated for lenth, number, and characters they are composed of. An error label is shown with info to correct the violations before submitting a post is allowed.
When a token expired or was revoked, the user would still stay logged in due to the cookie still being there. I fixed the check on returning users by checking the token with SteemConnect and making sure the token is valid before authenticating. When a token isn't valid, the user won't be logged in anymore.
With the recent changes int eh authentication of the SteemConnect token, the redux action wasn't being cancelled, so the loading spinner stayed in a state of true indefinitely. Dispatching an action on error to chagne the state to false fixed the issue.
Sending error message when a post is submitted less than 5 minutes after a post was sent still had the post trying to sent to Steem. Added conditional return.

Error label for time limit was under the Submit button, not beside. Fixed that.

Trying to fetch data right after a post was sometimes done too quickly and returned no results. Added 1s delay.
@KrNel KrNel merged commit 60f57d4 into master Apr 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant