Skip to content

Commit

Permalink
chore: staging bump 2024-11-15
Browse files Browse the repository at this point in the history
chore: staging bump 2024-11-15
  • Loading branch information
V-Gira authored Nov 15, 2024
2 parents 17b0441 + 599585b commit 3dc625b
Show file tree
Hide file tree
Showing 5 changed files with 170 additions and 137 deletions.
80 changes: 40 additions & 40 deletions electron/src/menu/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {config} from '../settings/config';
import {settings} from '../settings/ConfigurationPersistence';
import {SettingsType} from '../settings/SettingsType';
import {WindowManager} from '../window/WindowManager';
import {openExternal} from '../window/WindowUtil';
import {openExternal, sendToWebContents} from '../window/WindowUtil';

const launchCmd = process.env.APPIMAGE || process.execPath;

Expand Down Expand Up @@ -75,8 +75,8 @@ const aboutTemplate: MenuItemConstructorOptions = {
};

const signOutTemplate: MenuItemConstructorOptions = {
click: (_menuItem, browserWindow) =>
browserWindow?.webContents.send(EVENT_TYPE.UI.SYSTEM_MENU, EVENT_TYPE.ACTION.SIGN_OUT),
click: (_menuItem, baseWindow) =>
sendToWebContents(baseWindow, EVENT_TYPE.UI.SYSTEM_MENU, EVENT_TYPE.ACTION.SIGN_OUT),
label: locale.getText('menuSignOut'),
};

