plugged memory leaks

This commit is contained in:
Eugene Pankov
2021-05-13 16:40:23 +02:00
parent c98fd2042d
commit 5c22e22caa
18 changed files with 211 additions and 144 deletions

View File

@@ -1,8 +1,7 @@
import { Component, Input } from '@angular/core'
import { trigger, transition, style, animate } from '@angular/animations'
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
import { Subscription } from 'rxjs'
import { HotkeysService } from 'terminus-core'
import { HotkeysService, BaseComponent } from 'terminus-core'
const INPUT_TIMEOUT = 1000
@@ -36,11 +35,10 @@ const INPUT_TIMEOUT = 1000
]),
],
})
export class HotkeyInputModalComponent {
export class HotkeyInputModalComponent extends BaseComponent {
@Input() value: string[] = []
@Input() timeoutProgress = 0
private keySubscription: Subscription
private lastKeyEvent: number|null = null
private keyTimeoutInterval: number|null = null
@@ -48,8 +46,9 @@ export class HotkeyInputModalComponent {
private modalInstance: NgbActiveModal,
public hotkeys: HotkeysService,
) {
super()
this.hotkeys.clearCurrentKeystrokes()
this.keySubscription = hotkeys.key.subscribe((event) => {
this.subscribeUntilDestroyed(hotkeys.key, (event) => {
this.lastKeyEvent = performance.now()
this.value = this.hotkeys.getCurrentKeystrokes()
event.preventDefault()
@@ -75,10 +74,10 @@ export class HotkeyInputModalComponent {
}
ngOnDestroy (): void {
this.keySubscription.unsubscribe()
this.hotkeys.clearCurrentKeystrokes()
this.hotkeys.enable()
clearInterval(this.keyTimeoutInterval!)
super.ngOnDestroy()
}
close (): void {

View File

@@ -58,7 +58,7 @@ export class SettingsTabComponent extends BaseTabComponent {
&& config.store.appearance.tabsLocation !== 'top'
}
this.configSubscription = config.changed$.subscribe(onConfigChange)
this.configSubscription = this.subscribeUntilDestroyed(config.changed$, onConfigChange)
onConfigChange()
}

View File

@@ -9,6 +9,7 @@ import {
Platform,
isWindowsBuild,
WIN_BUILD_FLUENT_BG_SUPPORTED,
BaseComponent,
} from 'terminus-core'
@@ -17,7 +18,7 @@ import {
selector: 'window-settings-tab',
template: require('./windowSettingsTab.component.pug'),
})
export class WindowSettingsTabComponent {
export class WindowSettingsTabComponent extends BaseComponent {
screens: any[]
Platform = Platform
isFluentVibrancySupported = false
@@ -29,10 +30,11 @@ export class WindowSettingsTabComponent {
public zone: NgZone,
@Inject(Theme) public themes: Theme[],
) {
super()
this.screens = this.docking.getScreens()
this.themes = config.enabledServices(this.themes)
hostApp.displaysChanged$.subscribe(() => {
this.subscribeUntilDestroyed(hostApp.displaysChanged$, () => {
this.zone.run(() => this.screens = this.docking.getScreens())
})