Revise cache times (#1942)

(cherry picked from commit 1be2060a2b81741dcf9a392160af87d2747b3497)
zio/stable
Eric Bailey 2023-11-16 17:43:53 -06:00 committed by GitHub
parent 1952705ded
commit 6f57192bd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 14 additions and 14 deletions

View File

@ -9,7 +9,7 @@ export const RQKEY = () => ['app-passwords']
export function useAppPasswordsQuery() { export function useAppPasswordsQuery() {
const {agent} = useSession() const {agent} = useSession()
return useQuery({ return useQuery({
staleTime: STALE.INFINITY, staleTime: STALE.MINUTES.ONE,
queryKey: RQKEY(), queryKey: RQKEY(),
queryFn: async () => { queryFn: async () => {
const res = await agent.com.atproto.server.listAppPasswords({}) const res = await agent.com.atproto.server.listAppPasswords({})

View File

@ -18,7 +18,7 @@ export function useListMembersQuery(uri: string) {
QueryKey, QueryKey,
RQPageParam RQPageParam
>({ >({
staleTime: STALE.INFINITY, staleTime: STALE.MINUTES.ONE,
queryKey: RQKEY(uri), queryKey: RQKEY(uri),
async queryFn({pageParam}: {pageParam: RQPageParam}) { async queryFn({pageParam}: {pageParam: RQPageParam}) {
const res = await agent.app.bsky.graph.getList({ const res = await agent.app.bsky.graph.getList({

View File

@ -40,7 +40,7 @@ export interface ListMembersip {
export function useDangerousListMembershipsQuery() { export function useDangerousListMembershipsQuery() {
const {agent, currentAccount} = useSession() const {agent, currentAccount} = useSession()
return useQuery<ListMembersip[]>({ return useQuery<ListMembersip[]>({
staleTime: STALE.INFINITY, staleTime: STALE.MINUTES.FIVE,
queryKey: RQKEY(), queryKey: RQKEY(),
async queryFn() { async queryFn() {
if (!currentAccount) { if (!currentAccount) {

View File

@ -20,7 +20,7 @@ export const RQKEY = (uri: string) => ['list', uri]
export function useListQuery(uri?: string) { export function useListQuery(uri?: string) {
const {agent} = useSession() const {agent} = useSession()
return useQuery<AppBskyGraphDefs.ListView, Error>({ return useQuery<AppBskyGraphDefs.ListView, Error>({
staleTime: STALE.INFINITY, staleTime: STALE.MINUTES.ONE,
queryKey: RQKEY(uri || ''), queryKey: RQKEY(uri || ''),
async queryFn() { async queryFn() {
if (!uri) { if (!uri) {

View File

@ -16,7 +16,7 @@ export function useMyBlockedAccountsQuery() {
QueryKey, QueryKey,
RQPageParam RQPageParam
>({ >({
staleTime: STALE.INFINITY, staleTime: STALE.MINUTES.ONE,
queryKey: RQKEY(), queryKey: RQKEY(),
async queryFn({pageParam}: {pageParam: RQPageParam}) { async queryFn({pageParam}: {pageParam: RQPageParam}) {
const res = await agent.app.bsky.graph.getBlocks({ const res = await agent.app.bsky.graph.getBlocks({

View File

@ -11,7 +11,7 @@ export const RQKEY = (filter: MyListsFilter) => ['my-lists', filter]
export function useMyListsQuery(filter: MyListsFilter) { export function useMyListsQuery(filter: MyListsFilter) {
const {agent, currentAccount} = useSession() const {agent, currentAccount} = useSession()
return useQuery<AppBskyGraphDefs.ListView[]>({ return useQuery<AppBskyGraphDefs.ListView[]>({
staleTime: STALE.INFINITY, staleTime: STALE.MINUTES.ONE,
queryKey: RQKEY(filter), queryKey: RQKEY(filter),
async queryFn() { async queryFn() {
let lists: AppBskyGraphDefs.ListView[] = [] let lists: AppBskyGraphDefs.ListView[] = []

View File

@ -16,7 +16,7 @@ export function useMyMutedAccountsQuery() {
QueryKey, QueryKey,
RQPageParam RQPageParam
>({ >({
staleTime: STALE.INFINITY, staleTime: STALE.MINUTES.ONE,
queryKey: RQKEY(), queryKey: RQKEY(),
async queryFn({pageParam}: {pageParam: RQPageParam}) { async queryFn({pageParam}: {pageParam: RQPageParam}) {
const res = await agent.app.bsky.graph.getMutes({ const res = await agent.app.bsky.graph.getMutes({

View File

@ -34,7 +34,7 @@ export function usePreferencesQuery() {
const {agent, hasSession} = useSession() const {agent, hasSession} = useSession()
return useQuery({ return useQuery({
enabled: hasSession, enabled: hasSession,
staleTime: STALE.INFINITY, staleTime: STALE.MINUTES.ONE,
queryKey: usePreferencesQueryKey, queryKey: usePreferencesQueryKey,
queryFn: async () => { queryFn: async () => {
const res = await agent.getPreferences() const res = await agent.getPreferences()

View File

@ -13,7 +13,7 @@ export const RQKEY = (did: string) => ['profile-extra-info', did]
export function useProfileExtraInfoQuery(did: string) { export function useProfileExtraInfoQuery(did: string) {
const {agent} = useSession() const {agent} = useSession()
return useQuery({ return useQuery({
staleTime: STALE.INFINITY, staleTime: STALE.MINUTES.ONE,
queryKey: RQKEY(did), queryKey: RQKEY(did),
async queryFn() { async queryFn() {
const [listsRes, feedsRes] = await Promise.all([ const [listsRes, feedsRes] = await Promise.all([

View File

@ -23,7 +23,7 @@ export function useProfileFeedgensQuery(
QueryKey, QueryKey,
RQPageParam RQPageParam
>({ >({
staleTime: STALE.INFINITY, staleTime: STALE.MINUTES.ONE,
queryKey: RQKEY(did), queryKey: RQKEY(did),
async queryFn({pageParam}: {pageParam: RQPageParam}) { async queryFn({pageParam}: {pageParam: RQPageParam}) {
const res = await agent.app.bsky.feed.getActorFeeds({ const res = await agent.app.bsky.feed.getActorFeeds({

View File

@ -19,7 +19,7 @@ export function useProfileFollowsQuery(did: string | undefined) {
QueryKey, QueryKey,
RQPageParam RQPageParam
>({ >({
staleTime: STALE.INFINITY, staleTime: STALE.MINUTES.ONE,
queryKey: RQKEY(did || ''), queryKey: RQKEY(did || ''),
async queryFn({pageParam}: {pageParam: RQPageParam}) { async queryFn({pageParam}: {pageParam: RQPageParam}) {
const res = await agent.app.bsky.graph.getFollows({ const res = await agent.app.bsky.graph.getFollows({

View File

@ -19,7 +19,7 @@ export function useProfileListsQuery(did: string, opts?: {enabled?: boolean}) {
QueryKey, QueryKey,
RQPageParam RQPageParam
>({ >({
staleTime: STALE.INFINITY, staleTime: STALE.MINUTES.ONE,
queryKey: RQKEY(did), queryKey: RQKEY(did),
async queryFn({pageParam}: {pageParam: RQPageParam}) { async queryFn({pageParam}: {pageParam: RQPageParam}) {
const res = await agent.app.bsky.graph.getLists({ const res = await agent.app.bsky.graph.getLists({

View File

@ -16,7 +16,7 @@ export function useSuggestedFeedsQuery() {
QueryKey, QueryKey,
string | undefined string | undefined
>({ >({
staleTime: STALE.INFINITY, staleTime: STALE.HOURS.ONE,
queryKey: suggestedFeedsQueryKey, queryKey: suggestedFeedsQueryKey,
queryFn: async ({pageParam}) => { queryFn: async ({pageParam}) => {
const res = await agent.app.bsky.feed.getSuggestedFeeds({ const res = await agent.app.bsky.feed.getSuggestedFeeds({

View File

@ -34,7 +34,7 @@ export function useSuggestedFollowsQuery() {
string | undefined string | undefined
>({ >({
enabled: !!moderationOpts, enabled: !!moderationOpts,
staleTime: STALE.INFINITY, staleTime: STALE.HOURS.ONE,
queryKey: suggestedFollowsQueryKey, queryKey: suggestedFollowsQueryKey,
queryFn: async ({pageParam}) => { queryFn: async ({pageParam}) => {
const res = await agent.app.bsky.actor.getSuggestions({ const res = await agent.app.bsky.actor.getSuggestions({