[MM-63842] Upgrade to Electron v35.2.0 (#3398)

This commit is contained in:
Devin Binnie
2025-04-22 09:15:54 -04:00
committed by GitHub
parent e147f56492
commit 54874ecaca
9 changed files with 35 additions and 73 deletions

View File

@@ -100,7 +100,7 @@ export function showBadgeOSX(sessionExpired: boolean, mentionCount: number, show
} else if (sessionExpired) {
badge = '!';
}
app.dock.setBadge(badge);
app.dock?.setBadge(badge);
}
function showBadgeLinux(sessionExpired: boolean, mentionCount: number) {

View File

@@ -402,7 +402,7 @@ describe('main/notifications', () => {
Object.defineProperty(process, 'platform', {
value: originalPlatform,
});
expect(app.dock.bounce).not.toBeCalled();
expect(app.dock!.bounce).not.toBeCalled();
});
it('mac - should bounce icon when config item is set', async () => {
@@ -428,7 +428,7 @@ describe('main/notifications', () => {
Object.defineProperty(process, 'platform', {
value: originalPlatform,
});
expect(app.dock.bounce).toHaveBeenCalledWith('critical');
expect(app.dock!.bounce).toHaveBeenCalledWith('critical');
});
});

View File

@@ -267,7 +267,7 @@ function flashFrame(flash: boolean) {
}
}
if (process.platform === 'darwin' && Config.notifications.bounceIcon && Config.notifications.bounceIconType) {
app.dock.bounce(Config.notifications.bounceIconType);
app.dock?.bounce(Config.notifications.bounceIconType);
}
}

View File

@@ -164,8 +164,8 @@ export class PerformanceMonitor {
}
};
private handleSpeedLimitChange = (limit: number) => {
if (limit < 100) {
private handleSpeedLimitChange = (details: {limit: number}) => {
if (details.limit < 100) {
this.stop();
} else {
this.start();

View File

@@ -226,26 +226,26 @@ describe('main/views/webContentsEvents', () => {
});
it('should respect logging levels', () => {
consoleMessage({}, 0, 'test0', 0, '');
consoleMessage({level: 'info', message: 'test0', lineNumber: 0, sourceId: ''});
expect(logObject.debug).toHaveBeenCalledWith('test0');
consoleMessage({}, 1, 'test1', 0, '');
consoleMessage({level: 'info', message: 'test1', lineNumber: 0, sourceId: ''});
expect(logObject.debug).toHaveBeenCalledWith('test1');
consoleMessage({}, 2, 'test2', 0, '');
consoleMessage({level: 'warning', message: 'test2', lineNumber: 0, sourceId: ''});
expect(logObject.warn).toHaveBeenCalledWith('test2');
consoleMessage({}, 3, 'test3', 0, '');
consoleMessage({level: 'error', message: 'test3', lineNumber: 0, sourceId: ''});
expect(logObject.error).toHaveBeenCalledWith('test3');
});
it('should only add line numbers for debug and silly', () => {
getLevel.mockReturnValue('debug');
consoleMessage({}, 0, 'test1', 42, 'meaning_of_life.js');
consoleMessage({level: 'info', message: 'test1', lineNumber: 42, sourceId: 'meaning_of_life.js'});
expect(logObject.debug).toHaveBeenCalledWith('test1', '(meaning_of_life.js:42)');
getLevel.mockReturnValue('warn');
consoleMessage({}, 0, 'test2', 42, 'meaning_of_life.js');
consoleMessage({level: 'info', message: 'test2', lineNumber: 42, sourceId: 'meaning_of_life.js'});
expect(logObject.warn).not.toHaveBeenCalledWith('test2', '(meaning_of_life.js:42)');
});
});

View File

@@ -2,36 +2,29 @@
// See LICENSE.txt for license information.
import path from 'path';
import type {Event} from 'electron';
import type {Event, WebContentsConsoleMessageEventParams} from 'electron';
import type {Logger} from 'common/log';
import {getLevel} from 'common/log';
import {protocols} from '../../../electron-builder.json';
enum ConsoleMessageLevel {
Verbose,
Info,
Warning,
Error
}
export const generateHandleConsoleMessage = (log: Logger) => (_: Event, level: number, message: string, line: number, sourceId: string) => {
export const generateHandleConsoleMessage = (log: Logger) => (event: Event<WebContentsConsoleMessageEventParams>) => {
const wcLog = log.withPrefix('renderer');
let logFn = wcLog.debug;
switch (level) {
case ConsoleMessageLevel.Error:
switch (event.level) {
case 'error':
logFn = wcLog.error;
break;
case ConsoleMessageLevel.Warning:
case 'warning':
logFn = wcLog.warn;
break;
}
// Only include line entries if we're debugging
const entries = [message];
const entries = [event.message];
if (['debug', 'silly'].includes(getLevel())) {
entries.push(`(${path.basename(sourceId)}:${line})`);
entries.push(`(${path.basename(event.sourceId)}:${event.lineNumber})`);
}
logFn(...entries);