-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move common useQuery definitions into their own file
- Loading branch information
Showing
8 changed files
with
164 additions
and
285 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { DefinedUseQueryResult, useQuery } from "@tanstack/react-query"; | ||
|
||
import { | ||
InProxyActivityByPeriod, | ||
InProxyStatusEnum, | ||
} from "@/src/inproxy/types"; | ||
import { getZeroedInProxyActivityStats } from "@/src/inproxy/utils"; | ||
|
||
// These useQuery hooks are used to cache the data emitted by the ConduitModule. | ||
// Note that each queryFn is an empty function, this is because the data cached | ||
// is controlled by the InProxyContext. Anything the ConduitModule emits that we | ||
// want to track or share throughout the app should have an associated hook. | ||
|
||
export const useInProxyStatus = (): DefinedUseQueryResult<InProxyStatusEnum> => | ||
useQuery({ | ||
queryKey: ["inProxyStatus"], | ||
queryFn: () => undefined, | ||
initialData: "UNKNOWN", | ||
enabled: false, | ||
}); | ||
|
||
export const useInProxyActivityBy1000ms = | ||
(): DefinedUseQueryResult<InProxyActivityByPeriod> => | ||
useQuery({ | ||
queryKey: ["inProxyActivityBy1000ms"], | ||
queryFn: () => undefined, | ||
initialData: getZeroedInProxyActivityStats().dataByPeriod["1000ms"], | ||
enabled: false, | ||
}); | ||
|
||
export const useInProxyCurrentConnectedClients = | ||
(): DefinedUseQueryResult<number> => | ||
useQuery({ | ||
queryKey: ["inProxyCurrentConnectedClients"], | ||
queryFn: () => undefined, | ||
initialData: 0, | ||
enabled: false, | ||
}); | ||
|
||
export const useInProxyCurrentConnectingClients = | ||
(): DefinedUseQueryResult<number> => | ||
useQuery({ | ||
queryKey: ["inProxyCurrentConnectingClients"], | ||
queryFn: () => undefined, | ||
initialData: 0, | ||
enabled: false, | ||
}); | ||
|
||
export const useInProxyTotalBytesTransferred = | ||
(): DefinedUseQueryResult<number> => | ||
useQuery({ | ||
queryKey: ["inProxyTotalBytesTransferred"], | ||
queryFn: () => undefined, | ||
initialData: 0, | ||
enabled: false, | ||
}); |
Oops, something went wrong.