Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions desktop-app/.erb/scripts/delete-source-maps.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import path from 'path';
import rimraf from 'rimraf';

Check warning on line 2 in desktop-app/.erb/scripts/delete-source-maps.js

View workflow job for this annotation

GitHub Actions / test (macos-latest)

Using exported name 'rimraf' as identifier for default import
import webpackPaths from '../configs/webpack.paths';

export default function deleteSourceMaps() {
rimraf.sync(path.join(webpackPaths.distMainPath, '*.js.map'));
rimraf.sync(path.join(webpackPaths.distRendererPath, '*.js.map'));
rimraf.sync(path.join(webpackPaths.distMainPath, '*.js.map'), {glob: true});

Check warning on line 6 in desktop-app/.erb/scripts/delete-source-maps.js

View workflow job for this annotation

GitHub Actions / test (macos-latest)

Caution: `rimraf` also has a named export `sync`. Check if you meant to write `import {sync} from 'rimraf'` instead
rimraf.sync(path.join(webpackPaths.distRendererPath, '*.js.map'), {glob: true});

Check warning on line 7 in desktop-app/.erb/scripts/delete-source-maps.js

View workflow job for this annotation

GitHub Actions / test (macos-latest)

Caution: `rimraf` also has a named export `sync`. Check if you meant to write `import {sync} from 'rimraf'` instead
}
58 changes: 31 additions & 27 deletions desktop-app/src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,33 @@ let urlToOpen: string | undefined = cli.input[0]?.includes('electronmon')

let mainWindow: BrowserWindow | null = null;

const bringWindowToFront = (window: BrowserWindow) => {
if (window.isDestroyed()) {
return;
}

if (window.isMinimized()) {
window.restore();
}

window.show();
window.moveTop();
window.focus();
window.flashFrame(false);
};

const gotSingleInstanceLock = app.requestSingleInstanceLock();

if (!gotSingleInstanceLock) {
app.quit();
}

app.on('second-instance', () => {
if (mainWindow) {
bringWindowToFront(mainWindow);
}
});

initAppMetaHandlers();
initWebviewContextMenu();
initScreenshotHandlers();
Expand Down Expand Up @@ -158,30 +185,6 @@ const createWindow = async () => {
`${resolveHtmlPath('index.html')}?urlToOpen=${encodeURI(urlToOpen ?? 'undefined')}`
);

const isWindows = process.platform === 'win32';
let needsFocusFix = false;
let triggeringProgrammaticBlur = false;

mainWindow.on('blur', () => {
if (!triggeringProgrammaticBlur) {
needsFocusFix = true;
}
});

mainWindow.on('focus', () => {
if (isWindows && needsFocusFix) {
needsFocusFix = false;
triggeringProgrammaticBlur = true;
setTimeout(function () {
mainWindow!.blur();
mainWindow!.focus();
setTimeout(function () {
triggeringProgrammaticBlur = false;
}, 100);
}, 100);
}
});

mainWindow.on('ready-to-show', async () => {
if (!isAppInitiated) {
await initInstance();
Expand All @@ -199,12 +202,11 @@ const createWindow = async () => {
mainWindow.showInactive();
windowShownOnOpen = true;
} else {
mainWindow.showInactive();
if (!windowShownOnOpen) {
windowShownOnOpen = true;
mainWindow.show();
bringWindowToFront(mainWindow);
} else {
mainWindow.showInactive();
bringWindowToFront(mainWindow);
}
}
}
Expand Down Expand Up @@ -263,6 +265,7 @@ app.on('open-url', async (event, url) => {
}
windowShownOnOpen = false;
openUrl(actualURL, mainWindow);
bringWindowToFront(mainWindow);
});

/**
Expand Down Expand Up @@ -294,6 +297,7 @@ app
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) createWindow();
else bringWindowToFront(mainWindow);
});
})
.catch(console.log);
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ interface Props {
export const SettingsContent = ({onClose}: Props) => {
const id = useId();
const [screenshotSaveLocation, setScreenshotSaveLocation] = useState<string>(
window.electron.store.get('userPreferences.screenshot.saveLocation')
window.electron.store.get('userPreferences.screenshot.saveLocation') ?? ''
);
const [webRequestHeaderAcceptLanguage, setWebRequestHeaderAcceptLanguage] = useState<string>(
window.electron.store.get('userPreferences.webRequestHeaderAcceptLanguage')
window.electron.store.get('userPreferences.webRequestHeaderAcceptLanguage') ?? ''
);

const onSave = () => {
Expand Down
Loading