Skip to content

Commit

Permalink
pdf-viewer: disable pdf-viewer window.
Browse files Browse the repository at this point in the history
Disable the pdf window for now since this is broken in v3
of electron.

Fixes zulip#640.
  • Loading branch information
vsvipul authored and akashnimare committed Feb 9, 2019
1 parent 9e33eba commit a2e8459
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 31 deletions.
50 changes: 25 additions & 25 deletions app/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,31 +198,31 @@ app.on('ready', () => {
app.quit();
});

// Show pdf in a new BrowserWindow
ipcMain.on('pdf-view', (event, url) => {
// Paddings for pdfWindow so that it fits into the main browserWindow
const paddingWidth = 55;
const paddingHeight = 22;

// Get the config of main browserWindow
const mainWindowState = global.mainWindowState;

// Window to view the pdf file
const pdfWindow = new electron.BrowserWindow({
x: mainWindowState.x + paddingWidth,
y: mainWindowState.y + paddingHeight,
width: mainWindowState.width - paddingWidth,
height: mainWindowState.height - paddingHeight,
webPreferences: {
plugins: true,
partition: 'persist:webviewsession'
}
});
pdfWindow.loadURL(url);

// We don't want to have the menu bar in pdf window
pdfWindow.setMenu(null);
});
// Code to show pdf in a new BrowserWindow (currently commented out due to bug-upstream)
// ipcMain.on('pdf-view', (event, url) => {
// // Paddings for pdfWindow so that it fits into the main browserWindow
// const paddingWidth = 55;
// const paddingHeight = 22;

// // Get the config of main browserWindow
// const mainWindowState = global.mainWindowState;

// // Window to view the pdf file
// const pdfWindow = new electron.BrowserWindow({
// x: mainWindowState.x + paddingWidth,
// y: mainWindowState.y + paddingHeight,
// width: mainWindowState.width - paddingWidth,
// height: mainWindowState.height - paddingHeight,
// webPreferences: {
// plugins: true,
// partition: 'persist:webviewsession'
// }
// });
// pdfWindow.loadURL(url);

// // We don't want to have the menu bar in pdf window
// pdfWindow.setMenu(null);
// });

// Reload full app not just webview, useful in debugging
ipcMain.on('reload-full-app', () => {
Expand Down
14 changes: 8 additions & 6 deletions app/renderer/js/components/handle-external-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,21 @@ function handleExternalLink(event) {
if (isWhiteListURL) {
event.preventDefault();

// Code to show pdf in a new BrowserWindow (currently commented out due to bug-upstream)
// Show pdf attachments in a new window

if (LinkUtil.isPDF(url) && isUploadsURL) {
ipcRenderer.send('pdf-view', url);
return;
}
// if (LinkUtil.isPDF(url) && isUploadsURL) {
// ipcRenderer.send('pdf-view', url);
// return;
// }

// download txt, mp3, mp4 etc.. by using downloadURL in the
// main process which allows the user to save the files to their desktop
// and not trigger webview reload while image in webview will
// do nothing and will not save it

if (!LinkUtil.isImage(url) && !LinkUtil.isPDF(url) && isUploadsURL) {
// Code to show pdf in a new BrowserWindow (currently commented out due to bug-upstream)
// if (!LinkUtil.isImage(url) && !LinkUtil.isPDF(url) && isUploadsURL) {
if (!LinkUtil.isImage(url) && isUploadsURL) {
ipcRenderer.send('downloadFile', url, downloadPath);
ipcRenderer.once('downloadFileCompleted', (event, filePath, fileName) => {
const downloadNotification = new Notification('Download Complete', {
Expand Down

0 comments on commit a2e8459

Please sign in to comment.