Skip to content

Commit

Permalink
Fix: cache alby user calls (#377)
Browse files Browse the repository at this point in the history
* fix: cache fetches to alby user endpoint for 5 minutes by default

* fix: also cache alby balance calls
  • Loading branch information
rolznz authored Jul 31, 2024
1 parent f464a5a commit 2ec2cda
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions frontend/src/hooks/useAlbyBalance.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import useSWR from "swr";

import { swrFetcher } from "src/utils/swr";
import { AlbyBalance } from "src/types";
import { swrFetcher } from "src/utils/swr";

export function useAlbyBalance() {
return useSWR<AlbyBalance>("/api/alby/balance", swrFetcher);
return useSWR<AlbyBalance>("/api/alby/balance", swrFetcher, {
dedupingInterval: 5 * 60 * 1000, // 5 minutes
});
}
4 changes: 3 additions & 1 deletion frontend/src/hooks/useAlbyMe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ import { AlbyMe } from "src/types";
import { swrFetcher } from "src/utils/swr";

export function useAlbyMe() {
return useSWR<AlbyMe>("/api/alby/me", swrFetcher);
return useSWR<AlbyMe>("/api/alby/me", swrFetcher, {
dedupingInterval: 5 * 60 * 1000, // 5 minutes
});
}

0 comments on commit 2ec2cda

Please sign in to comment.