fix: media library on reload (#3174)
This commit is contained in:
parent
b579489525
commit
4f5544287f
@ -313,12 +313,13 @@ export function deleteLocalBackup(collection: Collection, slug: string) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export function loadEntry(collection: Collection, slug: string) {
|
export function loadEntry(collection: Collection, slug: string) {
|
||||||
return (dispatch: ThunkDispatch<State, {}, AnyAction>, getState: () => State) => {
|
return async (dispatch: ThunkDispatch<State, {}, AnyAction>, getState: () => State) => {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const backend = currentBackend(state.config);
|
const backend = currentBackend(state.config);
|
||||||
|
await waitForMediaLibraryToLoad(dispatch, getState());
|
||||||
dispatch(entryLoading(collection, slug));
|
dispatch(entryLoading(collection, slug));
|
||||||
return backend
|
return backend
|
||||||
.getEntry(state, collection, slug)
|
.getEntry(getState(), collection, slug)
|
||||||
.then((loadedEntry: EntryValue) => {
|
.then((loadedEntry: EntryValue) => {
|
||||||
return dispatch(entryLoaded(collection, loadedEntry));
|
return dispatch(entryLoaded(collection, loadedEntry));
|
||||||
})
|
})
|
||||||
|
@ -147,10 +147,8 @@ export function loadMedia(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
dispatch(mediaLoading(page));
|
dispatch(mediaLoading(page));
|
||||||
return new Promise(resolve => {
|
|
||||||
setTimeout(
|
const loadFunction = () =>
|
||||||
() =>
|
|
||||||
resolve(
|
|
||||||
backend
|
backend
|
||||||
.getMedia()
|
.getMedia()
|
||||||
.then(files => dispatch(mediaLoaded(files)))
|
.then(files => dispatch(mediaLoaded(files)))
|
||||||
@ -162,11 +160,15 @@ export function loadMedia(
|
|||||||
} else {
|
} else {
|
||||||
dispatch(mediaLoadFailed());
|
dispatch(mediaLoadFailed());
|
||||||
}
|
}
|
||||||
}),
|
|
||||||
),
|
|
||||||
delay,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (delay > 0) {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
setTimeout(() => resolve(loadFunction()), delay);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return loadFunction();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user