mirror of
https://github.com/strapi/strapi.git
synced 2025-09-18 21:08:54 +00:00
Fix double fetch assets
This commit is contained in:
parent
07045008a4
commit
433ec9a04b
@ -9,7 +9,7 @@ export const useAssets = ({ skipWhen }) => {
|
|||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
const toggleNotification = useNotification();
|
const toggleNotification = useNotification();
|
||||||
const { notifyStatus } = useNotifyAT();
|
const { notifyStatus } = useNotifyAT();
|
||||||
const [{ rawQuery, query }, setQuery] = useQueryParams();
|
const [{ rawQuery }] = useQueryParams();
|
||||||
const dataRequestURL = getRequestUrl('files');
|
const dataRequestURL = getRequestUrl('files');
|
||||||
|
|
||||||
const getAssets = async () => {
|
const getAssets = async () => {
|
||||||
@ -24,12 +24,6 @@ export const useAssets = ({ skipWhen }) => {
|
|||||||
cacheTime: 0,
|
cacheTime: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!query) {
|
|
||||||
setQuery({ sort: 'updatedAt:DESC', page: 1, pageSize: 10 });
|
|
||||||
}
|
|
||||||
}, [query, setQuery]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (data) {
|
if (data) {
|
||||||
notifyStatus(
|
notifyStatus(
|
||||||
|
@ -1,8 +1,17 @@
|
|||||||
import React from 'react';
|
import React, { useEffect } from 'react';
|
||||||
|
import { useQueryParams } from '@strapi/helper-plugin';
|
||||||
import { MediaLibrary } from './MediaLibrary';
|
import { MediaLibrary } from './MediaLibrary';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
return <MediaLibrary />;
|
const [{ rawQuery }, setQuery] = useQueryParams();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!rawQuery) {
|
||||||
|
setQuery({ sort: 'updatedAt:DESC', page: 1, pageSize: 10 });
|
||||||
|
}
|
||||||
|
}, [rawQuery, setQuery]);
|
||||||
|
|
||||||
|
return rawQuery ? <MediaLibrary /> : null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default App;
|
export default App;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user