-
Notifications
You must be signed in to change notification settings - Fork 1
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
#33 refactor method (linting, readability) #180
base: main
Are you sure you want to change the base?
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.
In the past, we've added information regarding refactorings to the Changelog. I think some relevant entries should be added here as well
🏓 @warm-coolguy
const mapContext = mapCanvas.getContext('2d') | ||
if (!mapContext) { | ||
console.error( | ||
'@polar/plugin-export: map does not of a 2d context, export failed.' |
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.
'@polar/plugin-export: map does not of a 2d context, export failed.' | |
'@polar/plugin-export: map does not have a 2d context, export failed.' |
Let's fix this while we are at it
matrix | ||
) | ||
mapContext.drawImage(canvas, 0, 0) | ||
} else console.warn('@polar/plugin-export: canvas width is 0') |
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.
} else console.warn('@polar/plugin-export: canvas width is 0') | |
} else console.warn('@polar/plugin-export: canvas width is 0.') |
link.click() | ||
document.body.removeChild(link) | ||
} | ||
if (download) downloadAsImage(src, type) |
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.
As I can' suggest it (deleted lines and such), here is what I would've anticipated:
if (
(type === ExportFormat.JPG || type === ExportFormat.PNG) &&
download
) {
downloadAsImage(src, type)
jsPdf.addImage(src, 'JPEG', 0, 0, dim[0], dim[1]) | ||
// Reset original map size | ||
map.setSize(size) | ||
map.getView().setResolution(map.getView().getResolution()) |
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 must've been a reason for the variable beforehand. Are you sure, this doesn't change anything? map.getSize()
is still set as a variable on the other hand.
Now that I think about it: What happens if neither the size of the map or the resolution is reset?
Summary
Improve readability of export implementation. Remove linting warning.
Instructions for local reproduction and review
Fiddle with export tool in snowbox to check some combinations. Snippet as reminder:
Relevant tickets, issues, et cetera
#33