MOBILE-3081 login: Show download button on version check

main
Pau Ferrer Ocaña 2019-08-01 10:04:32 +02:00
parent a73f340cd7
commit aca09a2dc2
6 changed files with 31 additions and 12 deletions

View File

@ -220,6 +220,9 @@ export class CoreLoginCredentialsPage {
}); });
}).catch((error) => { }).catch((error) => {
this.loginHelper.treatUserTokenError(siteUrl, error, username, password); this.loginHelper.treatUserTokenError(siteUrl, error, username, password);
if (error.loggedout) {
this.navCtrl.setRoot('CoreLoginSitesPage');
}
}).finally(() => { }).finally(() => {
modal.dismiss(); modal.dismiss();
}); });

View File

@ -94,14 +94,8 @@ export class CoreLoginInitPage {
return this.loadPage(); return this.loadPage();
}); });
} }
} else { }
return this.sitesProvider.hasSites().then((hasSites) => {
if (hasSites) {
return this.navCtrl.setRoot('CoreLoginSitesPage'); return this.navCtrl.setRoot('CoreLoginSitesPage');
} else {
return this.loginHelper.goToAddSite(true);
}
});
}
} }
} }

View File

@ -103,7 +103,9 @@ export class CoreLoginReconnectPage {
* Cancel reconnect. * Cancel reconnect.
*/ */
cancel(): void { cancel(): void {
this.sitesProvider.logout().finally(() => { this.sitesProvider.logout().catch(() => {
// Ignore errors (shouldn't happen).
}).finally(() => {
this.navCtrl.setRoot('CoreLoginSitesPage'); this.navCtrl.setRoot('CoreLoginSitesPage');
}); });
} }
@ -149,13 +151,22 @@ export class CoreLoginReconnectPage {
// Go to the site initial page. // Go to the site initial page.
return this.loginHelper.goToSiteInitialPage(this.navCtrl, this.pageName, this.pageParams); return this.loginHelper.goToSiteInitialPage(this.navCtrl, this.pageName, this.pageParams);
}).catch((error) => { }).catch((error) => {
// Error, go back to login page. if (error.loggedout) {
this.loginHelper.treatUserTokenError(siteUrl, error, username, password);
} else {
this.domUtils.showErrorModalDefault(error, 'core.login.errorupdatesite', true); this.domUtils.showErrorModalDefault(error, 'core.login.errorupdatesite', true);
}
// Error, go back to login page.
this.cancel(); this.cancel();
}); });
}); });
}).catch((error) => { }).catch((error) => {
this.loginHelper.treatUserTokenError(siteUrl, error, username, password); this.loginHelper.treatUserTokenError(siteUrl, error, username, password);
if (error.loggedout) {
this.cancel();
}
}).finally(() => { }).finally(() => {
modal.dismiss(); modal.dismiss();
}); });

View File

@ -95,10 +95,16 @@ export class CoreLoginSitePage {
return this.sitesProvider.newSite(data.siteUrl, data.token, data.privateToken).then(() => { return this.sitesProvider.newSite(data.siteUrl, data.token, data.privateToken).then(() => {
return this.loginHelper.goToSiteInitialPage(); return this.loginHelper.goToSiteInitialPage();
}, (error) => { }, (error) => {
this.domUtils.showErrorModal(error); this.loginHelper.treatUserTokenError(siteData.url, error, siteData.username, siteData.password);
if (error.loggedout) {
this.navCtrl.setRoot('CoreLoginSitesPage');
}
}); });
}, (error) => { }, (error) => {
this.loginHelper.treatUserTokenError(siteData.url, error, siteData.username, siteData.password); this.loginHelper.treatUserTokenError(siteData.url, error, siteData.username, siteData.password);
if (error.loggedout) {
this.navCtrl.setRoot('CoreLoginSitesPage');
}
}).finally(() => { }).finally(() => {
modal.dismiss(); modal.dismiss();
}); });

View File

@ -46,6 +46,10 @@ export class CoreLoginSitesPage {
*/ */
ionViewDidLoad(): void { ionViewDidLoad(): void {
this.sitesProvider.getSortedSites().then((sites) => { this.sitesProvider.getSortedSites().then((sites) => {
if (sites.length == 0) {
this.loginHelper.goToAddSite(true);
}
// Remove protocol from the url to show more url text. // Remove protocol from the url to show more url text.
this.sites = sites.map((site) => { this.sites = sites.map((site) => {
site.siteUrl = site.siteUrl.replace(/^https?:\/\//, ''); site.siteUrl = site.siteUrl.replace(/^https?:\/\//, '');

View File

@ -715,7 +715,8 @@ export class CoreSitesProvider {
return promise.then(() => { return promise.then(() => {
return Promise.reject({ return Promise.reject({
error: this.translate.instant(errorKey, errorKeyParams) + errorExtra, error: this.translate.instant(errorKey, errorKeyParams) + errorExtra,
errorcode: errorCode errorcode: errorCode,
loggedout: true
}); });
}); });
} }