Fix media library loading and upload outside of collection

This commit is contained in:
Daniel Lautzenheiser
2022-10-31 14:01:03 -04:00
parent 22b395e170
commit de52e7c7d6
3 changed files with 6 additions and 13 deletions

View File

@ -293,14 +293,11 @@ export function persistMedia(file: File, opts: MediaOptions = {}) {
});
}
} else if (privateUpload) {
console.error('The Private Upload option is only available for Asset Store Integration')
throw new Error('The Private Upload option is only available for Asset Store Integration');
} else {
const entry = state.entryDraft.entry;
if (!entry?.collection) {
return;
}
const collection = state.collections[entry?.collection];
const collection = entry?.collection ? state.collections[entry.collection] : null;
const path = selectMediaFilePath(config, collection, entry, fileName, field);
assetProxy = createAssetProxy({
file,

View File

@ -346,18 +346,14 @@ function mediaLibrary(
export function selectMediaFiles(state: RootState, field?: Field): MediaFile[] {
const { mediaLibrary, entryDraft } = state;
if (!entryDraft.entry) {
return [];
}
const editingDraft = selectEditingDraft(entryDraft);
const integration = selectIntegration(state, null, 'assetStore');
let files: MediaFile[] = [];
if (editingDraft && !integration) {
const entryFiles = (get(entryDraft, ['entry', 'mediaFiles']) ?? []) as MediaFile[];
const entryFiles = entryDraft?.entry?.mediaFiles ?? [];
const entry = entryDraft['entry'];
const collection = state.collections[entry?.collection];
const collection = entry?.collection ? state.collections[entry.collection] : null;
if (state.config.config) {
const mediaFolder = selectMediaFolder(state.config.config, collection, entry, field);
files = entryFiles