Merge pull request #1723 from automatisch/remove-unused-payloads
refactor: remove unused payloads from RQ
This commit is contained in:
@@ -40,12 +40,14 @@ function AddNewAppConnection(props) {
|
||||
const [appName, setAppName] = React.useState('');
|
||||
const [isLoading, setIsLoading] = React.useState(false);
|
||||
|
||||
const { data: apps, mutate } = useLazyApps({
|
||||
appName,
|
||||
const { data: apps, mutate } = useLazyApps(
|
||||
{ appName },
|
||||
{
|
||||
onSuccess: () => {
|
||||
setIsLoading(false);
|
||||
},
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
const fetchData = React.useMemo(() => debounce(mutate, 300), [mutate]);
|
||||
|
||||
|
@@ -161,17 +161,17 @@ function FlowStep(props) {
|
||||
({ key }) => key === step.key,
|
||||
);
|
||||
|
||||
const { data: triggerSubsteps } = useTriggerSubsteps(
|
||||
app?.key,
|
||||
actionOrTrigger?.key,
|
||||
);
|
||||
const { data: triggerSubsteps } = useTriggerSubsteps({
|
||||
appKey: app?.key,
|
||||
triggerKey: actionOrTrigger?.key,
|
||||
});
|
||||
|
||||
const triggerSubstepsData = triggerSubsteps?.data || [];
|
||||
|
||||
const { data: actionSubsteps } = useActionSubsteps(
|
||||
app?.key,
|
||||
actionOrTrigger?.key,
|
||||
);
|
||||
const { data: actionSubsteps } = useActionSubsteps({
|
||||
appKey: app?.key,
|
||||
actionKey: actionOrTrigger?.key,
|
||||
});
|
||||
|
||||
const actionSubstepsData = actionSubsteps?.data || [];
|
||||
|
||||
|
@@ -2,10 +2,10 @@ import { useQuery } from '@tanstack/react-query';
|
||||
|
||||
import api from 'helpers/api';
|
||||
|
||||
export default function useActionSubsteps(appKey, actionKey) {
|
||||
export default function useActionSubsteps({ appKey, actionKey }) {
|
||||
const query = useQuery({
|
||||
queryKey: ['actionSubsteps', appKey, actionKey],
|
||||
queryFn: async ({ payload, signal }) => {
|
||||
queryFn: async ({ signal }) => {
|
||||
const { data } = await api.get(
|
||||
`/v1/apps/${appKey}/actions/${actionKey}/substeps`,
|
||||
{
|
||||
|
@@ -5,7 +5,7 @@ import api from 'helpers/api';
|
||||
export default function useActions(appKey) {
|
||||
const query = useQuery({
|
||||
queryKey: ['actions', appKey],
|
||||
queryFn: async ({ payload, signal }) => {
|
||||
queryFn: async ({ signal }) => {
|
||||
const { data } = await api.get(`/v1/apps/${appKey}/actions`, {
|
||||
signal,
|
||||
});
|
||||
|
@@ -5,7 +5,7 @@ import api from 'helpers/api';
|
||||
export default function useAdminAppAuthClient(id) {
|
||||
const query = useQuery({
|
||||
queryKey: ['adminAppAuthClient', id],
|
||||
queryFn: async ({ payload, signal }) => {
|
||||
queryFn: async ({ signal }) => {
|
||||
const { data } = await api.get(`/v1/admin/app-auth-clients/${id}`, {
|
||||
signal,
|
||||
});
|
||||
|
@@ -5,7 +5,7 @@ import api from 'helpers/api';
|
||||
export default function useApp(appKey) {
|
||||
const query = useQuery({
|
||||
queryKey: ['app', appKey],
|
||||
queryFn: async ({ payload, signal }) => {
|
||||
queryFn: async ({ signal }) => {
|
||||
const { data } = await api.get(`/v1/apps/${appKey}`, {
|
||||
signal,
|
||||
});
|
||||
|
@@ -5,7 +5,7 @@ import api from 'helpers/api';
|
||||
export default function useAppAuth(appKey) {
|
||||
const query = useQuery({
|
||||
queryKey: ['appAuth', appKey],
|
||||
queryFn: async ({ payload, signal }) => {
|
||||
queryFn: async ({ signal }) => {
|
||||
const { data } = await api.get(`/v1/apps/${appKey}/auth`, {
|
||||
signal,
|
||||
});
|
||||
|
@@ -4,7 +4,7 @@ import api from 'helpers/api';
|
||||
export default function useAppConfig(appKey) {
|
||||
const query = useQuery({
|
||||
queryKey: ['appConfig', appKey],
|
||||
queryFn: async ({ payload, signal }) => {
|
||||
queryFn: async ({ signal }) => {
|
||||
const { data } = await api.get(`/v1/app-configs/${appKey}`, {
|
||||
signal,
|
||||
});
|
||||
|
@@ -3,11 +3,15 @@ import { useQuery } from '@tanstack/react-query';
|
||||
import api from 'helpers/api';
|
||||
|
||||
export default function useApps(variables) {
|
||||
const trueOnlyVariables = Object.fromEntries(
|
||||
Object.entries(variables).filter(([_, value]) => value === true),
|
||||
);
|
||||
|
||||
const query = useQuery({
|
||||
queryKey: ['apps', variables],
|
||||
queryFn: async ({ payload, signal }) => {
|
||||
queryKey: ['apps', trueOnlyVariables],
|
||||
queryFn: async ({ signal }) => {
|
||||
const { data } = await api.get('/v1/apps', {
|
||||
params: variables,
|
||||
params: trueOnlyVariables,
|
||||
signal,
|
||||
});
|
||||
|
||||
|
@@ -3,7 +3,7 @@ import { useMutation } from '@tanstack/react-query';
|
||||
import api from 'helpers/api';
|
||||
import React from 'react';
|
||||
|
||||
export default function useLazyApps({ appName, onSuccess }) {
|
||||
export default function useLazyApps({ appName } = {}, { onSuccess }) {
|
||||
const abortControllerRef = React.useRef(new AbortController());
|
||||
|
||||
React.useEffect(() => {
|
||||
@@ -15,7 +15,7 @@ export default function useLazyApps({ appName, onSuccess }) {
|
||||
}, [appName]);
|
||||
|
||||
const query = useMutation({
|
||||
mutationFn: async ({ payload }) => {
|
||||
mutationFn: async () => {
|
||||
const { data } = await api.get('/v1/apps', {
|
||||
params: { name: appName },
|
||||
signal: abortControllerRef.current.signal,
|
||||
|
@@ -2,10 +2,10 @@ import { useQuery } from '@tanstack/react-query';
|
||||
|
||||
import api from 'helpers/api';
|
||||
|
||||
export default function useTriggerSubsteps(appKey, triggerKey) {
|
||||
export default function useTriggerSubsteps({ appKey, triggerKey }) {
|
||||
const query = useQuery({
|
||||
queryKey: ['triggerSubsteps', appKey, triggerKey],
|
||||
queryFn: async ({ payload, signal }) => {
|
||||
queryFn: async ({ signal }) => {
|
||||
const { data } = await api.get(
|
||||
`/v1/apps/${appKey}/triggers/${triggerKey}/substeps`,
|
||||
{
|
||||
|
@@ -5,7 +5,7 @@ import api from 'helpers/api';
|
||||
export default function useTriggers(appKey) {
|
||||
const query = useQuery({
|
||||
queryKey: ['triggers', appKey],
|
||||
queryFn: async ({ payload, signal }) => {
|
||||
queryFn: async ({ signal }) => {
|
||||
const { data } = await api.get(`/v1/apps/${appKey}/triggers`, {
|
||||
signal,
|
||||
});
|
||||
|
Reference in New Issue
Block a user