3

Angular4 with @ng2-idle trying to capture the inactivity of the user.

code example link https://hackedbychinese.github.io/ng2-idle/

I am trying to customize it so every time user goes idle i show modal with ok button. and user will able to resume only ok is clicked on the modal.

on page load default interrupts are on

idle.setInterrupts(DEFAULT_INTERRUPTSOURCES); 

on idleStart i show my modal and count down begins on onIdleEnd i close my modal

when modal is open i want to disable DEFAULT_INTERRUPTSOURCES only manual interrupt so i called idle.clearInterrupts() and on modal ok press event calling idle.interrupt(true); once modal is close i set idle.setInterrupts(DEFAULT_INTERRUPTSOURCES); again.

does not seems to work very well. after modal close and open again it does not car about DEFAULT_INTERRUPTSOURCES and on setIdle time it goes automiticaly idle mode even though user interacts with the UI.

d-man
  • 57,473
  • 85
  • 212
  • 296
  • Hi, I am also facing with the same issue , How did you resolved it. please check this link https://stackoverflow.com/questions/57866420/ngidle-how-to-clear-and-reset-interrupts-in-angular – Roster Sep 10 '19 at 10:43

3 Answers3

0

When your modal is open better to call idle.stop() than clearing the DEFAULT_INTERRUPTSOURCES then on modal close call idle.watch()

0

Try

idle.clearInterrupts()

to solve this issue.

Mohammad Usman
  • 37,952
  • 20
  • 92
  • 95
Moses bendicion
  • 107
  • 3
  • 7
  • Hi Moses , I am also stuck on the same issue, In my case clearInterrupts() is working but unable to reset the interrupts . Please check this link https://stackoverflow.com/questions/57866420/ngidle-how-to-clear-and-reset-interrupts-in-angular – Roster Sep 10 '19 at 10:40
0

Hi the following worked for me.

On the open modal I clear the interrupts:

  ngOnInit() {
    this.idle.onTimeoutWarning.subscribe((countdown) => this.countdown = countdown);
    this.idle.clearInterrupts();
  }

and then when the continue button is clicked I reset the interrupts and start watching the idle again:

  continue() {
    this.idle.setInterrupts(DEFAULT_INTERRUPTSOURCES);
    this.idle.watch();
    this.dialog.close();
  }
ALB
  • 1