mirror of
				https://github.com/zulip/zulip-desktop.git
				synced 2025-11-03 21:43:18 +00:00 
			
		
		
		
	Always show downloaded files in file manager.
shell.openItem is unsafe. Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
		@@ -13,7 +13,6 @@ export default function handleExternalLink(this: WebView, event: Electron.NewWin
 | 
			
		||||
	const { url } = event;
 | 
			
		||||
	const domainPrefix = DomainUtil.getDomain(this.props.index).url;
 | 
			
		||||
	const downloadPath = ConfigUtil.getConfigItem('downloadsPath', `${app.getPath('downloads')}`);
 | 
			
		||||
	const shouldShowInFolder = ConfigUtil.getConfigItem('showDownloadFolder', false);
 | 
			
		||||
 | 
			
		||||
	// Whitelist URLs which are allowed to be opened in the app
 | 
			
		||||
	const {
 | 
			
		||||
@@ -42,7 +41,7 @@ export default function handleExternalLink(this: WebView, event: Electron.NewWin
 | 
			
		||||
			ipcRenderer.send('downloadFile', url, downloadPath);
 | 
			
		||||
			ipcRenderer.once('downloadFileCompleted', (_event: Event, filePath: string, fileName: string) => {
 | 
			
		||||
				const downloadNotification = new Notification('Download Complete', {
 | 
			
		||||
					body: shouldShowInFolder ? `Click to show ${fileName} in folder` : `Click to open ${fileName}`,
 | 
			
		||||
					body: `Click to show ${fileName} in folder`,
 | 
			
		||||
					silent: true // We'll play our own sound - ding.ogg
 | 
			
		||||
				});
 | 
			
		||||
 | 
			
		||||
@@ -52,13 +51,8 @@ export default function handleExternalLink(this: WebView, event: Electron.NewWin
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				downloadNotification.addEventListener('click', () => {
 | 
			
		||||
					if (shouldShowInFolder) {
 | 
			
		||||
					// Reveal file in download folder
 | 
			
		||||
					shell.showItemInFolder(filePath);
 | 
			
		||||
					} else {
 | 
			
		||||
						// Open file in the default native app
 | 
			
		||||
						shell.openItem(filePath);
 | 
			
		||||
					}
 | 
			
		||||
				});
 | 
			
		||||
				ipcRenderer.removeAllListeners('downloadFileFailed');
 | 
			
		||||
			});
 | 
			
		||||
 
 | 
			
		||||
@@ -57,7 +57,6 @@ interface SettingsOptions {
 | 
			
		||||
		flashTaskbarOnMessage?: boolean;
 | 
			
		||||
	};
 | 
			
		||||
	downloadsPath: string;
 | 
			
		||||
	showDownloadFolder: boolean;
 | 
			
		||||
	quitOnClose: boolean;
 | 
			
		||||
	promptDownload: boolean;
 | 
			
		||||
	flashTaskbarOnMessage?: boolean;
 | 
			
		||||
@@ -206,7 +205,6 @@ class ServerManagerView {
 | 
			
		||||
				silent: false
 | 
			
		||||
			},
 | 
			
		||||
			downloadsPath: `${app.getPath('downloads')}`,
 | 
			
		||||
			showDownloadFolder: false,
 | 
			
		||||
			quitOnClose: false,
 | 
			
		||||
			promptDownload: false
 | 
			
		||||
		};
 | 
			
		||||
 
 | 
			
		||||
@@ -100,10 +100,6 @@ export default class GeneralSection extends BaseSection {
 | 
			
		||||
						<div class="setting-description">${t.__('Force social login in app instead of browser')}</div>
 | 
			
		||||
						<div class="setting-control"></div>
 | 
			
		||||
					</div>
 | 
			
		||||
					<div class="setting-row" id="show-download-folder">
 | 
			
		||||
						<div class="setting-description">${t.__('Show downloaded files in file manager')}</div>
 | 
			
		||||
						<div class="setting-control"></div>
 | 
			
		||||
					</div>
 | 
			
		||||
					<div class="setting-row" id="add-custom-css">
 | 
			
		||||
						<div class="setting-description">
 | 
			
		||||
							${t.__('Add custom CSS')}
 | 
			
		||||
@@ -164,7 +160,6 @@ export default class GeneralSection extends BaseSection {
 | 
			
		||||
		this.showCustomCSSPath();
 | 
			
		||||
		this.removeCustomCSS();
 | 
			
		||||
		this.downloadFolder();
 | 
			
		||||
		this.showDownloadFolder();
 | 
			
		||||
		this.updateQuitOnCloseOption();
 | 
			
		||||
		this.updatePromptDownloadOption();
 | 
			
		||||
		this.enableErrorReporting();
 | 
			
		||||
@@ -473,18 +468,6 @@ export default class GeneralSection extends BaseSection {
 | 
			
		||||
		});
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	showDownloadFolder(): void {
 | 
			
		||||
		this.generateSettingOption({
 | 
			
		||||
			$element: document.querySelector('#show-download-folder .setting-control'),
 | 
			
		||||
			value: ConfigUtil.getConfigItem('showDownloadFolder', false),
 | 
			
		||||
			clickHandler: () => {
 | 
			
		||||
				const newValue = !ConfigUtil.getConfigItem('showDownloadFolder');
 | 
			
		||||
				ConfigUtil.setConfigItem('showDownloadFolder', newValue);
 | 
			
		||||
				this.showDownloadFolder();
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	updatePromptDownloadOption(): void {
 | 
			
		||||
		this.generateSettingOption({
 | 
			
		||||
			$element: document.querySelector('#prompt-download .setting-control'),
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user