Skip to content
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

Merged
merged 3 commits into from Apr 26, 2018
Merged

Fixed moving notes with images #1805

merged 3 commits into from Apr 26, 2018

Conversation

ghost
Copy link

@ghost ghost commented Apr 12, 2018

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.

@kazup01 kazup01 added the awaiting review ❇️ Pull request is awaiting a review. label Apr 13, 2018
@ehhc
Copy link
Contributor

ehhc commented Apr 23, 2018

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 :)

Copy link
Member

@sosukesuzuki sosukesuzuki left a 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:

@@ -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) {
Copy link
Member

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 ...

Copy link
Author

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.

@kazup01
Copy link
Member

kazup01 commented Apr 26, 2018

hey @sosukesuzuki , could you review it again?

@kazup01 kazup01 merged commit 25440a2 into BoostIO:master Apr 26, 2018
@kazup01
Copy link
Member

kazup01 commented Apr 26, 2018

Merged. Thank you for your awesome contribution @frankkanis :)

@kazup01 kazup01 added next release (v0.11.5) and removed awaiting review ❇️ Pull request is awaiting a review. labels Apr 26, 2018
@ghost ghost deleted the move-image-note-fix branch April 26, 2018 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants