Merge pull request #2050 from NguyenTranHoangSym/SDA-4427

SDA-4427: Add fix to case of close and capture with sym hidden
This commit is contained in:
NguyenTranHoangSym 2024-01-03 16:15:14 +07:00 committed by GitHub
commit b16c6e4bbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 7 deletions

View File

@ -187,7 +187,7 @@ class ScreenSnippet {
hideOnCapture,
);
this.uploadSnippet(webContents, hideOnCapture);
this.closeSnippet();
this.closeSnippet(webContents);
this.copyToClipboard();
this.saveAs();
return;
@ -355,7 +355,6 @@ class ScreenSnippet {
);
webContents.send('screen-snippet-data', payload);
winStore.restoreWindows(hideOnCapture);
webContents.focus();
await this.verifyAndUpdateAlwaysOnTop();
} catch (error) {
await this.verifyAndUpdateAlwaysOnTop();
@ -363,6 +362,7 @@ class ScreenSnippet {
`screen-snippet-handler: upload of screen capture failed with error: ${error}!`,
);
}
webContents.focus();
},
);
}
@ -370,7 +370,7 @@ class ScreenSnippet {
/**
* Close the current snippet
*/
private closeSnippet() {
private closeSnippet(webContents: WebContents) {
ipcMain.once(ScreenShotAnnotation.CLOSE, async (_event) => {
try {
windowHandler.closeSnippingToolWindow();
@ -381,6 +381,8 @@ class ScreenSnippet {
`screen-snippet-handler: close window failed with error: ${error}!`,
);
}
webContents?.focus();
});
}

View File

@ -77,15 +77,17 @@ export class WindowStore {
if (hideOnCapture) {
this.restoreNotificationProperties();
const storedWindows = this.getWindowStore();
let currentWindow = storedWindows.windows.find(
let _currentWindow = storedWindows.windows.find(
(currentWindow) => currentWindow.focused,
);
if (!currentWindow) {
if (!_currentWindow) {
// In case there is no window focused, we automatically focus on the main one.
currentWindow = storedWindows.windows.find(
_currentWindow = storedWindows.windows.find(
(currentWindow) => currentWindow.id === 'main',
);
currentWindow!.focused = true;
if (_currentWindow) {
_currentWindow!.focused = true;
}
}
let focusedWindowToRestore: ICustomBrowserWindow | undefined;