Skip to content

Commit

Permalink
Merge pull request #52289 from allroundexperts/synk-fix-electron-upgrade
Browse files Browse the repository at this point in the history
feat: synk fix electron upgrade
  • Loading branch information
pecanoro authored Nov 11, 2024
2 parents 9e85b9f + ef8237f commit 9d8571b
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 34 deletions.
26 changes: 14 additions & 12 deletions desktop/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {app, BrowserWindow, clipboard, dialog, ipcMain, Menu, shell} from 'electron';
import type {BrowserView, MenuItem, MenuItemConstructorOptions, WebContents, WebviewTag} from 'electron';
import type {BaseWindow, BrowserView, MenuItem, MenuItemConstructorOptions, WebContents, WebviewTag} from 'electron';
import contextMenu from 'electron-context-menu';
import log from 'electron-log';
import type {ElectronLog} from 'electron-log';
Expand Down Expand Up @@ -47,6 +47,8 @@ function pasteAsPlainText(browserWindow: BrowserWindow | BrowserView | WebviewTa
const text = clipboard.readText();

if ('webContents' in browserWindow) {
// https://github.com/sindresorhus/electron-context-menu is passing in deprecated `BrowserView` to this function
// eslint-disable-next-line deprecation/deprecation
browserWindow.webContents.insertText(text);
}
}
Expand Down Expand Up @@ -107,7 +109,7 @@ process.argv.forEach((arg) => {
return;
}

expectedUpdateVersion = arg.substr(`${EXPECTED_UPDATE_VERSION_FLAG}=`.length);
expectedUpdateVersion = arg.slice(`${EXPECTED_UPDATE_VERSION_FLAG}=`.length);
});

// Add the listeners and variables required to ensure that auto-updating
Expand All @@ -132,7 +134,7 @@ const quitAndInstallWithUpdate = () => {
};

/** Menu Item callback to trigger an update check */
const manuallyCheckForUpdates = (menuItem?: MenuItem, browserWindow?: BrowserWindow) => {
const manuallyCheckForUpdates = (menuItem?: MenuItem, browserWindow?: BaseWindow) => {
if (menuItem) {
// Disable item until the check (and download) is complete
// eslint-disable-next-line no-param-reassign -- menu item flags like enabled or visible can be dynamically toggled by mutating the object
Expand Down Expand Up @@ -427,30 +429,30 @@ const mainWindow = (): Promise<void> => {
id: 'back',
accelerator: process.platform === 'darwin' ? 'Cmd+[' : 'Shift+[',
click: () => {
browserWindow.webContents.goBack();
browserWindow.webContents.navigationHistory.goBack();
},
},
{
label: 'backWithKeyShortcut',
visible: false,
accelerator: process.platform === 'darwin' ? 'Cmd+Left' : 'Shift+Left',
click: () => {
browserWindow.webContents.goBack();
browserWindow.webContents.navigationHistory.goBack();
},
},
{
id: 'forward',
accelerator: process.platform === 'darwin' ? 'Cmd+]' : 'Shift+]',
click: () => {
browserWindow.webContents.goForward();
browserWindow.webContents.navigationHistory.goForward();
},
},
{
label: 'forwardWithKeyShortcut',
visible: false,
accelerator: process.platform === 'darwin' ? 'Cmd+Right' : 'Shift+Right',
click: () => {
browserWindow.webContents.goForward();
browserWindow.webContents.navigationHistory.goForward();
},
},
],
Expand Down Expand Up @@ -507,7 +509,7 @@ const mainWindow = (): Promise<void> => {
const denial = {action: 'deny'} as const;

// Make sure local urls stay in electron perimeter
if (url.substr(0, 'file://'.length).toLowerCase() === 'file://') {
if (url.slice(0, 'file://'.length).toLowerCase() === 'file://') {
return denial;
}

Expand Down Expand Up @@ -539,19 +541,19 @@ const mainWindow = (): Promise<void> => {
// Initiating a browser-back or browser-forward with mouse buttons should navigate history.
browserWindow.on('app-command', (e, cmd) => {
if (cmd === 'browser-backward') {
browserWindow.webContents.goBack();
browserWindow.webContents.navigationHistory.goBack();
}
if (cmd === 'browser-forward') {
browserWindow.webContents.goForward();
browserWindow.webContents.navigationHistory.goForward();
}
});

browserWindow.on('swipe', (e, direction) => {
if (direction === 'left') {
browserWindow.webContents.goBack();
browserWindow.webContents.navigationHistory.goBack();
}
if (direction === 'right') {
browserWindow.webContents.goForward();
browserWindow.webContents.navigationHistory.goForward();
}
});

Expand Down
61 changes: 44 additions & 17 deletions desktop/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@
"csv-writer": "^1.6.0",
"diff-so-fancy": "^1.3.0",
"dotenv": "^16.0.3",
"electron": "^29.4.6",
"electron": "^32.2.3",
"electron-builder": "25.0.0",
"eslint": "^8.57.0",
"eslint-config-airbnb-typescript": "^18.0.0",
Expand Down

0 comments on commit 9d8571b

Please sign in to comment.