Hello Programmers,
I hope you all are well. I am very well sure that many new developers are working on Steem and they want to build some useful tools for Steem Blockchain. Our team is working on SteemPro Mobile App for the last 6 months, During this time frame we also launch SteemPro

To educate the new developers and also to the whole steemit users, We arrange this bi-weekly post in which we explore the code of official Steemit. You can get the GitHub repository here.
We will also modify the code to convert it into TypeScript and make the necessary changes to work with the SDS APIs provided by @steemchiller.
File Path
steemit/condenser/src/app/utils/Community.js
Class
Role
Old Code
export class Role {
static LEVELS = ['muted', 'guest', 'member', 'mod', 'admin', 'owner'];
static level = role => {
if (!role) throw 'empty role provided';
const level = Role.LEVELS.indexOf(role);
if (level == -1) throw 'invalid role: ' + role;
return level;
};
static atLeast = (role, target) => {
return Role.level(role) >= Role.level(target);
};
}
Working
This class helps us know if authority is valid for a specific role. We need to provide the role value in a string and the target role for comparing and we get a return value in a boolean if the role is matching with the target role or above. Or it can be a lower role and we get the false value.
Code in Typescript
export class Role {
static LEVELS = ['muted', 'guest', 'member', 'mod', 'admin', 'owner'];
static level = (role: string): number => {
role = role || 'guest';
const level = Role.LEVELS.indexOf(role);
if (level === -1) {
throw new Error('Invalid role: ' + role);
}
return level;
};
static atLeast = (
role: string,
target: 'muted' |'guest' | 'member' | 'mod' | 'admin' | 'owner',
): boolean => {
const roleLevel = Role.level(role || 'guest');
const targetLevel = Role.level(target);
return roleLevel >= targetLevel;
};
}
What's new
This code is optimized to use for the SDS feed_api or post_api. We can get an empty string value of author_role for a community which is why we need to use the 'guest' value for this empty string.
SteemPro Official
Cc: @blacks
Cc: @rme
Cc: @hungry-griffin
Cc: @steemchiller
Cc: @steemcurator01
Best Regards @faisalamin
I think you mean the field author_role.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Absolutely,
author_role thanks for the correction.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
This post has been featured in the latest edition of Steem News...
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thank you, friend!


I'm @steem.history, who is steem witness.
Thank you for witnessvoting for me.
please click it!
(Go to https://steemit.com/~witnesses and type fbslo at the bottom of the page)
The weight is reduced because of the lack of Voting Power. If you vote for me as a witness, you can get my little vote.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit