Hi,
I have an Electron program that executes an Ionic app created with the tabs template.
This app shows two problems:
-Tabs
: the tab navigation buttons do not correspond to the page being displayed. That is, after changing sometimes the chosen tab, if I choose a tab another time, the correct page is displayed but, in the navigation bar, the chosen tab doesn’t change.
-Segments
: Changing a segment doesn’t work. That is if I choose another segment nothing happens.
If I execute the app in the browser with “ionic serve -lcs
” it works well.
Which could be the problem?
How can I debug it?
I’m using Electron 2.0.8 and Ionic 4.1.1.
Thank you
cld
I’ve found that the problem is in the file app.components.ts where I wrote:
platform.ready().then(() => {
statusBar.styleDefault();
splashScreen.hide();
this.settings.initLanguageSetting();
this.pages = [
{ title: 'Settings', component: SettingsPage },
];
if (settings.getIsDesktopApp()){
// Sono nell'App DESKTOP
this.settings.isUserLogged.subscribe((value) => {
if (true === value) {
this.nav.setRoot(TabsPage);
this.settings.isUserLogged.unsubscribe();
}
});
....
} else {
....
}
}
where settings.isUserLogged is defined as a Behaviour.
export class SettingsProvider {
....
public isUserLogged: BehaviorSubject<boolean> = new BehaviorSubject(false);
So something is wrong with the use of “this.settings.isUserLogged.subscribe
”.
I’ve to found another way to do this.
cld
I’ve solved in this way:
- I’ve removed the subscription to the
Behavior
in the file: app.components.ts replacing this code:
if (settings.getIsDesktopApp()){
// Sono nell'App DESKTOP
this.settings.isUserLogged.subscribe((value) => {
if (true === value) {
this.nav.setRoot(TabsPage);
this.settings.isUserLogged.unsubscribe();
}
with this code:
if (settings.getIsDesktopApp()){
this.nav.setRoot(TabsPage);
- I’ve used the behaviour in the costructor of the first page:
constructor(private settings:SettingsProvider,
private wsmanager: WsmanagerProvider,
private qrcodemanager: QrcodemanagerProvider) {
// Init data
console.log('DashboardPage constructor');
settings.isUserLogged.subscribe((value) => {
console.log('isUserLogged subscribe:', value);
if (true === value) {
this.getDashboardData();
this.getBannersData();
}
});
}
Now I haven’t problems with the navigation of Tabs and Segments.