Mentions légales du service

Skip to content
Snippets Groups Projects
Commit db35e23e authored by VIAUD Nathan's avatar VIAUD Nathan
Browse files

improvement(dev): normalize import behavior

parent 80621d01
Branches
Tags
No related merge requests found
Pipeline #963599 passed
......@@ -6,9 +6,10 @@ const AdmZip = require('adm-zip');
const glob = require('glob');
const { wait } = require('./utils');
const Store = require('electron-store');
const store = new Store();
const electronStore = new Store();
const store = require('./store');
const recentFiles = store.get('recentFiles', []).filter((r) => {
const recentFiles = electronStore.get('recentFiles', []).filter((r) => {
return fs.existsSync(r.filepath);
});
......@@ -131,31 +132,46 @@ const openEpocProject = async function (filepath) {
zip.extractAllTo(workdir, true, false, null);
if(!fs.existsSync(path.join(workdir, 'project.json'))) {
const project = await importEpoc(filepath, startTime, workdir);
store.updateState('projects', { [BrowserWindow.getFocusedWindow().id]: project });
console.log('filepath', filepath);
return {
project,
imported: true
};
}
} catch (err) {
console.log('error', err);
return null;
}
const project = {
name: path.basename(filepath),
modified: fs.statSync(filepath).mtime,
filepath,
workdir,
};
try {
// if extenions is .epoc rename it to .epocproject
if (path.extname(filepath) === '.epoc') {
const newFilepath = filepath.replace('.epoc', '.epocproject');
fs.renameSync(filepath, newFilepath);
updateRecent(project);
filepath = newFilepath;
}
const ellapsed = performance.now() - startTime;
if (ellapsed < 500) await wait(500 - ellapsed);
const project = {
name: path.basename(filepath),
modified: fs.statSync(filepath).mtime,
filepath,
workdir,
};
return {
project,
imported: false,
};
updateRecent(project);
const ellapsed = performance.now() - startTime;
if (ellapsed < 500) await wait(500 - ellapsed);
return {
project,
imported: false,
};
} catch(e) {
return null;
}
};
/**
......@@ -316,7 +332,7 @@ const updateRecent = function (project) {
} else {
recentFiles.unshift(project);
}
store.set('recentFiles', recentFiles);
electronStore.set('recentFiles', recentFiles);
};
/**
......
......@@ -4,9 +4,8 @@ import { useEditorStore, useGraphStore, useUndoRedoStore } from '@/src/shared/st
import { ePocProject } from '@/src/shared/interfaces';
import { createToaster } from '@meforma/vue-toaster';
import { closeFormPanel, graphService } from '.';
import { createGraphEpocFromData, createGraphFromImport } from '@/src/shared/services/import.service';
import { createGraphFromImport } from '@/src/shared/services/import.service';
import { useVueFlow } from '@vue-flow/core';
import { saveState } from '@/src/shared/services/undoRedo.service';
import { applyBackwardCompatibility } from '@/src/shared/utils/backwardCompability';
const { findNode } = useVueFlow({ id: 'main' });
......
......@@ -44,7 +44,7 @@ function importProject() {
@accept="importProject"
@cancel="cancelImport"
>
<h3>Cet ePoc est une publication, vous devez l'importer avant de pouvoir l'éditer ici</h3>
<h3>Cet ePoc est une version publiée, vous devez l'importer avant de pouvoir l'éditer ici</h3>
</ChoiceModal>
<div v-if="editorStore.loading" class="loading">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment