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

Fix drop image rotate wrong #2322

Merged
merged 2 commits into from
Sep 30, 2018
Merged

Conversation

youngyou
Copy link
Contributor

Fix drag-drop image rotate wrong, as Jordan Thornquest mentioned in slack

Fix drag-drop image rotate wrong, as Jordan Thornquest mentioned in slack
Copy link
Contributor

@ehhc ehhc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see my inline feedback..
Also: please add documentation and tests!

if (!fs.existsSync(sourceFilePath)) {
reject('source file does not exist')
const isBase64 = typeof sourceFilePath === 'object' && sourceFilePath.type === 'base64'
if (!fs.existsSync(sourceFilePath) && !isBase64) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you reject images that are not base64? e.g. i might drag&drop a pdf. Are all files always base64?!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only if the file not exists and the file is not a base64, reject.
In additional, I think you should add return before reject, the code should not run through if the file not exists.

Copy link
Contributor

@ehhc ehhc Aug 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but i mean what happens if you drop a PDF for example. Is that still possible with your changes? Or will it be rejected because it is not bas64?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch does nothing for other file. It will work same as before

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. And why don't you use something like this library instead of implementing it yourself? (tbh: first google result) https://www.npmjs.com/package/fix-orientation ??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has many dependencies, maybe we don't need to import so many code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @ehhc. This feature looks good to have. But I think it should not be included in the code base of boostnote. It is almost impossible to maintain...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we make a npm module for this? And, I think we need some test for this too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'll do it some days later.

@@ -12,6 +12,82 @@ const STORAGE_FOLDER_PLACEHOLDER = ':storage'
const DESTINATION_FOLDER = 'attachments'
const PATH_SEPARATORS = escapeStringRegexp(path.posix.sep) + escapeStringRegexp(path.win32.sep)

function getImage (file) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no documentation at all.
Nor are there any tests i see..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will add it later

})
}

function getOrientation (file) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me it seems like this method does a lot of black magic.. what are all the constants about? I have no idea how this method works, what it does and what it returns..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add comments later.

})
}

function fixRotate (file) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does it "fixes" the "wrong" rotation? I don't understand what might be wrong with it since i cannot reproduce the problem..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@youngyou
Copy link
Contributor Author

@ehhc comments added.

@ghost
Copy link

ghost commented Aug 22, 2018

I cannot replicate the issue. I am on 0.11.9.1 in Ubuntu 16.04

@youngyou
Copy link
Contributor Author

youngyou commented Aug 22, 2018

Try drop this image. It should be landscape. @modmod24

@ghost
Copy link

ghost commented Aug 22, 2018

ok, I see

@kazup01 kazup01 added the awaiting review ❇️ Pull request is awaiting a review. label Aug 27, 2018
@Rokt33r Rokt33r added next release (v0.11.10) and removed awaiting review ❇️ Pull request is awaiting a review. labels Sep 30, 2018
@Rokt33r Rokt33r merged commit 2ccd00a into BoostIO:master Sep 30, 2018
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

4 participants