* fix: on assetFormat undefined

* fix for multiple toasts

* refactor

* fix for tiff/tif files

* style: fix empty line
This commit is contained in:
alex-krasn 2020-07-15 15:31:27 -07:00 коммит произвёл GitHub
Родитель d8fa6141cf
Коммит 89be3ac5b6
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 9 добавлений и 6 удалений

Просмотреть файл

@ -42,8 +42,12 @@ const imageMimes: IMime[] = [
pattern: [0xff, 0xd8, 0xff],
},
{
types: ["tif", "tiff"],
pattern: [0x49, 0x49, 0x42, 0x00],
types: ["tif"],
pattern: [0x49, 0x49, 0x2a, 0x00],
},
{
types: ["tiff"],
pattern: [0x4d, 0x4d, 0x00, 0x2a],
},
{
types: ["pdf"],
@ -101,9 +105,8 @@ export class AssetService {
if (!types.includes(assetFormat)) {
assetFormat = types[0];
const corruptFileName = fileName.split("%2F").pop().replace(/%20/g, " ");
setTimeout(() => {
toast.info(`${strings.editorPage.assetWarning.incorrectFileExtension.attention} ${corruptFileName.toLocaleUpperCase()} ${strings.editorPage.assetWarning.incorrectFileExtension.text} ${corruptFileName.toLocaleUpperCase()}`);
}, 3000);
toast.info(`${strings.editorPage.assetWarning.incorrectFileExtension.attention} ${corruptFileName.toLocaleUpperCase()} ${strings.editorPage.assetWarning.incorrectFileExtension.text} ${corruptFileName.toLocaleUpperCase()}`, { delay: 3000 });
}
}
@ -125,7 +128,7 @@ export class AssetService {
* @param format - File extension of asset
*/
public static getAssetType(format: string): AssetType {
switch (format.toLowerCase()) {
switch (format?.toLowerCase()) {
case "jpg":
case "jpeg":
case "png":