Skip to content

Commit

Permalink
chore: Update/electron 22.0.0 (RocketChat#2571)
Browse files Browse the repository at this point in the history
* change snapcraft login

* fix lint

* export SNAPCRAFT_STORE_CREDENTIALS

* install gnome-keyring

* try another thing

* chore: Update to electron 22

* lint fix
  • Loading branch information
jeanfbrito authored Dec 30, 2022
1 parent 5083326 commit 9d8363e
Show file tree
Hide file tree
Showing 4 changed files with 172 additions and 190 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"chokidar": "^3.5.3",
"conventional-changelog-cli": "^2.2.2",
"convert-svg-to-png": "^0.5.0",
"electron": "^17.4.11",
"electron": "^22.0.0",
"electron-builder": "^23.5.0",
"electron-devtools-installer": "^3.2.0",
"electron-notarize": "^1.2.1",
Expand Down
66 changes: 30 additions & 36 deletions src/ui/main/serverView/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ export const attachGuestWebContentsEvents = async (): Promise<void> => {
webPreferences.nodeIntegrationInSubFrames = false;
webPreferences.webSecurity = true;
webPreferences.contextIsolation = true;
webPreferences.sandbox = false;
};

const handleDidAttachWebview = (
Expand All @@ -187,54 +188,49 @@ export const attachGuestWebContentsEvents = async (): Promise<void> => {
setupPreloadReload(webContents);
}

webContents.addListener(
'new-window',
(
event,
url,
frameName,
disposition,
options,
_additionalFeatures,
referrer,
postBody
) => {
event.preventDefault();

if (
disposition === 'foreground-tab' ||
disposition === 'background-tab'
) {
isProtocolAllowed(url).then((allowed) => {
if (!allowed) {
return;
}
webContents.setWindowOpenHandler(({ url, frameName, disposition }) => {
if (
disposition === 'foreground-tab' ||
disposition === 'background-tab'
) {
isProtocolAllowed(url).then((allowed) => {
if (!allowed) {
return { action: 'deny' };
}

shell.openExternal(url);
});
return;
}
shell.openExternal(url);
return { action: 'deny' };
});
return { action: 'deny' };
}

const isVideoCall = frameName === 'Video Call';
const isVideoCall = frameName === 'Video Call';

const newWindow = new BrowserWindow({
return {
action: 'allow',
overrideBrowserWindowOptions: {
...(isVideoCall
? {
webPreferences: {
preload: path.join(app.getAppPath(), 'app/preload.js'),
},
}
: options),
: {}),
show: false,
});
},
};
});

newWindow.once('ready-to-show', () => {
newWindow.show();
webContents.addListener(
'did-create-window',
(window, { url, frameName, disposition, referrer, postBody }) => {
window.once('ready-to-show', () => {
window.show();
});

isProtocolAllowed(url).then((allowed) => {
if (!allowed) {
newWindow.destroy();
window.destroy();
return;
}

Expand All @@ -243,7 +239,7 @@ export const attachGuestWebContentsEvents = async (): Promise<void> => {
disposition === 'new-window' &&
new URL(url).hostname.match(/(\.)?google\.com$/);

newWindow.loadURL(url, {
window.loadURL(url, {
userAgent: isGoogleSignIn
? app.userAgentFallback
.replace(`Electron/${process.versions.electron} `, '')
Expand All @@ -258,8 +254,6 @@ export const attachGuestWebContentsEvents = async (): Promise<void> => {
}),
});
});

event.newGuest = newWindow;
}
);
};
Expand Down
9 changes: 8 additions & 1 deletion workspaces/desktop-release-action/src/linux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@ import { run, runElectronBuilder } from './shell';
export const setupSnapcraft = (): Promise<void> =>
core.group('Setup Snapcraft', async () => {
await run(`sudo snap install snapcraft --classic --channel stable`);
await run(`sudo apt install gnome-keyring`);
await run(`dbus-run-session -- bash --noprofile --norc`);
await run(`rm -rf ~/.local/share/keyrings`);
await run(`echo -n 'db' | gnome-keyring-daemon --unlock`);
await run(`echo /snap/bin >> ${process.env.GITHUB_PATH}`);
await run('sudo chown root:root /');

const snapcraftToken = core.getInput('snapcraft_token');
const snapcraftTokenFile = './snapcraft-token.txt';
await promises.writeFile(snapcraftTokenFile, snapcraftToken, 'utf-8');
await run(`/snap/bin/snapcraft login --with ${snapcraftTokenFile}`);
await run(
`export SNAPCRAFT_STORE_CREDENTIALS=$(cat ${snapcraftTokenFile})`
);
await run(`/snap/bin/snapcraft login`);
await promises.unlink(snapcraftTokenFile);
});

Expand Down
Loading

0 comments on commit 9d8363e

Please sign in to comment.