Repository navigation
[Migadu] cache most results + minor api refactor - #13990
Conversation
|
Thank you for the update! 🎉 You can expect an initial review within five business days. |
|
|
||
| function AliasesIndex({ domain }: { domain: string }) { | ||
| const { push } = useNavigation(); | ||
| const [aliases, setAliases] = useState<Alias[]>([]); |
There was a problem hiding this comment.
Suggestion (non-blocking): In an effort of pure refactoring, we can use useCachedPromise hook (instead of useCachedState) to replace the whole getDomainAliasesFromApi(), isLoading, error etc. and we won't need useCachedState. So something like:
const {isLoading, error, mutate, data: aliases} = useCachedPromise(getDomainAliases, [domain], {failureToastOptions: {title: "Error while getting domain aliases"}});This will require some refactoring in callApi: removing the failure toast there and bubbling up the error msg as part of Error instead of ErrorResponse.
This way we can also optimistically mutate based on deletion etc.
This refactoring can be applied to most commands where we are using useCachedState in this PR. If this is intrusive for this PR, it can be handled as part of a separate PR too. What do you think?
left a comment
There was a problem hiding this comment.
I really like this refactor @xmok. Thanks for raising the bar 🔥
Another thing I noticed was the delete resource shortcut. Most Raycast commands/extensions will use Ctrl + x as a standard practice, for easy memorization. For example:
But Cmd + d also makes sense.
commented
Aug 15, 2024
|
Great suggestions. I really appreciate the review 👀.
Thanks! |
commented
Aug 16, 2024
|
@jfkisafk, thank you for catching the mistake 🤦♂️. I'll be sure to eventually migrate the extension to use the native hooks in the future which would supersede this PR 🔥. |
commented
Aug 21, 2024
|
Published to the Raycast Store: |
commented
Aug 21, 2024
|
🎉 🎉 🎉 We've rewarded your Raycast account with some credits. You will soon be able to exchange them for some swag. |
Description
Replaced some of the
useStatewithuseCachedStateso the data is cached.In terms of refactoring, I moved the type casting of api responses into the api function itself so there is fewer explicit casting.
Screencast
No screencast needed as functionality has not changed besides data is now cached on future loads.
Checklist
npm run buildand tested this distribution build in Raycastassetsfolder are used by the extension itselfREADMEare placed outside of themetadatafolder