Inline
This commit is contained in:
parent
6f82881ac3
commit
550ad94257
1 changed files with 11 additions and 25 deletions
|
@ -485,6 +485,13 @@ async function getRenderableFileURL(
|
|||
originalFileURL: string,
|
||||
forceConvert: boolean,
|
||||
): Promise<SourceURLs> {
|
||||
const existingOrNewObjectURL = (convertedBlob: Blob) =>
|
||||
convertedBlob
|
||||
? convertedBlob === fileBlob
|
||||
? originalFileURL
|
||||
: URL.createObjectURL(convertedBlob)
|
||||
: undefined;
|
||||
|
||||
let srcURLs: SourceURLs["url"];
|
||||
let mimeType: string | undefined;
|
||||
switch (file.metadata.fileType) {
|
||||
|
@ -493,13 +500,9 @@ async function getRenderableFileURL(
|
|||
file.metadata.title,
|
||||
fileBlob,
|
||||
);
|
||||
const convertedURL = getFileObjectURL(
|
||||
originalFileURL,
|
||||
fileBlob,
|
||||
convertedBlob,
|
||||
);
|
||||
const convertedURL = existingOrNewObjectURL(convertedBlob);
|
||||
srcURLs = convertedURL;
|
||||
mimeType = convertedBlob.type;
|
||||
mimeType = convertedBlob?.type;
|
||||
break;
|
||||
}
|
||||
case FILE_TYPE.LIVE_PHOTO: {
|
||||
|
@ -516,13 +519,9 @@ async function getRenderableFileURL(
|
|||
fileBlob,
|
||||
forceConvert,
|
||||
);
|
||||
const convertedURL = getFileObjectURL(
|
||||
originalFileURL,
|
||||
fileBlob,
|
||||
convertedBlob,
|
||||
);
|
||||
const convertedURL = existingOrNewObjectURL(convertedBlob);
|
||||
srcURLs = convertedURL;
|
||||
mimeType = convertedBlob.type;
|
||||
mimeType = convertedBlob?.type;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
@ -551,19 +550,6 @@ async function getRenderableFileURL(
|
|||
};
|
||||
}
|
||||
|
||||
const getFileObjectURL = (
|
||||
originalFileURL: string,
|
||||
originalBlob: Blob,
|
||||
convertedBlob: Blob,
|
||||
) => {
|
||||
const convertedURL = convertedBlob
|
||||
? convertedBlob === originalBlob
|
||||
? originalFileURL
|
||||
: URL.createObjectURL(convertedBlob)
|
||||
: null;
|
||||
return convertedURL;
|
||||
};
|
||||
|
||||
async function getRenderableLivePhotoURL(
|
||||
file: EnteFile,
|
||||
fileBlob: Blob,
|
||||
|
|
Loading…
Add table
Reference in a new issue