diff --git a/js/koi/code/codeViewer.js b/js/koi/code/codeViewer.js index cedf9502..40fc7d37 100644 --- a/js/koi/code/codeViewer.js +++ b/js/koi/code/codeViewer.js @@ -55,7 +55,18 @@ CodeViewer.prototype.createButtonDownload = function(image, audio) { button.onclick = () => { audio.effectClick.play(); - image.toBlob(blob => this.storage.imageToFile(blob, this.DEFAULT_NAME)); + image.toBlob(blob => { + if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.saveImage) { + var reader = new FileReader(); + reader.readAsDataURL(blob); + reader.onloadend = function() { + var base64data = reader.result; + window.webkit.messageHandlers.saveImage.postMessage({blob: base64data}); + } + } else { + this.storage.imageToFile(blob, this.DEFAULT_NAME) + } + }); this.hide(); }; @@ -121,8 +132,12 @@ CodeViewer.prototype.createView = function(image, audio) { element.appendChild(image); element.appendChild(this.createButtonDownload(image, audio)); - if (this.storage.hasClipboard) - element.appendChild(this.createButtonCopy(image, audio)); + if (this.storage.hasClipboard) { + // Do not show the clipboard button if the image can be stored on the photo library. + if (!(window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.saveImage)) { + element.appendChild(this.createButtonCopy(image, audio)); + } + } element.addEventListener("mousedown", event => event.stopImmediatePropagation()); diff --git a/js/koi/gui/loader/loaderDiscord.js b/js/koi/gui/loader/loaderDiscord.js index 8b4e3d86..b5e7864f 100644 --- a/js/koi/gui/loader/loaderDiscord.js +++ b/js/koi/gui/loader/loaderDiscord.js @@ -31,7 +31,7 @@ LoaderDiscord.prototype.loadSVG = function() { if (window["require"]) { window["require"]("electron")["shell"]["openExternal"](this.URL); } else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.openDiscordHandler) { - window.webkit.messageHandlers.openDiscordHandler.postMessage({url: this.URL}); + window.webkit.messageHandlers.openDiscordHandler.postMessage({discordURL: this.URL}); } else { window.open(this.URL, "_blank"); }