-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
buscador de usuarios por nombre en github #41
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@codemcu, como te dije en #39. Estas en otro nivel y el grado de exigencia es mayor. Dicho esto, el código es elegante y funciona bien, aunque tienes un par de problemas en el HTML. (título del documento y gestión de imágenes transparentes). Me gusto mucho que incluyeras el Score
Dos cosas importantes... DRY y KISS. Estas haciendo dos llamadas AJAX para averiguar los followers
y followings
... cuando realmente lo podrías sacar la información haciendo una única llamada a su perfil https://api.github.com/users/
y evitando que rápidamente sobrepase el límite.
Espero un refactor 🕶
mauricio/githubSearch/css/style.css
Outdated
background: #355C7D"*/ | ||
|
||
body { | ||
/*background-color: #F8B195;*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ℹ️ El código comentado... sobra
mauricio/githubSearch/css/style.css
Outdated
width: 620px; | ||
margin: 0 auto 0; | ||
list-style-type: none; | ||
/*background-color: #355C7D;*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ℹ️ El código comentado... sobra
mauricio/githubSearch/js/main.js
Outdated
|
||
} else { | ||
|
||
if (document.querySelector('ul') !== null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mete este selector en una variable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
mauricio/githubSearch/js/main.js
Outdated
|
||
loadAjax(`https://api.github.com/search/users?q=${text}+in%3Afullname&type=Users`) | ||
.then(getNetwork) | ||
.catch(error => console.log(error)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gestiona el error de forma visual también
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
he metido try/catch
pero como console.log
, por ahora...
mauricio/githubSearch/js/main.js
Outdated
|
||
if ($event.code === 'Enter' && $event.isTrusted) { | ||
|
||
if (input.value.trim() === '') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No necesitas === ""
podrías hacer !input.value.trim()
o simplemente input.value.trim()
que sería más legible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
mauricio/githubSearch/js/main.js
Outdated
const p = document.createElement('P'); | ||
container.appendChild(p); | ||
p.textContent = 'Please enter username'; | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
mauricio/githubSearch/js/main.js
Outdated
|
||
users.forEach(function (item) { | ||
|
||
const followers = new Promise( (resolve, reject) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
followers
y followings
son lo mismo con distintas urls. DRY!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nadie gestiona los errores... 🤦♂️
mauricio/githubSearch/js/main.js
Outdated
getFollowings(followings, div); | ||
} | ||
|
||
function getFollowers (followers, div) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getFollowers
y getFollowings
son lo mismo con distinto texto y target.... DRY!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async/await
al rescate!. Aparte de mi despiste de followers y following en /user
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feedback
- Muy bien por usar
async/await
- El código está algo descuidado, pero nada que un buen reactor no ayude a solucionar
- Me gusto mucho la idea del buscador! 👏
- Estaría bien apoyar un poco al usuario cuando se esperan datos o no tenemos información que mostrar xD
🌟 Me gusta el diseño y que aparezcan todas las coincidencias!
Bugs
- Qué pasa cuando alcanzas el límite?
- No hay spinners ni similar...
mauricio/githubSearch/js/main.js
Outdated
reject(response.json()); | ||
} | ||
}) | ||
.catch(error => console.log(error)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aqui haces un return raro...
mauricio/githubSearch/js/main.js
Outdated
input.addEventListener('keyup', searchUser, false); | ||
const container = document.querySelector('.container'); | ||
|
||
async function searchUser($event) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
el naming de $event
fuera de angular.. no es muy extendido ;-)
mauricio/githubSearch/js/main.js
Outdated
@@ -0,0 +1,112 @@ | |||
(function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
podría ser arrow...
mauricio/githubSearch/js/main.js
Outdated
try { | ||
if ($event.code === 'Enter' && $event.isTrusted) { | ||
|
||
if (!input.value.trim()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Esto lo reutilizas luego como text
..
document.querySelector('ul').remove(); | ||
} | ||
|
||
const text = input.value.trim(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mauricio/githubSearch/js/main.js
Outdated
|
||
} else { | ||
|
||
const isUl = document.querySelector('ul') !== null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
es raro como manejas este condicional y su contexto con document.querySelector('ul')
e isUl
mauricio/githubSearch/js/main.js
Outdated
|
||
const resArray = data.items; | ||
|
||
resArray.forEach(async function (item) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no es mas sencillo un Promise.All()
?
No description provided.