Expand All @@ -92,55 +92,55 @@ const conversationTemplate: MenuItemConstructorOptions = {
submenu: [
{
accelerator: 'CmdOrCtrl+N',
click: (_menuItem, browserWindow) =>
browserWindow?.webContents.send(EVENT_TYPE.UI.SYSTEM_MENU, EVENT_TYPE.CONVERSATION.START),
click: (_menuItem, baseWindow) =>
sendToWebContents(baseWindow, EVENT_TYPE.UI.SYSTEM_MENU, EVENT_TYPE.CONVERSATION.START),
label: locale.getText('menuStart'),
},
{
accelerator: 'CmdOrCtrl+K',
click: (_menuItem, browserWindow) =>
browserWindow?.webContents.send(EVENT_TYPE.UI.SYSTEM_MENU, EVENT_TYPE.CONVERSATION.SEARCH),
click: (_menuItem, baseWindow) =>
sendToWebContents(baseWindow, EVENT_TYPE.UI.SYSTEM_MENU, EVENT_TYPE.CONVERSATION.SEARCH),
label: locale.getText('menuSearch'),
},
separatorTemplate,
{
click: (_menuItem, browserWindow) =>
browserWindow?.webContents.send(EVENT_TYPE.UI.SYSTEM_MENU, EVENT_TYPE.CONVERSATION.PING),
click: (_menuItem, baseWindow) =>
sendToWebContents(baseWindow, EVENT_TYPE.UI.SYSTEM_MENU, EVENT_TYPE.CONVERSATION.PING),
label: locale.getText('menuPing'),
},
{
click: (_menuItem, browserWindow) =>
browserWindow?.webContents.send(EVENT_TYPE.UI.SYSTEM_MENU, EVENT_TYPE.CONVERSATION.CALL),
click: (_menuItem, baseWindow) =>
sendToWebContents(baseWindow, EVENT_TYPE.UI.SYSTEM_MENU, EVENT_TYPE.CONVERSATION.CALL),
label: locale.getText('menuCall'),
},
{
click: (_menuItem, browserWindow) =>
browserWindow?.webContents.send(EVENT_TYPE.UI.SYSTEM_MENU, EVENT_TYPE.CONVERSATION.VIDEO_CALL),
click: (_menuItem, baseWindow) =>
sendToWebContents(baseWindow, EVENT_TYPE.UI.SYSTEM_MENU, EVENT_TYPE.CONVERSATION.VIDEO_CALL),
label: locale.getText('menuVideoCall'),
},
separatorTemplate,
{
accelerator: 'CmdOrCtrl+I',
click: (_menuItem, browserWindow) =>
browserWindow?.webContents.send(EVENT_TYPE.UI.SYSTEM_MENU, EVENT_TYPE.CONVERSATION.PEOPLE),
click: (_menuItem, baseWindow) =>
sendToWebContents(baseWindow, EVENT_TYPE.UI.SYSTEM_MENU, EVENT_TYPE.CONVERSATION.PEOPLE),
label: locale.getText('menuPeople'),
},
{
accelerator: 'Shift+CmdOrCtrl+K',
click: (_menuItem, browserWindow) =>
browserWindow?.webContents.send(EVENT_TYPE.UI.SYSTEM_MENU, EVENT_TYPE.CONVERSATION.ADD_PEOPLE),
click: (_menuItem, baseWindow) =>
sendToWebContents(baseWindow, EVENT_TYPE.UI.SYSTEM_MENU, EVENT_TYPE.CONVERSATION.ADD_PEOPLE),
label: locale.getText('menuAddPeople'),
},
separatorTemplate,
{
accelerator: 'CmdOrCtrl+D',
click: (_menuItem, browserWindow) =>
browserWindow?.webContents.send(EVENT_TYPE.UI.SYSTEM_MENU, EVENT_TYPE.CONVERSATION.ARCHIVE),
click: (_menuItem, baseWindow) =>
sendToWebContents(baseWindow, EVENT_TYPE.UI.SYSTEM_MENU, EVENT_TYPE.CONVERSATION.ARCHIVE),
label: locale.getText('menuArchive'),
},
{
click: (_menuItem, browserWindow) =>
browserWindow?.webContents.send(EVENT_TYPE.UI.SYSTEM_MENU, EVENT_TYPE.CONVERSATION.DELETE),
click: (_menuItem, baseWindow) =>
sendToWebContents(baseWindow, EVENT_TYPE.UI.SYSTEM_MENU, EVENT_TYPE.CONVERSATION.DELETE),
label: locale.getText('menuDelete'),
},
],
Expand Down Expand Up @@ -188,34 +188,34 @@ const editTemplate: MenuItemConstructorOptions = {
submenu: [
{
accelerator: 'CmdOrCtrl+Z',
click: (_menuItem, browserWindow) => browserWindow?.webContents.send(EVENT_TYPE.EDIT.UNDO),
click: (_menuItem, baseWindow) => sendToWebContents(baseWindow, EVENT_TYPE.EDIT.UNDO),
label: locale.getText('menuUndo'),
},
{
accelerator: 'Shift+CmdOrCtrl+Z',
click: (_menuItem, browserWindow) => browserWindow?.webContents.send(EVENT_TYPE.EDIT.REDO),
click: (_menuItem, baseWindow) => sendToWebContents(baseWindow, EVENT_TYPE.EDIT.REDO),
label: locale.getText('menuRedo'),
},
separatorTemplate,
{
accelerator: 'CmdOrCtrl+X',
click: (_menuItem, browserWindow) => browserWindow?.webContents.send(EVENT_TYPE.EDIT.CUT),
click: (_menuItem, baseWindow) => sendToWebContents(baseWindow, EVENT_TYPE.EDIT.CUT),
label: locale.getText('menuCut'),
},
{
accelerator: 'CmdOrCtrl+C',
click: (_menuItem, browserWindow) => browserWindow?.webContents.send(EVENT_TYPE.EDIT.COPY),
click: (_menuItem, baseWindow) => sendToWebContents(baseWindow, EVENT_TYPE.EDIT.COPY),
label: locale.getText('menuCopy'),
},
{
accelerator: 'CmdOrCtrl+V',
click: (_menuItem, browserWindow) => browserWindow?.webContents.send(EVENT_TYPE.EDIT.PASTE),
click: (_menuItem, baseWindow) => sendToWebContents(baseWindow, EVENT_TYPE.EDIT.PASTE),
label: locale.getText('menuPaste'),
},
separatorTemplate,
{
accelerator: 'CmdOrCtrl+A',
click: (_menuItem, browserWindow) => browserWindow?.webContents.send(EVENT_TYPE.EDIT.SELECT_ALL),
click: (_menuItem, baseWindow) => sendToWebContents(baseWindow, EVENT_TYPE.EDIT.SELECT_ALL),
label: locale.getText('menuSelectAll'),
},
],
Expand All @@ -236,14 +236,14 @@ const windowTemplate: MenuItemConstructorOptions = {
separatorTemplate,
{
accelerator: EnvironmentUtil.platform.IS_MAC_OS ? 'Alt+Cmd+Up' : 'Alt+Shift+Up',
click: (_menuItem, browserWindow) =>
browserWindow?.webContents.send(EVENT_TYPE.UI.SYSTEM_MENU, EVENT_TYPE.CONVERSATION.SHOW_NEXT),
click: (_menuItem, baseWindow) =>
sendToWebContents(baseWindow, EVENT_TYPE.UI.SYSTEM_MENU, EVENT_TYPE.CONVERSATION.SHOW_NEXT),
label: locale.getText('menuNextConversation'),
},
{
accelerator: EnvironmentUtil.platform.IS_MAC_OS ? 'Alt+Cmd+Down' : 'Alt+Shift+Down',
click: (_menuItem, browserWindow) =>
browserWindow?.webContents.send(EVENT_TYPE.UI.SYSTEM_MENU, EVENT_TYPE.CONVERSATION.SHOW_PREVIOUS),
click: (_menuItem, baseWindow) =>
sendToWebContents(baseWindow, EVENT_TYPE.UI.SYSTEM_MENU, EVENT_TYPE.CONVERSATION.SHOW_PREVIOUS),
label: locale.getText('menuPreviousConversation'),
},
],
Expand Down Expand Up @@ -296,8 +296,8 @@ const darwinTemplate: MenuItemConstructorOptions = {
separatorTemplate,
{
accelerator: 'Command+,',
click: (_menuItem, browserWindow) =>
browserWindow?.webContents.send(EVENT_TYPE.UI.SYSTEM_MENU, EVENT_TYPE.PREFERENCES.SHOW),
click: (_menuItem, baseWindow) =>
sendToWebContents(baseWindow, EVENT_TYPE.UI.SYSTEM_MENU, EVENT_TYPE.PREFERENCES.SHOW),
label: locale.getText('menuPreferences'),
},
separatorTemplate,
Expand Down Expand Up @@ -337,8 +337,8 @@ const win32Template: MenuItemConstructorOptions = {
submenu: [
{
accelerator: 'Ctrl+,',
click: (_menuItem, browserWindow) =>
browserWindow?.webContents.send(EVENT_TYPE.UI.SYSTEM_MENU, EVENT_TYPE.PREFERENCES.SHOW),
click: (_menuItem, baseWindow) =>
sendToWebContents(baseWindow, EVENT_TYPE.UI.SYSTEM_MENU, EVENT_TYPE.PREFERENCES.SHOW),
label: locale.getText('menuSettings'),
},
localeTemplate,
Expand Down Expand Up @@ -429,8 +429,8 @@ export const createMenu = (isFullScreen: boolean): Menu => {

const muteShortcut: MenuItemConstructorOptions = {
accelerator: muteAccelerator,
click: (_menuItem, browserWindow) =>
browserWindow?.webContents.send(EVENT_TYPE.UI.SYSTEM_MENU, EVENT_TYPE.CONVERSATION.TOGGLE_MUTE),
click: (_menuItem, baseWindow) =>
sendToWebContents(baseWindow, EVENT_TYPE.UI.SYSTEM_MENU, EVENT_TYPE.CONVERSATION.TOGGLE_MUTE),
label: 'Toggle mute',
visible: false,
};
Expand All @@ -442,7 +442,7 @@ export const createMenu = (isFullScreen: boolean): Menu => {

return {
accelerator: switchAccelerator,
click: (_menuItem, browserWindow) => browserWindow?.webContents.send(EVENT_TYPE.ACTION.SWITCH_ACCOUNT, index),
click: (_menuItem, baseWindow) => sendToWebContents(baseWindow, EVENT_TYPE.ACTION.SWITCH_ACCOUNT, index),
label: `Switch to Account ${index + 1}`,
visible: false,
};
Expand All @@ -455,8 +455,8 @@ export const createMenu = (isFullScreen: boolean): Menu => {
if (Array.isArray(editTemplate.submenu)) {
editTemplate.submenu.push(separatorTemplate, {
accelerator: 'Ctrl+,',
click: (_menuItem, browserWindow) =>
browserWindow?.webContents.send(EVENT_TYPE.UI.SYSTEM_MENU, EVENT_TYPE.PREFERENCES.SHOW),
click: (_menuItem, baseWindow) =>
sendToWebContents(baseWindow, EVENT_TYPE.UI.SYSTEM_MENU, EVENT_TYPE.PREFERENCES.SHOW),
label: locale.getText('menuPreferences'),
});
}
Expand Down
9 changes: 5 additions & 4 deletions electron/src/preload/menu/preload-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
import {EVENT_TYPE} from '../../lib/eventType';
import * as locale from '../../locale';
import {config} from '../../settings/config';
import {sendToWebContents} from '../../window/WindowUtil';

const remote = require('@electron/remote');

Expand Down Expand Up @@ -72,25 +73,25 @@ const createTextMenu = (params: ContextMenuParams, webContents: WebContents): El

const template: MenuItemConstructorOptions[] = [
{
click: (_menuItem, browserWindow) => browserWindow?.webContents.send(EVENT_TYPE.EDIT.CUT),
click: (_menuItem, baseWindow) => sendToWebContents(baseWindow, EVENT_TYPE.EDIT.CUT),
enabled: editFlags.canCut,
label: locale.getText('menuCut'),
},
{
click: (_menuItem, browserWindow) => browserWindow?.webContents.send(EVENT_TYPE.EDIT.COPY),
click: (_menuItem, baseWindow) => sendToWebContents(baseWindow, EVENT_TYPE.EDIT.COPY),
enabled: editFlags.canCopy,
label: locale.getText('menuCopy'),
},
{
click: (_menuItem, browserWindow) => browserWindow?.webContents.send(EVENT_TYPE.EDIT.PASTE),
click: (_menuItem, baseWindow) => sendToWebContents(baseWindow, EVENT_TYPE.EDIT.PASTE),
enabled: editFlags.canPaste,
label: locale.getText('menuPaste'),
},
{
type: 'separator',
},
{
click: (_menuItem, browserWindow) => browserWindow?.webContents.send(EVENT_TYPE.EDIT.SELECT_ALL),
click: (_menuItem, baseWindow) => sendToWebContents(baseWindow, EVENT_TYPE.EDIT.SELECT_ALL),
enabled: editFlags.canSelectAll,
label: locale.getText('menuSelectAll'),
},
Expand Down
14 changes: 13 additions & 1 deletion electron/src/window/WindowUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*
*/

import {BrowserWindow, screen, shell} from 'electron';
import {BaseWindow, BrowserWindow, screen, shell} from 'electron';

import * as path from 'path';
import {URL} from 'url';
Expand Down Expand Up @@ -79,6 +79,18 @@ export const openExternal = async (url: string, httpsOnly: boolean = false): Pro
}
};

export const sendToWebContents = (baseWindow: BaseWindow | undefined, channel: string, ...args: any[]) => {
if (baseWindow instanceof BrowserWindow) {
try {
baseWindow.webContents.send(channel, ...args);
} catch (error) {
logger.error('Failed to send event to webContents', error);
}
} else {
logger.error("This action's target is not an instance of BrowserWindow.");
}
};

export const getNewWindowOptions = ({
parent,
title = '',
Expand Down
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"@hapi/joi": "17.1.1",
"@wireapp/certificate-check": "0.7.18",
"@wireapp/commons": "5.2.13",
"@wireapp/protocol-messaging": "1.50.0",
"@wireapp/react-ui-kit": "9.26.0",
"@wireapp/protocol-messaging": "1.51.0",
"@wireapp/react-ui-kit": "9.26.2",
"@wireapp/webapp-events": "0.24.3",
"auto-launch": "5.0.6",
"axios": "0.21.2",
Expand Down Expand Up @@ -55,7 +55,7 @@
"@types/lodash": "4.17.13",
"@types/minimist": "1.2.5",
"@types/mocha": "10.0.9",
"@types/node": "18.19.61",
"@types/node": "18.19.64",
"@types/open-graph": "0.2.5",
"@types/platform": "1.3.6",
"@types/prettier": "^2.7.3",
Expand All @@ -71,18 +71,18 @@
"@wireapp/eslint-config": "3.0.19",
"@wireapp/prettier-config": "0.6.4",
"adm-zip": "0.5.16",
"aws-sdk": "2.1691.0",
"aws-sdk": "2.1692.0",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "10.1.0",
"babel-jest": "29.7.0",
"babel-loader": "9.2.1",
"babel-plugin-istanbul": "6.1.1",
"commander": "12.1.0",
"core-js": "3.38.1",
"core-js": "3.39.0",
"cross-env": "7.0.3",
"css-loader": "7.1.2",
"dotenv": "16.4.5",
"electron": "29.4.6",
"electron": "33.2.0",
"electron-builder": "24.13.3",
"electron-mocha": "12.3.1",
"electron-packager": "17.1.2",
Expand All @@ -95,7 +95,7 @@
"eslint-plugin-header": "3.1.1",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jasmine": "4.2.2",
"eslint-plugin-jest": "28.8.3",
"eslint-plugin-jest": "28.9.0",
"eslint-plugin-jest-dom": "5.4.0",
"eslint-plugin-jsdoc": "48.11.0",
"eslint-plugin-jsx-a11y": "6.10.2",
Expand All @@ -112,8 +112,8 @@
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"lint-staged": "15.2.10",
"mocha": "10.8.1",
"nock": "13.5.5",
"mocha": "10.8.2",
"nock": "13.5.6",
"nyc": "15.1.0",
"prettier": "2.8.8",
"rimraf": "5.0.8",
Expand All @@ -122,7 +122,7 @@
"style-loader": "4.0.0",
"ts-node": "10.9.2",
"typescript": "5.6.3",
"webpack": "5.95.0",
"webpack": "5.96.1",
"webpack-cli": "5.1.4"
},
"homepage": "https://wire.com",
Expand Down
Loading

0 comments on commit 3dc625b

Please sign in to comment.