punitda / ssh-git

Desktop app to manage SSH keys for Github, Bitbucket and Gitlab accounts
https://ssh-git.app
MIT License
5 stars 0 forks source link

Bug : UI Fixes #71

Closed punitda closed 4 years ago

punitda commented 4 years ago

useTimeout:

Created custom hook for it useTimeout() which basically cancels all timeouts on unmount without main component having to deal with it. We need it because in CloneRepo screen we show animations and notification with timeouts. So, if we user exists early we can cancel those timeouts thereby not allowing callback code inside timeout to run resulting into delayed notification on another screen.

useLottieAnimtion:

Apart from cancelling timeouts we also need to make sure we stop lottie animations using anim.stop() method. We weren't handling it resulting into memory leak. Added animation stop and clean up logic in useLottieAnimation hook by exposing additional method from this hook called stopAnimation. So, now this hook returns tuple with actual animation instance and stopAnimation method to stop that particular animation. Ideally we could have used animation instance and called stop() method on it but that doesn't seems to work maybe animation instance becomes null when associated container of it is unmounted and no longer present in DOM. That is the reason we're providing another method from this hook.