fix: load missing assets when retrieving backup (#3192)
This commit is contained in:
parent
a4a721591f
commit
7d792f3005
@ -290,8 +290,17 @@ export function retrieveLocalBackup(collection: Collection, slug: string) {
|
||||
if (entry) {
|
||||
// load assets from backup
|
||||
const mediaFiles = entry.mediaFiles || [];
|
||||
const assetProxies: AssetProxy[] = mediaFiles.map(file =>
|
||||
createAssetProxy({ path: file.path, file: file.file, url: file.url }),
|
||||
const assetProxies: AssetProxy[] = await Promise.all(
|
||||
mediaFiles.map(file => {
|
||||
if (file.file || file.url) {
|
||||
return createAssetProxy({ path: file.path, file: file.file, url: file.url });
|
||||
} else {
|
||||
return getAsset({ collection, entry: fromJS(entry), path: file.path })(
|
||||
dispatch,
|
||||
getState,
|
||||
);
|
||||
}
|
||||
}),
|
||||
);
|
||||
dispatch(addAssets(assetProxies));
|
||||
|
||||
|
@ -450,7 +450,8 @@ export class Backend {
|
||||
// make sure to serialize the file
|
||||
if (file.url?.startsWith('blob:')) {
|
||||
const blob = await fetch(file.url as string).then(res => res.blob());
|
||||
return { ...file, file: new File([blob], file.name) };
|
||||
const options = file.name.match(/.svg$/) ? { type: 'image/svg+xml' } : {};
|
||||
return { ...file, file: new File([blob], file.name, options) };
|
||||
}
|
||||
return file;
|
||||
}),
|
||||
|
Loading…
x
Reference in New Issue
Block a user