Skip to content

Commit

Permalink
SDA-4427: Add fix to case of close and capture with sym hidden
Browse files Browse the repository at this point in the history
  • Loading branch information
NguyenTranHoangSym committed Jan 3, 2024
1 parent b28e896 commit f232099
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
8 changes: 5 additions & 3 deletions src/app/screen-snippet-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class ScreenSnippet {
hideOnCapture,
);
this.uploadSnippet(webContents, hideOnCapture);
this.closeSnippet();
this.closeSnippet(webContents);
this.copyToClipboard();
this.saveAs();
return;
Expand Down Expand Up @@ -355,22 +355,22 @@ class ScreenSnippet {
);
webContents.send('screen-snippet-data', payload);
winStore.restoreWindows(hideOnCapture);
webContents.focus();
await this.verifyAndUpdateAlwaysOnTop();
} catch (error) {
await this.verifyAndUpdateAlwaysOnTop();
logger.error(
`screen-snippet-handler: upload of screen capture failed with error: ${error}!`,
);
}
webContents.focus();
},
);
}

/**
* Close the current snippet
*/
private closeSnippet() {
private closeSnippet(webContents: WebContents) {
ipcMain.once(ScreenShotAnnotation.CLOSE, async (_event) => {
try {
windowHandler.closeSnippingToolWindow();
Expand All @@ -381,6 +381,8 @@ class ScreenSnippet {
`screen-snippet-handler: close window failed with error: ${error}!`,
);
}

webContents?.focus();
});
}

Expand Down
10 changes: 6 additions & 4 deletions src/app/stores/window-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f232099

Please sign in to comment.