-
Notifications
You must be signed in to change notification settings - Fork 0
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
Toast-ilmoitusten ajan nollaaminen | Antti/toast reset timer on hover #43
Conversation
…r will be reseted if hovered with cursor over it. Add a lot of functions that are necessary to make handleErrorToast working
…e unnecessary comment and console.log
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
utils/handleToasts.ts
Outdated
if (!document) { | ||
return; | ||
} |
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.
Onko tämä tarpeellinen tsekkaus?
Puhuttiin silloin serverin puolen rendauksesta, eikö se voi tapahtua tätä funktiota kutsuessa? Silloinhan document
ei pitäisi olla olemassa.
Jos tämä tsekkaus säilytetään, vaihtaisin paikkaa rivin 20 generatedToastID
:n kanssa, jotta turhaan ei generoi ID:tä, jos sitä ei voidakaan käyttää. Käytännössä lienee turha muokkaus
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.
Tsekkaus ei ole tarpeellinen, koska handleErrorToast
funktiota ei koskaan kutsuta serverillä.
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.
Varmistan vielä että ymmärsin oikein. Eli jos handleErrorToast
kutsuttaisiinkin backendissä, silloin tarkistus on tarpeellinen?
Toinen kysymys vielä joka ei tähän varsinaisesti liity. Mutta useEffect
-funktiota .tsx
-päätteisissä tiedostoissa ei ajeta serverillä koskaan, jonka takia esimerkiksi seuraavia tsekkauksia ei tarvitse tehdä:
useEffect(() => {
if(window){
// code
}
}, []);
tai
useEffect(() => {
if(document){
// code
}
}, []);
window
ja document
ovat vain client
-puolen funktioita / classeja / objekteja / tai millä nimellä kutsutaankaan
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.
Varmistan vielä että ymmärsin oikein. Eli jos
handleErrorToast
kutsuttaisiinkin backendissä, silloin tarkistus on tarpeellinen?
Kyllä, juurikin näin.
Toinen kysymys vielä joka ei tähän varsinaisesti liity. Mutta
useEffect
-funktiota.tsx
-päätteisissä tiedostoissa ei ajeta serverillä koskaan, jonka takia esimerkiksi seuraavia tsekkauksia ei tarvitse tehdä:useEffect(() => { if(window){ // code } }, []);tai
useEffect(() => { if(document){ // code } }, []);
window
jadocument
ovat vainclient
-puolen funktioita / classeja / objekteja / tai millä nimellä kutsutaankaan
Jep window
ja document
ovat objekteja jotka on määritetty cain client-puolella. Mutta koska useEffect
kuten myös kaikki onClick
handlerit ajetaan vain client-puolella niissä tarkistusta ei tarvitse tehdä.
utils/handleToasts.ts
Outdated
if (!document) { | ||
return; | ||
} |
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.
Tsekkaus ei ole tarpeellinen, koska handleErrorToast
funktiota ei koskaan kutsuta serverillä.
@anttiasmala Mun ehdotukset |
Mun mielestä sun idea oli parempi! 👍 Jätin kuitenkin Toastien ID:n käyttämään meidän omaa tapaa ( Mergesin samalla |
…ment.body. Change mutation checks to use getElementById
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.
Hyvin toimii! 👍
Valmista, mergetään! |
Toastien ajan nollaamisen toteutus. Näin tuon ominaisuuden Bitwardenin toasteissa. Tykkäsin ideasta, joten halusin kokeilla lisätä itsekin sen.
react-toastify
ei näyttäisi tukevanonHover
-eventtiä, joten toteutin "itse". En löytänyt mitään ohjeita / toteutustapaa netistä tähän liittyen, joten tämä luultavasti on aika hirveän näköinen mutta katsotaan 🤣Maininta kommentissa: #35 (comment)