-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
clone functionality in collection #1202
clone functionality in collection #1202
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome job on your first contribution! There are a couple of areas that need tweaks, but looks very good overall. Keep up the good work!
// clone collection | ||
ipcMain.handle( | ||
'renderer:clone-collection', | ||
async (event, collectionName, collectionFolderName, collectionLocation, perviousPath) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in perviousPath
|
||
await createDirectory(dirPath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better if you split the code into 3 or 4 logical parts / blocks by adding an empty line between them.
And remove the console.log's
await writeFile(path.join(dirPath, 'bruno.json'), cont); | ||
const files = searchForBruFiles(perviousPath); | ||
console.log(files); | ||
for (const sourceFilePath of files) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I missed that case to handle file dir to clone collection location
mainWindow.webContents.send('main:collection-opened', dirPath, uid, json); | ||
ipcMain.emit('main:collection-opened', mainWindow, dirPath, uid); | ||
} catch (error) { | ||
return Promise.reject(error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove the try/catch because you are not doing anything with the error here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I think I have copied the create collection code, but that is correct it do nothing.
return new Promise((resolve, reject) => { | ||
ipcRenderer | ||
.invoke('renderer:clone-collection', collectionName, collectionFolderName, collectionLocation, perviousPath) | ||
.then(resolve) | ||
.catch(reject); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can simplify this code here, ipcRenderer.invoke() already returns a promise.
return new Promise((resolve, reject) => { | |
ipcRenderer | |
.invoke('renderer:clone-collection', collectionName, collectionFolderName, collectionLocation, perviousPath) | |
.then(resolve) | |
.catch(reject); | |
}); | |
return ipcRenderer.invoke('renderer:clone-collection', collectionName, collectionFolderName, collectionLocation, perviousPath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have corrected this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, i think you need to look at this again. Now the modal always stays open, because the promise is never resolved.
I think this would make more sense:
export const cloneCollection = (collectionName, collectionFolderName, collectionLocation, perviousPath) => () => {
const { ipcRenderer } = window;
return ipcRenderer.invoke(
'renderer:clone-collection',
collectionName,
collectionFolderName,
collectionLocation,
perviousPath
);
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, now it is working fine
@helloanoop Can you please merge my PR. |
Merged! Nice work, @akshat-khosya ! |
Description
Issue: [Feature]-collection clone or duplicate feature/option is not available #156
I have created clone collection functionality. I just created new folder at user location and copied previous collection files.
Here is demo video of that.
Screencast from 11-12-23 02:11:38 AM IST.webm
Contribution Checklist:
Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.
Publishing to New Package Managers
Please see here for more information.