Skip to content

Commit

Permalink
[desktop]: Fix auto resize window timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagohm committed Feb 29, 2024
1 parent f82c0f4 commit 2de3db1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion desktop/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class AppComponent implements AfterViewInit {
})

if (window.options.autoResizable !== false) {
setTimeout(() => this.electron.autoResizeWindow(), 250)
this.electron.autoResizeWindow()
}
}

Expand Down
2 changes: 1 addition & 1 deletion desktop/src/app/calculator/calculator.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,6 @@ export class CalculatorComponent {

formulaChanged() {
clearTimeout(this.autoResizeTimeout)
this.autoResizeTimeout = setTimeout(() => this.electron.autoResizeWindow(), 250)
this.autoResizeTimeout = this.electron.autoResizeWindow()
}
}
2 changes: 1 addition & 1 deletion desktop/src/app/framing/framing.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class FramingComponent implements AfterViewInit, OnDestroy {
this.hipsSurvey = this.hipsSurveys[0]
}

setTimeout(() => this.electron.autoResizeWindow(), 250)
this.electron.autoResizeWindow()

this.route.queryParams.subscribe(e => {
const data = JSON.parse(decodeURIComponent(e.data)) as FramingData
Expand Down
12 changes: 8 additions & 4 deletions desktop/src/shared/services/electron.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,15 @@ export class ElectronService {
this.send('WINDOW.RESIZE', Math.floor(size))
}

autoResizeWindow() {
const size = document.getElementsByTagName('app-root')[0]?.getBoundingClientRect()?.height
autoResizeWindow(timeout: number = 500): any {
if (timeout <= 0) {
const size = document.getElementsByTagName('app-root')[0]?.getBoundingClientRect()?.height

if (size > 0) {
this.resizeWindow(size)
if (size > 0) {
this.resizeWindow(size)
}
} else {
return setTimeout(() => this.autoResizeWindow(), timeout)
}
}

Expand Down

0 comments on commit 2de3db1

Please sign in to comment.