From 94da14fb10e17c99d26c2eb2425749755e4c5421 Mon Sep 17 00:00:00 2001 From: Jack <5182053+phyzical@users.noreply.github.com> Date: Thu, 4 May 2023 03:28:14 +0800 Subject: [PATCH] [PM-1144] Fix last active (auto logout issue) (#4835) * replicate the recordActivity function everytime a successful login occurs * rejig the exisiting recordActivity function to use state service for lastActive value * revert change and just use onblur instead * Update apps/browser/src/background/main.background.ts * insted of bluring, pipe up unlocked message to update lastActive * remove pingpong, use subscribe to update last active * Update apps/browser/src/popup/app.component.ts Co-authored-by: Matt Gibson * add missing imports --------- Co-authored-by: Matt Gibson Co-authored-by: Matt Gibson --- apps/browser/src/popup/app.component.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/browser/src/popup/app.component.ts b/apps/browser/src/popup/app.component.ts index 1f4ddfc36c..d9dc602a0c 100644 --- a/apps/browser/src/popup/app.component.ts +++ b/apps/browser/src/popup/app.component.ts @@ -9,7 +9,7 @@ import { import { DomSanitizer } from "@angular/platform-browser"; import { NavigationEnd, Router, RouterOutlet } from "@angular/router"; import { IndividualConfig, ToastrService } from "ngx-toastr"; -import { Subject, takeUntil } from "rxjs"; +import { filter, concatMap, Subject, takeUntil } from "rxjs"; import Swal from "sweetalert2"; import { DialogServiceAbstraction, SimpleDialogOptions } from "@bitwarden/angular/services/dialog"; @@ -62,6 +62,16 @@ export class AppComponent implements OnInit, OnDestroy { this.activeUserId = userId; }); + this.stateService.activeAccountUnlocked$ + .pipe( + filter((unlocked) => unlocked), + concatMap(async () => { + await this.recordActivity(); + }), + takeUntil(this.destroy$) + ) + .subscribe(); + this.ngZone.runOutsideAngular(() => { window.onmousedown = () => this.recordActivity(); window.ontouchstart = () => this.recordActivity();