-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Fixed moving notes with images #1805
Conversation
I've submitted a fix for the problem based on the refactoring of the attachment management -> #1860 I think i've also fixed the issue you mentioned as 'limitation' with the fix :) |
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.
Please confirm my review!:smile:
browser/main/lib/dataApi/moveNote.js
Outdated
@@ -68,25 +68,29 @@ function moveNote (storageKey, noteKey, newStorageKey, newFolderKey) { | |||
return noteData | |||
}) | |||
.then(function moveImages (noteData) { | |||
const searchImagesRegex = /!\[.*?]\(\s*?\/:storage\/(.*\.\S*?)\)/gi | |||
let match = searchImagesRegex.exec(noteData.content) | |||
if (oldStorage.path === newStorage.path) { |
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 that we should reduce nests.
So I want you to use the style like this:
if (oldStorage.path === newStorage.path) return noteData
// next ...
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.
Thanks, great review! I like your solution, it is much cleaner.
hey @sosukesuzuki , could you review it again? |
Merged. Thank you for your awesome contribution @frankkanis :) |
Fixes #1788
How it works:
Moving note from one folder to another folder at the same storage -> don't touch the images
Moving note from one folder to another folder at different storages -> copy the images to the new storage, delete the images from the old storage
Limits:
If the same image is referenced in multiple notes at the old storage, moving only one note (with the image) will result in deleting the image at the old storage. But this is another bug.