Coder Social home page Coder Social logo

Comments (2)

wescopeland avatar wescopeland commented on August 19, 2024

I actually got this to work pretty easily by making the following change:
https://github.com/wescopeland/ng-idle/commit/a4ed316c60f72abfb9bbf26482d40665dc13924c

Though I am not sure if this is the best approach.

from ng-idle.

moribvndvs avatar moribvndvs commented on August 19, 2024

There is a setting called autoResume. I think this feature got away from me, and how it works now is a bug or unexpected feature.

What I had intended is as follows:

  • When setting is true: If the user is currently idle and the user triggers an activeOn event, the idle state will automatically be reset. If the user is not idle, the activeOn event(s) will simply reset the idle timer.
    • The end result is a user will never see a $idleStart or $timeout event so long as they are active within the idle duration, as the timer will continuously be reset. If the user does go idle, but triggers activeOn, the idle state will be reset. This is useful if you want a passive and easy way of clearing dialogs, warnings, or errors.
  • When setting is false: If the user is currently idle and triggers an activeOn event, the idle state will not be reset. If the user is not idle, the activeOn event(s) will simply reset the idle timer.
    • The end result here is that once a user goes idle, they cannot come back to the non-idle state unless watch is called manually by your application. This is useful if you do not want users to be able to resume using the software once they go idle, or you require a specific action from the user (such as your scenario of requiring the user to enter a password).

The way it works now:

  • When setting is true: If the user is currently idle and an event is triggered, the idle state is reset. If the user is not idle, the timer is reset.
  • When the setting is false: The user cannot reset the idle state with an event. If the user is not idle, the timer is not reset and must be done so manually by calling watch.

If I were to fix it the way I described at the top, then you could set this to false, prompt the user for a password if they go idle, and then call watch when they enter the correct password. Otherwise, their normal non-idle activity will keep resetting the timeout and they can enjoy using the software without being any wiser.

Does that make sense?

from ng-idle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.