MOBILE-1973 sync: Do not sync logged out sites

main
Pau Ferrer Ocaña 2019-02-25 17:12:47 +01:00
parent c048c6f9bf
commit 04bc8fd81b
2 changed files with 14 additions and 1 deletions

View File

@ -243,7 +243,7 @@ export class CoreSyncBaseProvider {
if (!siteId) {
// No site ID defined, sync all sites.
this.logger.debug(`Try to sync '${syncFunctionLog}' in all sites.`);
promise = this.sitesProvider.getSitesIds();
promise = this.sitesProvider.getLoggedInSitesIds();
} else {
this.logger.debug(`Try to sync '${syncFunctionLog}' in site '${siteId}'.`);
promise = Promise.resolve([siteId]);

View File

@ -1050,6 +1050,19 @@ export class CoreSitesProvider {
});
}
/**
* Get the list of IDs of sites stored and not logged out.
*
* @return {Promise<string[]>} Promise resolved when the sites IDs are retrieved.
*/
getLoggedInSitesIds(): Promise<string[]> {
return this.appDB.getRecords(this.SITES_TABLE, {loggedOut : 0}).then((sites) => {
return sites.map((site) => {
return site.id;
});
});
}
/**
* Get the list of IDs of sites stored.
*