irislib / iris-messenger

Decentralized messenger
https://iris.to
MIT License
719 stars 157 forks source link

useKey #428

Closed keutmann closed 1 year ago

keutmann commented 1 year ago

Some of my code from the DWoTR fork. I think it simplifys the code by delegating the different key formats in the same hook and scandalize the names of keys in other function components. Demo implementation in Badge.tsx

mmalmi commented 1 year ago

Thanks for the PR, but I just added Hex, PublicKey and EventID classes https://github.com/irislib/iris-messenger/blob/master/src/js/utils/Hex/Hex.ts and Key.isMine(str). I think it's good to be a class so it can be used as a parameter type.

keutmann commented 1 year ago

Gotcha, I saw the classes you added. I used the useKey idea mainly to dodge the key format recalculation on every render and simplify the component code. But I get where you're coming from with the class approach.