forked from extern/bruno
feat: generate collection hash on the fly
This commit is contained in:
parent
4e16e954ef
commit
7f2e19250f
@ -3,6 +3,7 @@ const path = require('path');
|
|||||||
const { dialog, ipcMain } = require('electron');
|
const { dialog, ipcMain } = require('electron');
|
||||||
const Yup = require('yup');
|
const Yup = require('yup');
|
||||||
const { isDirectory, normalizeAndResolvePath } = require('../utils/filesystem');
|
const { isDirectory, normalizeAndResolvePath } = require('../utils/filesystem');
|
||||||
|
const { generateUidBasedOnHash } = require('../utils/common');
|
||||||
|
|
||||||
const uidSchema = Yup.string()
|
const uidSchema = Yup.string()
|
||||||
.length(21, 'uid must be 21 characters in length')
|
.length(21, 'uid must be 21 characters in length')
|
||||||
@ -11,7 +12,6 @@ const uidSchema = Yup.string()
|
|||||||
.strict();
|
.strict();
|
||||||
|
|
||||||
const configSchema = Yup.object({
|
const configSchema = Yup.object({
|
||||||
uid: uidSchema,
|
|
||||||
name: Yup.string().nullable().max(256, 'name must be 256 characters or less'),
|
name: Yup.string().nullable().max(256, 'name must be 256 characters or less'),
|
||||||
type: Yup.string().oneOf(['collection']).required('type is required'),
|
type: Yup.string().oneOf(['collection']).required('type is required'),
|
||||||
version: Yup.string().oneOf(['1']).required('type is required')
|
version: Yup.string().oneOf(['1']).required('type is required')
|
||||||
@ -65,12 +65,9 @@ const openCollection = async (win, watcher, collectionPath, options = {}) => {
|
|||||||
if(!watcher.hasWatcher(collectionPath)) {
|
if(!watcher.hasWatcher(collectionPath)) {
|
||||||
try {
|
try {
|
||||||
const {
|
const {
|
||||||
uid,
|
|
||||||
name
|
name
|
||||||
} = await getCollectionConfigFile(collectionPath);
|
} = await getCollectionConfigFile(collectionPath);
|
||||||
|
const uid = generateUidBasedOnHash(collectionPath);
|
||||||
console.log(uid);
|
|
||||||
console.log(name);
|
|
||||||
|
|
||||||
win.webContents.send('main:collection-opened', collectionPath, uid, name);
|
win.webContents.send('main:collection-opened', collectionPath, uid, name);
|
||||||
ipcMain.emit('main:collection-opened', win, collectionPath, uid);
|
ipcMain.emit('main:collection-opened', win, collectionPath, uid);
|
||||||
|
Loading…
Reference in New Issue
Block a user