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 electron context menu copy/save-as #96

Merged
merged 2 commits into from
Jun 1, 2020
Merged

Conversation

t3chguy
Copy link
Member

@t3chguy t3chguy commented May 31, 2020

Fixes element-hq/element-web#13845

We had a bunch of issues with the copy/save context menus we presented. The above being due to the showSaveDialog going async, instead of using the new showSaveDialogSync option I opted to switch it and the fs calls to async/await.

  • fixes save-as: awaits showSaveDialog
  • fixes save-as of data:// urls: by extracting the buffer from the nativeImage
  • hides the save-as option for blob: urls due to them only existing in the renderer process
  • uses fs.promises.writeFile instead of writeFileSync
  • cleans up the code a little
  • hides context menu for in-app icons like:
    image

I tried to (ab)use the clipboard for save-as on blob URLs and whilst it did work fundamentally, there was no way to accurately get the timing right. There is no way of knowing when copyImageAt is done and the clipboard is ready for us to read the image from.

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
@t3chguy t3chguy requested a review from a team May 31, 2020 11:29
@t3chguy t3chguy merged commit e56311f into develop Jun 1, 2020
@t3chguy t3chguy deleted the t3chguy/fix-save-as branch June 1, 2020 16: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.

Nightly: Right clicking an image -> Save image as = Error + Save dialog
2 participants