FEAT: Reworked pop up notifications across all events
This commit is contained in:
+10
-4
@@ -4,7 +4,7 @@ import {
|
||||
basename as pathBasename,
|
||||
dirname as pathDirname
|
||||
} from '@tauri-apps/api/path';
|
||||
import { stat, mkdir, readDir, copyFile, rename, remove } from '@tauri-apps/plugin-fs';
|
||||
import { stat, mkdir, readDir, copyFile, rename, remove, exists } from '@tauri-apps/plugin-fs';
|
||||
import { open } from '@tauri-apps/plugin-dialog';
|
||||
import baseicon from '$lib/assets/baseicon.png';
|
||||
import europa from '$lib/assets/fonts/Europa-Mono-Medium.otf';
|
||||
@@ -124,19 +124,25 @@ export async function addTemplateFile(version, filePath) {
|
||||
const newFileName = await pathBasename(filePath);
|
||||
const templateName = newFileName.replace(/\.blend$/i, '');
|
||||
const newTemplatePath = await join(await getTemplatesDir(version), templateName);
|
||||
await ensureDirectory(newTemplatePath)
|
||||
|
||||
// Check for duplicate template name
|
||||
if (await exists(newTemplatePath)) {
|
||||
return { success: false, message: `Template "${templateName}" already exists` };
|
||||
}
|
||||
|
||||
const newTemplateFile = await join(newTemplatePath, 'startup.blend');
|
||||
await ensureDirectory(newTemplatePath);
|
||||
|
||||
try {
|
||||
await copyFile(filePath, newTemplateFile);
|
||||
} catch (error) {
|
||||
console.error('Error adding template file:', error);
|
||||
return;
|
||||
return { success: false, message: `Failed to add template: ${error.message || error}` };
|
||||
}
|
||||
|
||||
await getInstalledVersions();
|
||||
|
||||
console.log('adding ', filePath, ' to ', newTemplateFile);
|
||||
return { success: true, message: `Template "${templateName}" added` };
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user