Merge branch 'develop' into anoa/jitsi_ptt

* develop: (47 commits)
  Translated using Weblate (Romanian)
  Translated using Weblate (Finnish)
  Translated using Weblate (Dutch)
  Added translation using Weblate (Slovenian)
  bump olm version
  Use a different cookie to expire any cookies people may already have
  Step cookie down to 4 hours
  Fix autolaunch setting appearing toggled off
  Expire mobile guide cookie after 24 hours
  Don't try to save files the user didn't want to save
  v1.0.6
  Prepare changelog for v1.0.6
  v1.0.6
  Released js-sdk & react-sdk, and bump electron version
  Deleted translation using Weblate (English (United Kingdom))
  Translated using Weblate (Italian)
  Translated using Weblate (Irish)
  Translated using Weblate (Finnish)
  Translated using Weblate (Esperanto)
  Translated using Weblate (English (United Kingdom))
  ...
This commit is contained in:
Andrew Morgan 2019-04-08 16:18:44 +01:00
commit c8a04cdfcc
23 changed files with 306 additions and 134 deletions

View file

@ -2,7 +2,7 @@
"name": "riot-web",
"productName": "Riot",
"main": "src/electron-main.js",
"version": "1.0.4",
"version": "1.0.6",
"description": "A feature-rich client for Matrix.org",
"author": "New Vector Ltd.",
"dependencies": {

View file

@ -140,7 +140,7 @@ ipcMain.on('ipcCall', async function(ev, payload) {
ret = autoUpdater.getFeedURL();
break;
case 'getAutoLaunchEnabled':
ret = launcher.isEnabled;
ret = await launcher.isEnabled();
break;
case 'setAutoLaunchEnabled':
if (args[0]) {

View file

@ -1,5 +1,7 @@
const {clipboard, nativeImage, Menu, MenuItem, shell} = require('electron');
const {clipboard, nativeImage, Menu, MenuItem, shell, dialog} = require('electron');
const url = require('url');
const fs = require('fs');
const request = require('request');
const MAILTO_PREFIX = "mailto:";
@ -47,6 +49,7 @@ function onLinkContextMenu(ev, params) {
}));
}
let addSaveAs = false;
if (params.mediaType && params.mediaType === 'image' && !url.startsWith('file://')) {
popupMenu.append(new MenuItem({
label: 'Copy image',
@ -58,6 +61,10 @@ function onLinkContextMenu(ev, params) {
}
},
}));
// We want the link to be ordered below the copy stuff, but don't want to duplicate
// the `if` statement, so use a flag.
addSaveAs = true;
}
// No point offering to copy a blob: URL either
@ -79,6 +86,36 @@ function onLinkContextMenu(ev, params) {
}));
}
}
if (addSaveAs) {
popupMenu.append(new MenuItem({
label: 'Save image as...',
click() {
const targetFileName = params.titleText || "image.png";
const filePath = dialog.showSaveDialog({
defaultPath: targetFileName,
});
if (!filePath) return; // user cancelled dialog
try {
if (url.startsWith("data:")) {
fs.writeFileSync(filePath, nativeImage.createFromDataURL(url));
} else {
request.get(url).pipe(fs.createWriteStream(filePath));
}
} catch (err) {
console.error(err);
dialog.showMessageBox({
type: "error",
title: "Failed to save image",
message: "The image failed to save",
});
}
},
}));
}
// popup() requires an options object even for no options
popupMenu.popup({});
ev.preventDefault();