Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚡️ Reduce refetching APIs #380

Merged
merged 1 commit into from
Oct 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ import '../leaflet.config.js'
import { FeatureProvider } from './components/useFeature'

const App: FC = () => {
const queryClient = new QueryClient()
const queryClient = new QueryClient({
defaultOptions: { queries: { staleTime: 60 * 1000 } },
})

return (
<QueryClientProvider client={queryClient}>
Expand Down
6 changes: 2 additions & 4 deletions src/components/message/MessageList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ interface Props {
const MessageList: FC<Props> = ({ ticker }) => {
const { token } = useAuth()
const { getMessages } = useMessageApi(token)
const { isLoading, error, data } = useQuery(
['messages', ticker.id],
() => getMessages(ticker.id),
{ refetchInterval: false }
const { isLoading, error, data } = useQuery(['messages', ticker.id], () =>
getMessages(ticker.id)
)

if (isLoading) {
Expand Down
5 changes: 1 addition & 4 deletions src/components/settings/InactiveSettingsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ const InactiveSettingsCard: FC = () => {
const { getInactiveSettings } = useSettingsApi(token)
const { isLoading, error, data } = useQuery(
['inactive_settings'],
getInactiveSettings,
{
refetchInterval: false,
}
getInactiveSettings
)

if (isLoading) {
Expand Down
5 changes: 1 addition & 4 deletions src/components/settings/RefreshIntervalCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ const RefreshIntervalCard: FC = () => {
const { getRefreshInterval } = useSettingsApi(token)
const { isLoading, error, data } = useQuery(
['refresh_interval_setting'],
getRefreshInterval,
{
refetchInterval: false,
}
getRefreshInterval
)

if (isLoading) {
Expand Down
3 changes: 0 additions & 3 deletions src/components/ticker/TickerUserCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ const TickerUsersCard: FC<Props> = props => {
['tickerUsers', props.ticker.id],
() => {
return getTickerUsers(props.ticker)
},
{
refetchInterval: false,
}
)

Expand Down
4 changes: 1 addition & 3 deletions src/components/user/UserList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ import ErrorView from '../../views/ErrorView'
const UserList: FC = () => {
const { token } = useAuth()
const { getUsers } = useUserApi(token)
const { isLoading, error, data } = useQuery(['users'], getUsers, {
refetchInterval: false,
})
const { isLoading, error, data } = useQuery(['users'], getUsers)

if (isLoading) {
return (
Expand Down
4 changes: 1 addition & 3 deletions src/views/HomeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ import { Navigate } from 'react-router'
const HomeView: FC = () => {
const { token, user } = useAuth()
const { getTickers } = useTickerApi(token)
const { isLoading, error, data } = useQuery(['tickers'], getTickers, {
refetchInterval: false,
})
const { isLoading, error, data } = useQuery(['tickers'], getTickers)

if (isLoading) {
return (
Expand Down
6 changes: 2 additions & 4 deletions src/views/TickerView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ const TickerView: FC = () => {
const { tickerId } = useParams<keyof TickerViewParams>() as TickerViewParams
const tickerIdNum = parseInt(tickerId)

const { isLoading, error, data } = useQuery(
['ticker', tickerIdNum],
() => getTicker(tickerIdNum),
{ refetchInterval: false }
const { isLoading, error, data } = useQuery(['ticker', tickerIdNum], () =>
getTicker(tickerIdNum)
)

if (isLoading) {
Expand Down