Page:afterin keeps reloading the page!?

I need to reload a page after it is loaded.
So in version 1 I used this and it worked fine.

myApp.onPageAfterAnimation(‘pushnotiser’, function (page) {
mainView.router.loadPage({url:“pushnotiser.asp?userId=1”,reload:true, ignoreCache: true});
});

So in version 2 I instead use “afterin” on the page like this and set that the navigate is reloadCurrent.

$$(document).on(‘page:afterin’, ‘.page[data-name=“pushnotiser”]’, function (e) {
var page = e.detail;

mainView.router.navigate("/pushnotiser/?userId=1",{reloadCurrent:true,ignoreCache: true});

});

And if I use this then it keeps reloading the page all the time!?

And if I use

$$(document).on(‘page:init’,…

then it is not working, I guess that it reloads it to soon for the userId variable to work.

I also tried to set a setTimeout function with

$$(document).on(‘page:init’, ‘.page[data-name=“pushnotiser”]’, function (e) {
var page = e.detail;
setTimeout(function(){
mainView.router.navigate("/pushnotiser/?userId=1",{reloadCurrent:true,ignoreCache: true});
},1500);
});

But this also just keeps reloading the page!?

So how can I reload the page after it is animated and visible?

It happens because reloading page is also triggers beforein/afterin callbacks. What is the point to load the page and reload it immediately?

When I load it I need to check in local storage what user it is using the app, and then send the userid to the page and reload it so I can get the right records from the database based on the userid.

Well, then you can try to check page data object and to,from,position, direction props. They will be different after reload, and don’t reload page again

But such logic sounds a bit wrong. How the user can be changed during the session, there shouldn’t be such opportunity. In case user is logged out, you probably must to remove all navigation and user related pages from app. Also if you have a lot of binding logic I highly recommend you to switch to the F7+Vue, you won’t need to do any reloads there

But I don´t understand why it is not getting the data from the local storage if I do it like this.
Should´t this, first get the local storage data and THEN navigate? And I use page:init

if(localStorage && localStorage.getItem(‘installningar’)){
var readinstallningar = JSON.parse(localStorage.getItem(“installningar”));
var appusersId = readinstallningar[“appusersId”];
mainView.router.navigate("/pushnotiser/?userId="+appusersId,{reloadCurrent:true,force:true, ignoreCache: true});

}

And even if I set the timeout around it all it is reloading the page over and over. So the timeout is not running just one time? Why is that?

$$(document).on(‘page:init’, ‘.page[data-name=“pushnotiser”]’, function (e) {
var page = e.detail;

setTimeout(function(){

if(localStorage && localStorage.getItem(‘installningar’)){
var readinstallningar = JSON.parse(localStorage.getItem(“installningar”));
var appusersId = readinstallningar[“appusersId”];

mainView.router.navigate("/pushnotiser/?userid="+appusersId+",{reloadCurrent:true,force:true, ignoreCache: true});

}
},1500);
});

Ok, just realize that it is running page:init every time I reloadCurrent, right!? And therefore it is running the settimeout all the time.

{
  path: '/pushnotiser/',
  async(routeTo,routeFrom,resole,reject){
    var id=localStorage.getItem("id");
    if (id) {
      resolve({ url: 'pushnotiser.asp?id='+id })
    } else {
      reject(); 
      //or
      //resolve({ url: 'login.html' })
    }
  }
}