Ionic v3: Toggle Hide/Unhide Passwords works only after round-progress ends

Hello,

I got an app that works as a 2FA and I got an issue with the iOS platform.

  • When I toggle hide/unhide password, the ng-container changes only after the round-progress countdown ends (30 sec) and gets the next password from the database.

The problem is that this issue is only on iOS. On Android the ng-countainer changes on each toggle state, after you save and close the configuration page. So with the same code, on iOS I have to wait the counter to end and load the next password, after you switch the toggle hide/unhide password.

[list.html]

<ng-container *ngIf="cod.hide == 1"> 
     <p class="generatedCode">--- ---</p>
     <p class="nameCode">{{cod.title}}</p>
</ng-container>
<ng-container *ngIf="cod.hide == 0"> 
     <p class="generatedCode">{{cod.password}}</p>
     <p class="nameCode">{{cod.title}}</p>
</ng-container>

[list.ts]

presentPopover(myEvent) {
    let popover = this.popoverCtrl.create(PopoverComponent);
    popover.present({
      ev: myEvent
    });

    popover.onDidDismiss(data => {
      this.getHidePassword();
      this.changeClockColor();

      setTimeout(() =>{
        for(let item of this.passwords){
          item["hide"] = this.hidePassword;
        }
      }, 200);
    });
  }

[config.html]

<ion-toggle [(ngModel)]="hidePassword" [checked]="hidePassword" (ionChange)="toggleChange($event)"></ion-toggle>

[config.ts]

toggleChange($event){
    var check = 0;

    if($event.checked){
      check = 1;
    }

    this.database.setDataHide("hidePassword", check).then(() => {        
      console.log("Saved!");
    }).catch(e => console.log(e)); 
  }

Any suggestion on how to make the iOS version work like the Android version ? Or what should I check.

  • To hide/unhide ng-container (password) every time I change the hide/unhide toggle in config page. Not wait for the counter to end (and get the next password from the database).

Thank you in advance.

setTimeout, especially with a magic number like 200, makes me very suspicious. Why is that there?

I have no clue. If I remove it or set it to 0 the password disappears.–

So you inherited this code? Can you ask whoever put it there why it’s there?

Developer says that it should work in any platform.

  • On android, toggle works after i close the configuration page and password is been hidden immediately.
  • On iOS, password is been hidden after the counter ends and loads the next password.

Same list.ts and same config.ts

Any suggestion ? Anyone ?

As I haven’t found any solution on this, I removed the feature.

Marked this post as resolved.