[bug] Attempt to resolve windows portable build issues (#1280)

This commit is contained in:
Addison Beck 2022-02-02 10:28:36 -05:00 committed by GitHub
parent 270411dff7
commit cad6e9481f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 10 deletions

View File

@ -96,6 +96,7 @@ export class AppComponent implements OnInit {
private modal: ModalRef = null; private modal: ModalRef = null;
private idleTimer: number = null; private idleTimer: number = null;
private isIdle = false; private isIdle = false;
private activeUserId: string = null;
constructor( constructor(
private broadcasterService: BroadcasterService, private broadcasterService: BroadcasterService,
@ -128,21 +129,18 @@ export class AppComponent implements OnInit {
) {} ) {}
ngOnInit() { ngOnInit() {
let activeUserId: string = null;
this.stateService.activeAccount.subscribe((userId) => { this.stateService.activeAccount.subscribe((userId) => {
activeUserId = userId; this.activeUserId = userId;
}); });
this.ngZone.runOutsideAngular(() => { this.ngZone.runOutsideAngular(() => {
setTimeout(async () => { setTimeout(async () => {
await this.updateAppMenu(); await this.updateAppMenu();
}, 1000); }, 1000);
if (activeUserId != null) { window.ontouchstart = () => this.recordActivity();
window.ontouchstart = () => this.recordActivity(activeUserId); window.onmousedown = () => this.recordActivity();
window.onmousedown = () => this.recordActivity(activeUserId); window.onscroll = () => this.recordActivity();
window.onscroll = () => this.recordActivity(activeUserId); window.onkeypress = () => this.recordActivity();
window.onkeypress = () => this.recordActivity(activeUserId);
}
}); });
this.broadcasterService.subscribe(BroadcasterSubscriptionId, async (message: any) => { this.broadcasterService.subscribe(BroadcasterSubscriptionId, async (message: any) => {
@ -498,14 +496,18 @@ export class AppComponent implements OnInit {
await this.updateAppMenu(); await this.updateAppMenu();
} }
private async recordActivity(userId: string) { private async recordActivity() {
if (this.activeUserId == null) {
return;
}
const now = new Date().getTime(); const now = new Date().getTime();
if (this.lastActivity != null && now - this.lastActivity < 250) { if (this.lastActivity != null && now - this.lastActivity < 250) {
return; return;
} }
this.lastActivity = now; this.lastActivity = now;
await this.stateService.setLastActive(now, { userId: userId }); await this.stateService.setLastActive(now, { userId: this.activeUserId });
// Idle states // Idle states
if (this.isIdle) { if (this.isIdle) {