Auto redirect on no activity from a page

This one has me scratching my head. I am building a menu app to sit on my shop counter so customers can browse when I am busy. I need to redirect all pages to the main start page when there has been no activity on the app for 5 minutes.

I have the redirect working on a page with the following code in my ts file (short timeout just for testing).

I am struggling to find a way to clear the timeout when a user navigates away from the page. Everything I do seems to be either throwing an error or just not working. Any ideas? Or is there a better way of achieving this?

ngOnInit() {
setTimeout(() => {
}, 10000); //5s

A bit of an older post, but this has some stuff that could help here

As well as this

Now they’re talking about loggin out, but the same concepts can apply here.

1 Like