Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/wincloud_gateway/node_modules/react-query/es/react/ drwxr-xr-x | |
| Viewing file: Select action/file-type: import React from 'react';
import { notifyManager } from '../core/notifyManager';
import { useQueryErrorResetBoundary } from './QueryErrorResetBoundary';
import { useQueryClient } from './QueryClientProvider';
export function useBaseQuery(options, Observer) {
var mountedRef = React.useRef(false);
var _React$useState = React.useState(0),
forceUpdate = _React$useState[1];
var queryClient = useQueryClient();
var errorResetBoundary = useQueryErrorResetBoundary();
var defaultedOptions = queryClient.defaultQueryObserverOptions(options); // Make sure results are optimistically set in fetching state before subscribing or updating options
defaultedOptions.optimisticResults = true; // Include callbacks in batch renders
if (defaultedOptions.onError) {
defaultedOptions.onError = notifyManager.batchCalls(defaultedOptions.onError);
}
if (defaultedOptions.onSuccess) {
defaultedOptions.onSuccess = notifyManager.batchCalls(defaultedOptions.onSuccess);
}
if (defaultedOptions.onSettled) {
defaultedOptions.onSettled = notifyManager.batchCalls(defaultedOptions.onSettled);
}
if (defaultedOptions.suspense) {
// Always set stale time when using suspense to prevent
// fetching again when directly mounting after suspending
if (typeof defaultedOptions.staleTime !== 'number') {
defaultedOptions.staleTime = 1000;
}
}
if (defaultedOptions.suspense || defaultedOptions.useErrorBoundary) {
// Prevent retrying failed query if the error boundary has not been reset yet
if (!errorResetBoundary.isReset()) {
defaultedOptions.retryOnMount = false;
}
}
var obsRef = React.useRef();
if (!obsRef.current) {
obsRef.current = new Observer(queryClient, defaultedOptions);
}
var result = obsRef.current.getOptimisticResult(defaultedOptions);
React.useEffect(function () {
mountedRef.current = true;
errorResetBoundary.clearReset();
var unsubscribe = obsRef.current.subscribe(notifyManager.batchCalls(function () {
if (mountedRef.current) {
forceUpdate(function (x) {
return x + 1;
});
}
})); // Update result to make sure we did not miss any query updates
// between creating the observer and subscribing to it.
obsRef.current.updateResult();
return function () {
mountedRef.current = false;
unsubscribe();
};
}, [errorResetBoundary]);
React.useEffect(function () {
// Do not notify on updates because of changes in the options because
// these changes should already be reflected in the optimistic result.
obsRef.current.setOptions(defaultedOptions, {
listeners: false
});
}, [defaultedOptions]); // Handle suspense
if (defaultedOptions.suspense && result.isLoading) {
throw obsRef.current.fetchOptimistic(defaultedOptions).then(function (_ref) {
var data = _ref.data;
defaultedOptions.onSuccess == null ? void 0 : defaultedOptions.onSuccess(data);
defaultedOptions.onSettled == null ? void 0 : defaultedOptions.onSettled(data, null);
}).catch(function (error) {
errorResetBoundary.clearReset();
defaultedOptions.onError == null ? void 0 : defaultedOptions.onError(error);
defaultedOptions.onSettled == null ? void 0 : defaultedOptions.onSettled(undefined, error);
});
} // Handle error boundary
if ((defaultedOptions.suspense || defaultedOptions.useErrorBoundary) && result.isError) {
throw result.error;
} // Handle result property usage tracking
if (defaultedOptions.notifyOnChangeProps === 'tracked') {
result = obsRef.current.trackResult(result);
}
return result;
} |
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0212 ]-- |