Skip to content

Commit

Permalink
🎉 리스트 페이지 staleTime 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
doggopawer committed Nov 27, 2023
1 parent 383d21a commit 727e8f1
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/constants/staleTime.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const LIST_STALE_TIME = 60000
2 changes: 2 additions & 0 deletions src/hooks/api/queries/useCardsQuery.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useInfiniteQuery } from '@tanstack/react-query'
import { LIST_STALE_TIME } from '@/constants/staleTime'
import { GetCardListRes, getCardList } from '@/services/card/card'
import { CategoryObjs, PriceRangeObjs } from '@/types/card'

Expand Down Expand Up @@ -27,5 +28,6 @@ export const useCardsQuery = ({
getNextPageParam: (lastPage: GetCardListRes) => {
return lastPage.data.nextCursorId
},
staleTime: LIST_STALE_TIME,
})
}
2 changes: 2 additions & 0 deletions src/hooks/api/queries/useChatRoomsQuery.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useInfiniteQuery } from '@tanstack/react-query'
import { LIST_STALE_TIME } from '@/constants/staleTime'
import {
GetChatRoomListRes,
getChatRoomList,
Expand All @@ -15,5 +16,6 @@ export const useChatRoomsQuery = () => {
getNextPageParam: (lastPage: GetChatRoomListRes) => {
return lastPage.data.nextCursorId
},
staleTime: LIST_STALE_TIME,
})
}
2 changes: 2 additions & 0 deletions src/hooks/api/queries/useMyCardsQuery.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useInfiniteQuery } from '@tanstack/react-query'
import { LIST_STALE_TIME } from '@/constants/staleTime'
import { GetMyCardListRes, getMyCardList } from '@/services/card/card'
import { TradeStatus } from '@/types/card'

Expand All @@ -18,5 +19,6 @@ export const useMyCardsQuery = ({ tradeStatus }: UseMyCardsQueryParams) => {
getNextPageParam: (lastPage: GetMyCardListRes) => {
return lastPage.data.nextCursorId
},
staleTime: LIST_STALE_TIME,
})
}
2 changes: 2 additions & 0 deletions src/hooks/api/queries/useMyDibsQuery.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useInfiniteQuery } from '@tanstack/react-query'
import { LIST_STALE_TIME } from '@/constants/staleTime'
import { GetMyDibsRes, getMyDibs } from '@/services/card/card'

export const useMyDibsQuery = () => {
Expand All @@ -10,5 +11,6 @@ export const useMyDibsQuery = () => {
getNextPageParam: (lastPage: GetMyDibsRes) => {
return lastPage.data.nextCursorId
},
staleTime: LIST_STALE_TIME,
})
}
2 changes: 2 additions & 0 deletions src/hooks/api/queries/useMySuggestionsQuery.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useInfiniteQuery } from '@tanstack/react-query'
import { LIST_STALE_TIME } from '@/constants/staleTime'
import { getMySuggestionList } from '@/services/suggestion/suggestion'
import { DirectionType, SuggestionType } from '@/types/suggestion'

Expand All @@ -20,5 +21,6 @@ export const useMySuggestionsQuery = (
getNextPageParam: (lastPage: any) => {
return lastPage.data.nextCursorId
},
staleTime: LIST_STALE_TIME,
})
}
2 changes: 2 additions & 0 deletions src/hooks/api/queries/useMyTradeHistoriesQuery.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useInfiniteQuery } from '@tanstack/react-query'
import { LIST_STALE_TIME } from '@/constants/staleTime'
import {
GetMyTradeHistoryListRes,
getMyTradeHistoryList,
Expand All @@ -15,5 +16,6 @@ export const useMyTradeHistoryQuery = () => {
getNextPageParam: (lastPage: GetMyTradeHistoryListRes) => {
return lastPage.data.nextCursorId
},
staleTime: LIST_STALE_TIME,
})
}
2 changes: 2 additions & 0 deletions src/hooks/api/queries/useNotificationsQuery.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useInfiniteQuery } from '@tanstack/react-query'
import { LIST_STALE_TIME } from '@/constants/staleTime'
import {
GetNotificationListRes,
getNotificationList,
Expand All @@ -16,5 +17,6 @@ export const useNotificationsQuery = (isRead: boolean) => {
getNextPageParam: (lastPage: GetNotificationListRes) => {
return lastPage.data.nextCursorId
},
staleTime: LIST_STALE_TIME,
})
}

0 comments on commit 727e8f1

Please sign in to comment.