mirror of
https://github.com/portainer/portainer.git
synced 2025-07-19 05:19:39 +02:00
Revert "feat(app): 1s staleTime to avoid sending repeated requests" (#639)
This commit is contained in:
parent
c331ada086
commit
7aa9f8b1c3
10 changed files with 14 additions and 4 deletions
|
@ -20,6 +20,7 @@ export function useTags<T = Tag[]>({
|
||||||
enabled = true,
|
enabled = true,
|
||||||
}: { select?: (tags: Tag[]) => T; enabled?: boolean } = {}) {
|
}: { select?: (tags: Tag[]) => T; enabled?: boolean } = {}) {
|
||||||
return useQuery(tagKeys.all, () => getTags(), {
|
return useQuery(tagKeys.all, () => getTags(), {
|
||||||
|
staleTime: 50,
|
||||||
select,
|
select,
|
||||||
enabled,
|
enabled,
|
||||||
...withError('Failed to retrieve tags'),
|
...withError('Failed to retrieve tags'),
|
||||||
|
|
|
@ -12,9 +12,10 @@ interface CurrentUserResponse extends User {
|
||||||
forceChangePassword: boolean;
|
forceChangePassword: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useLoadCurrentUser() {
|
export function useLoadCurrentUser({ staleTime }: { staleTime?: number } = {}) {
|
||||||
return useQuery(userQueryKeys.me(), () => getCurrentUser(), {
|
return useQuery(userQueryKeys.me(), () => getCurrentUser(), {
|
||||||
...withError('Unable to retrieve user details'),
|
...withError('Unable to retrieve user details'),
|
||||||
|
staleTime,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,9 +8,13 @@ import { User, UserId } from '../types';
|
||||||
|
|
||||||
import { userQueryKeys } from './queryKeys';
|
import { userQueryKeys } from './queryKeys';
|
||||||
|
|
||||||
export function useUser(id: UserId) {
|
export function useUser(
|
||||||
|
id: UserId,
|
||||||
|
{ staleTime }: { staleTime?: number } = {}
|
||||||
|
) {
|
||||||
return useQuery(userQueryKeys.user(id), () => getUser(id), {
|
return useQuery(userQueryKeys.user(id), () => getUser(id), {
|
||||||
...withError('Unable to retrieve user details'),
|
...withError('Unable to retrieve user details'),
|
||||||
|
staleTime,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,6 @@ export function createQueryClient() {
|
||||||
defaultOptions: {
|
defaultOptions: {
|
||||||
queries: {
|
queries: {
|
||||||
networkMode: 'offlineFirst',
|
networkMode: 'offlineFirst',
|
||||||
staleTime: 1000, // 1s stale time by default
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mutationCache: new MutationCache({
|
mutationCache: new MutationCache({
|
||||||
|
|
|
@ -83,6 +83,7 @@ export function useDeleteHelmRepositoriesMutation() {
|
||||||
|
|
||||||
export function useHelmRepositories(userId: number) {
|
export function useHelmRepositories(userId: number) {
|
||||||
return useQuery(['helmrepositories'], () => getHelmRepositories(userId), {
|
return useQuery(['helmrepositories'], () => getHelmRepositories(userId), {
|
||||||
|
staleTime: 20,
|
||||||
...withError('Unable to retrieve Helm repositories'),
|
...withError('Unable to retrieve Helm repositories'),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ export function useGroup<T = EnvironmentGroup>(
|
||||||
return getGroup(groupId);
|
return getGroup(groupId);
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
staleTime: 50,
|
||||||
select,
|
select,
|
||||||
enabled: groupId !== undefined,
|
enabled: groupId !== undefined,
|
||||||
...withGlobalError('Failed loading group'),
|
...withGlobalError('Failed loading group'),
|
||||||
|
|
|
@ -27,6 +27,7 @@ export function useEnvironment<T = Environment>(
|
||||||
{
|
{
|
||||||
select,
|
select,
|
||||||
...withError('Failed loading environment'),
|
...withError('Failed loading environment'),
|
||||||
|
staleTime: 50,
|
||||||
enabled: !!environmentId,
|
enabled: !!environmentId,
|
||||||
refetchInterval() {
|
refetchInterval() {
|
||||||
return options?.autoRefreshRate ?? false;
|
return options?.autoRefreshRate ?? false;
|
||||||
|
|
|
@ -20,7 +20,7 @@ interface Params {
|
||||||
export function useTagDetails<T = RepositoryTagViewModel>(
|
export function useTagDetails<T = RepositoryTagViewModel>(
|
||||||
params: Params,
|
params: Params,
|
||||||
{
|
{
|
||||||
staleTime,
|
staleTime = 0,
|
||||||
select,
|
select,
|
||||||
}: { select?: (model: RepositoryTagViewModel) => T; staleTime?: number } = {}
|
}: { select?: (model: RepositoryTagViewModel) => T; staleTime?: number } = {}
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -19,6 +19,7 @@ export function useExperimentalSettings<T = ExperimentalFeaturesSettings>(
|
||||||
return useQuery(queryKeys.experimental(), getExperimentalSettings, {
|
return useQuery(queryKeys.experimental(), getExperimentalSettings, {
|
||||||
select,
|
select,
|
||||||
enabled,
|
enabled,
|
||||||
|
staleTime: 50,
|
||||||
...withError('Unable to retrieve experimental settings'),
|
...withError('Unable to retrieve experimental settings'),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ export function useSettings<T = Settings>(
|
||||||
return useQuery(queryKeys.base(), getSettings, {
|
return useQuery(queryKeys.base(), getSettings, {
|
||||||
select,
|
select,
|
||||||
enabled,
|
enabled,
|
||||||
|
staleTime: 50,
|
||||||
...withError('Unable to retrieve settings'),
|
...withError('Unable to retrieve settings'),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue