frontend client for gemstone. decentralised workplace app
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor: abstract more queries

serenity 15d47c4a e395aa5c

+40 -18
+3 -9
src/components/Settings/LatticeInfo.tsx
··· 3 3 import type { AtUri } from "@/lib/types/atproto"; 4 4 import type { SystemsGmstnDevelopmentLattice } from "@/lib/types/lexicon/systems.gmstn.development.lattice"; 5 5 import { useCurrentPalette } from "@/providers/ThemeProvider"; 6 - import { getOwnerInfoFromLattice } from "@/queries/get-owner-info-from-lattice"; 7 - import { useQuery } from "@tanstack/react-query"; 6 + import { useLatticeInfoQuery } from "@/queries/hooks/useLatticeInfoQuery"; 8 7 import { BadgeCheck, X } from "lucide-react-native"; 9 8 import { View } from "react-native"; 10 9 ··· 17 16 }; 18 17 }) => { 19 18 const latticeDomain = lattice.uri.rKey; 20 - const { isLoading, data: latticeInfo } = useQuery({ 21 - queryKey: ["shardInfo", latticeDomain], 22 - queryFn: async () => { 23 - return await getOwnerInfoFromLattice(latticeDomain); 24 - }, 25 - retry: 1, 26 - }); 19 + const { useQuery } = useLatticeInfoQuery(latticeDomain); 20 + const { isLoading, data: latticeInfo } = useQuery(); 27 21 const { semantic } = useCurrentPalette(); 28 22 29 23 return (
+3 -9
src/components/Settings/ShardInfo.tsx
··· 3 3 import type { AtUri } from "@/lib/types/atproto"; 4 4 import type { SystemsGmstnDevelopmentShard } from "@/lib/types/lexicon/systems.gmstn.development.shard"; 5 5 import { useCurrentPalette } from "@/providers/ThemeProvider"; 6 - import { getOwnerInfoFromShard } from "@/queries/get-owner-info-from-shard"; 7 - import { useQuery } from "@tanstack/react-query"; 6 + import { useShardInfoQuery } from "@/queries/hooks/useShardInfoQuery"; 8 7 import { BadgeCheck, X } from "lucide-react-native"; 9 8 import { View } from "react-native"; 10 9 ··· 17 16 }; 18 17 }) => { 19 18 const shardDomain = shard.uri.rKey; 20 - const { isLoading, data: shardInfo } = useQuery({ 21 - queryKey: ["shardInfo", shardDomain], 22 - queryFn: async () => { 23 - return await getOwnerInfoFromShard(shardDomain); 24 - }, 25 - retry: 1, 26 - }); 19 + const { useQuery } = useShardInfoQuery(shardDomain); 20 + const { isLoading, data: shardInfo } = useQuery(); 27 21 const { semantic } = useCurrentPalette(); 28 22 29 23 return (
+17
src/queries/hooks/useLatticeInfoQuery.ts
··· 1 + import { getOwnerInfoFromLattice } from "@/queries/get-owner-info-from-lattice"; 2 + import { useQuery } from "@tanstack/react-query"; 3 + 4 + export const useLatticeInfoQuery = (latticeDomain: string) => { 5 + const queryKey = ["latticeInfo", latticeDomain]; 6 + return { 7 + queryKey, 8 + useQuery: () => 9 + useQuery({ 10 + queryKey, 11 + queryFn: async () => { 12 + return await getOwnerInfoFromLattice(latticeDomain); 13 + }, 14 + retry: 1, 15 + }), 16 + }; 17 + };
+17
src/queries/hooks/useShardInfoQuery.ts
··· 1 + import { getOwnerInfoFromShard } from "@/queries/get-owner-info-from-shard"; 2 + import { useQuery } from "@tanstack/react-query"; 3 + 4 + export const useShardInfoQuery = (shardDomain: string) => { 5 + const queryKey = ["shardInfo", shardDomain]; 6 + return { 7 + queryKey, 8 + useQuery: () => 9 + useQuery({ 10 + queryKey, 11 + queryFn: async () => { 12 + return await getOwnerInfoFromShard(shardDomain); 13 + }, 14 + retry: 1, 15 + }), 16 + }; 17 + };