ULOG #8: Adding Certified Ulogger Icon to Ulogs.Org
ulog·@eastmael·
0.000 HBDULOG #8: Adding Certified Ulogger Icon to Ulogs.Org

#### Repository
https://github.com/surpassinggoogle/UlogsV2
#### Task Request
https://steemit.com/utopian-io/@surpassinggoogle/task-request-kindly-add-a-rule-to-the-existing-algorithm-for-suggest-interesting-uloggers-on-ulogs-org
#### Pull Requests
https://github.com/surpassinggoogle/UlogsV2/pull/111
#### Feature: Adding the Verified Ulogger Icon
##### 1) Defining Terms - @Ulogger's Following vs @Ulogger's Followers
To shorten the sentences in the succeeding sections, let's define terms that are consistent with the codes:
1. **@ulogger's following** - the accounts that @uloggers follow; the account that you find in the link - https://ulogs.org/@uloggers/followed
2. **@ulogger's followers** - the accounts that follow @uloggers
##### 2) Planning the Solution
The logic behind this feature was simple - get a list of accounts @uloggers follow (a.k.a. @ulogger's following) then append an icon after the reputation badge for each `Story` in the feed.
*Simple, isn't it?* Yes, it's simple for those who have developed for busy and are well-versed with react-redux. I have the former but not the latter, and having 1 out of 2 is better than none.
I already had a solution in mind... it's just a matter of finding out if it will work.
##### 3) Partial Solutions - Getting from Point A to Point B
The reason I submitted multiple PRs for this task request was to submit working codes - micro-solutions to what Terry calls micro-tasks.
As I've taught one of my former teams, sometimes we have to get ourselves from point A to point B in order to find a solution to a second problem. That lesson applied to this.
My first problem was how to get @uloggers's following (which was solved in the feature ["Dynamic Interesting Uloggers"](https://ulogs.org/ulog/@eastmael/ulog-7-adding-dynamic-interesting-uloggers-to-ulogs-org)) and the second was knowing where to put the logic, store the list, and use it to mark verified uloggers.
##### 4) The Search - Looking for Similar Logic
I knew that getting @uloggers's following was the same as getting any account's following. So I just had to find where that logic's defined and where it's used. So I studied the codes and saw `getFollowing` in `Wrapper.js` and that's where I started.
##### 5) The Design Decision
After finding my target function and understanding its call stack, I had to decide whether to just re-use it or clone and customize. I decided the latter.
The reason for this was that I will be needing the verified uloggers (@uloggers's following) list in the same place where the `getFollowing` list is used. And in order to avoid foreseen side-effects of using the same action type (`GET_FOLLOWING`) at same time and location, I opted for the clone and customize.
##### 6) The Implementation
As mentioned previously, the first part of the solution was to get and store @uloggers's following. I was able to accomplish this by creating the `getUloggersFollowingList` user action in `src/client/user/userActions.js` and calling this action when the `Wrapper` component is mounted. This action dispatches the `GET_ULOGGERS_FOLLOWING` action type then updates the state via `src/client/user/userReducer.js`.
###### `src/client/user/userActions.js` :: `getUloggersFollowing`
```
export const getUloggersFollowing = () => (dispatch, getState) => {
const state = getState();
if (!getIsAuthenticated(state)) {
return dispatch({ type: GET_ULOGGERS_FOLLOWING_ERROR });
}
return dispatch({
type: GET_ULOGGERS_FOLLOWING,
meta: 'uloggers',
payload: {
promise: getAllFollowing('uloggers').catch(() => dispatch({ type: GET_ULOGGERS_FOLLOWING_ERROR })),
},
});
};
```
###### `src/client/user/userReducer.js`
```
case actions.GET_ULOGGERS_FOLLOWING_START:
return {
...state,
uloggersFollowing: {
...state.uloggersFollowing,
list: [],
isFetching: true,
fetched: false,
},
fetchUloggersFollowListError: false,
};
case actions.GET_ULOGGERS_FOLLOWING_ERROR:
return {
...state,
uloggersFollowing: {
...state.uloggersFollowing,
list: [],
isFetching: false,
fetched: true,
},
fetchUloggersFollowListError: true,
};
case actions.GET_ULOGGERS_FOLLOWING_SUCCESS:
return {
...state,
uloggersFollowing: {
...state.uloggersFollowing,
list: action.payload,
isFetching: false,
fetched: true,
},
fetchUloggersFollowListError: false,
};
```
The verified uloggers list can now be acquired from the app's `state` via `getUloggersFollowingList` reducer in `src/client/reducers.js` and `src/client/user/userReducer.js`.
Once that big chunk of the code was done, what's left was to check from the list if a story's author is a verified ulogger or not and then displaying the certified ulogger icon.
I accomplished this via the `isCertifiedUlogger()` function in `src/client/feed/StoryContainer.js` which returns a boolean. This function is then used in `src/client/components/Story/Story.js` in which if it returns `true` (user is included in @uloggers's following), then it will display the `<CertifiedUlogger />` icon - which is the last part of this solution - creating a new `CertifiedUlogger` component which includes the style for the verified ulogger icon (`src/client/components/Story/Story.less`).
And here's the feature in action...
#### Feature in Action

#### Lessons Learned Recap
**Plan before you act.** In this feature, the task seemed simple because *just* adds an icon. But behind it were functions I needed to see done first in my mind's eye before I started. Yes, not all were clear at the start, but this was where the second lesson came in...
**Move from point A to point B to find a solution to a second problem.** In this case, I needed to get myself from knowing how to get @uloggers's following to knowing how to store and access the list to add the verified icon. Solve problem #1 first and eventually, solution for problem #2 becomes clear.
#### GitHub Account
https://github.com/eastmaels<br/><div class="pull-right promo"><sub><p>This post was made from https://ulogs.org</p></sub></div>👍 eastmael, dylanhobalart, j-alhomestudio, zcool, beautifuldata, valiantheart, belkar, polsikio, rommist79, miki64839, alludelinear, juniortwee, artyrdavletov, pashafeloff, semenovyx83, bolendik, nyushosazha, steemitdoctor, steemph.manila, danielnewsomm, maluninivan, lisicka, pavlovilya23, romansilenkov, ermakx, boriskamiran, studiedcovalent, dzhozefrays, annazsarinacruz, rye05, crokkon, cryptos, zeddjacob, steemitbc, topbro, rt395, kilathecla, steemitph, east.autovote, revisesociology, abh12345, allonepower, paulag, luigi-tecnologo, bearone, alliruiz, jeandesss, lionlook, dominiqueruiz, sechki, onex8, wendyruiz, isaganicabrales, delta523, gieaspa, imayang, xtrm111, colettemaria, joshruiz, ellerysunga, amosbastian, ohmyjosh, ladyselene07, pinkblush, foxniner, josebravopalomo, reyleedwalo, andreapacoy, polbot, romeskie, itsmechille, st3llar, southparkqueen, steemgigs, yusuf.nisam, murhadi9, nessyquel, ranielbrianulan, yanga, ligarayk, sissyjill, morbyjohn, kutrulaju, evansbankx, starzy, shahaan, dwightjaden, moksamol, sunnylife, jembee, mrwang, bloghound, foways, rojellyannsotto, charitybot, originalmrspice, mikeyurnero, jayboi, johngoad, superdavey, khusairi, charitymemes, cradle, blessedsteemer, vyaduka, semtroneum, alom8, arcange, raphaelle, steemit-bot, lakawero, ahmanik, samdman, sumsum007, tolarnee, simgirl, kinglypalace, skreza, ninyea, autofreak, cordeta, vaansteam, bitmycoin, tjessie, miniature-tiger, grzesiekb, jacekw.dev, rafalski, doughtaker, steem-ua, hassan679, iridion9, surpassinggoogle, goode, baboyed1000, mhel, karyah1001, tradeownsystems, princekelly, davealemana, mart101, pipo092281, kerry234, parag, ekjosh, kupi, motivatorjoshua, awesome.ian, jecren, harkushi, berylwills, goddywise4-eu, andrelion, pauloliverpino, sanyjaya, strings, richgang, asfuriah, babaj, allaboutme, camilus, hoobeehey, kul0tzzz, julianalpanta, josealmergepegs, dzued, ulfiatu.akiya, arellanoyan, pojgaerlan, thamrin, aldiyani, freudy, zombieslayer, khloyd, akaikeru, jeanp, jefry113, donjyde, faisal08, dexter24, khairuddin08, bobiecayao, elbleess, kofspades, artoraly, kalanggaman, smafey, mercy11, penantang, muksalbaihaqi, estrellamag, zohaib715, klizo, enjoyy, hasan086, handfree42, popson, levinvillas, talivet, chiboyzz, patatesyiyen, ryl, josh26, victoriakorol, mcamayra, vanj, new.diak, basir92, mahmuliadi, fifi-yanti, lstriker, monwalker, pejugold, rhei86, beni96, azharmaulana, toyosiartdiy, theunlimited, bittrex12, virgo27, wandy01, queenlyka, muammarnst, jayo, ayoade96, mikemaphu, fibrefox, bravofer, mbahtutorial, belvajarandilla, muzaiyan, rishi-sayz, rechellomataro, lykia, sabiondico, dondondamayo, anime.lovers, vampirgarfield, kaplat, gerliepepito, techsfair, blackelephant, mayorhero, geotorb, gpwebers, morin89, purepinoy, christinevelasco, liquidpoopcorn, dotman-art, jgpro, rishadhaque, kumagang, bhim, olayemzeecool, amarm, advsamadhan, studytext, mkmk, bitcoin.news, shemzy, cheesom, imkareencajes, breezieblack, noechie1827, matadonis, sampath94, vlogger56, dtube-alfa, muzzlealem, devangbuch, chrisjayl, brewingstories, dazzy, greenville, paulasands, kelvo, fachod, roheemat, ernoldlvb, aikee, emeliveiga, mukulcclbd, akram7, chiqui03, akeenze13, mittalamit284, marzuki-r, devondrjackson, engmi, briandominise, rarcenal, galihtruff, cebusteemer, jezelle, mvoalevine, pinkyangel, edundayo, lotfiuser, gps7530, shippou95, pjmisa, adnanbtc, evolutionnow, kike313, hrovat66, paragon99, ezinwakelvin, sirfreeman, fadiji09, bestsmiles, fredoski, iamfo, pboss123, emirfirlar, jedamez, preciousimo, princefizzy, vegasgambler, alex04, benjaspa, syamsudduha2, polycarpedet, aronexxon, ninjarobo, rikilb, mutiarahmi, phoebedoll, chinosky, afefe, arrahman90, magatha, beshooo, sharminwadud, jeef-zone, joco0820, kataindah, jsantos17, sazid36, gemz2inspire, jomar07, membee, kyanzieuno, steemitkyle, halim08, erebuta01, fotografia101, mayib, daldon, kcpwesh, tammydixon, golden-man, vicmic, boyaceh, arianto71, ninihorlah, noodles09, kayegrasya, sirwayneweezy, bertoandes, minnowboostere, cynicalcake, elvinjohn21, david9122, cebuana, osky, r5yn1r4, dman-dmania, nicole24, pasokon, ayoshewa, dantoyin, bradondamyx12345, withbristy, wanderinglynelle, freitzie123, skyphotographer, dong-a, denkeicui, whatspal, lemcervantes, unika-ejes, ljpaez, crypto-whiz, salim001, ckbahdon, preetisingh1993, attoan.cmt, engineeringfeed, tomatom, dolphinscute, eruditescholar1, maanabdullah, ihamquentin, upyinnyarthutha, annalorin28, shiddiq, ramadhanil, greatwarrior79, steem-factuals, loudetteiam, sahiba, lianbloog, razik9708, ilmondoditea, nigerian-yogagal, egheprincez, rachelleignacio, riyadhie, maikelblogo, genesis171, shiddiq000, fauzan11, byash, hardaeborla, anward-malick, osakuni, kawan-baru, mrnightmare89, robioulsanny, jumpnrun, adebits, shiddiqmjmr, drmoises, lemareg, samsonite18654, maintang03, joseaybar1, digital-aster, foley, ak477, unityph, scottallen, ramonjvp, naayren, gelique, glendale05, citysitebuilders, medyomaldita, caroljayne02, asforex, idiongo, swapsteem, choobymaverick, grizzz, praditya, lksingha, alamgir140491, rajesh1000, crystaljonah1, saifulhuri, rawpostblog, rizzybear, sid000, pandina, zanjero, belicia, chriswilson, zyper, princezakir, alatomz, hmuajanice, dreamseller, minnowwboster, romanticankit, ggd3yydze, syami, mzajoke, yusifm, lunasilver, iamhumbled, srimulyani, jonn.putra, fadhilmuhammad, iryani, syahrulrazi, rizkya, everydaybitcoin, marhadi85, russeldammon, viralz, iryani1, musnawan, damoen, andre93, ramonalexander, randomkindness, gio.vanne, forhadh, jalvarezgw, tech-master, tff, camillius, jayboss, bitcoinmee, tony-duke, umut1905, readymade, iamwhatiamnot, alien-mastermind, beanenergy, faithvarron, eightbitfiction, stuckinacup, nproblem, arisviyo, dynamicshine, abbyrich, ingpablojosue, mrstaf, polarbeats, wealth4good, khunfarang, khunpoom, open-asset, digital-jesus, mrandreas, codingdefined, zeshanjaved, pushpo, masaitv, rigelmarco, kaloka, khairamuliani, cobloc, abyni, epicentrokaribe, cap.potato, letzsteem, eduardonarvaez, aehiguese, lifediaries2nd, reungkhoem, nonsqtr, carloniere, marysent, sukro, hillaryaa, tentalavera, kingsolo, mrxplicit, onin91, frellarong, luijii, raquelita, lykaypajaro, badzkie123, isaaceko, orhem, gwapoaller, khat.holanda23, bgmuna, keybordjp, steeman220, jacobzeema, jancharlest, geezyweezy, bumut, laura97, mwamin7, chinwengozi, friskykitty, sojol527, ablink, dianation, katrina71, carmen52, teardrops, samic, kaylog, rwilday, eyemon1, steemitbuzz, ulogs, steemsecrets, steem-untalented, aauthespian1, biplob12, sayed53, blogger-funda, sexygirl123, teukuizul, ismail96, sarjani, teukuafzal, wawan.anestesi, nurjannah11, nur-malita, roxso, jackbawa, awolesigideon, gracehills, theagriculturist, brightex, steemgigger, steemdragon, avhyaceulip, steemcanvas, kittenpics, kanhiyachauhan, blazing, richardbmx, alvinvoo, utopian-io, truthly,