diff --git a/src/core/features/settings/pages/synchronization/synchronization.html b/src/core/features/settings/pages/synchronization/synchronization.html index 7e4911b89..03ee791e9 100644 --- a/src/core/features/settings/pages/synchronization/synchronization.html +++ b/src/core/features/settings/pages/synchronization/synchronization.html @@ -17,7 +17,7 @@ - + {{ 'core.settings.syncsettings' | translate }} @@ -30,24 +30,75 @@ - {{ 'core.settings.sites' | translate }} + {{ 'core.accounts' | translate }} - - - - - - {{ site.fullName }} - {{ site.siteUrlWithoutProtocol }} - - - - - - - + + + + + + + + {{ + accountsList.currentSite.siteUrlWithoutProtocol }} + + + + + + + + + + {{accountsList.currentSite.fullName}} + + + + + + + + + + + + + + + + + + {{ sites[0].siteUrlWithoutProtocol }} + + + + + + + + + + + + + + + {{site.fullName}} + + + + + + + + diff --git a/src/core/features/settings/pages/synchronization/synchronization.ts b/src/core/features/settings/pages/synchronization/synchronization.ts index b96806ab2..cf64335b1 100644 --- a/src/core/features/settings/pages/synchronization/synchronization.ts +++ b/src/core/features/settings/pages/synchronization/synchronization.ts @@ -16,11 +16,12 @@ import { Component, OnDestroy, OnInit } from '@angular/core'; import { CoreConstants } from '@/core/constants'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; -import { CoreSites, CoreSiteBasicInfo } from '@services/sites'; +import { CoreSites } from '@services/sites'; import { CoreDomUtils } from '@services/utils/dom'; import { CoreConfig } from '@services/config'; import { CoreSettingsHelper } from '@features/settings/services/settings-helper'; import { Translate } from '@singletons'; +import { CoreAccountsList, CoreLoginHelper } from '@features/login/services/login-helper'; /** * Page that displays the synchronization settings. @@ -28,43 +29,67 @@ import { Translate } from '@singletons'; @Component({ selector: 'page-core-app-settings-synchronization', templateUrl: 'synchronization.html', + styleUrls: ['../../../login/sitelist.scss'], }) export class CoreSettingsSynchronizationPage implements OnInit, OnDestroy { - sites: CoreSiteBasicInfo[] = []; + accountsList: CoreAccountsList = { + sameSite: [], + otherSites: [], + count: 0, + }; + sitesLoaded = false; - currentSiteId = ''; syncOnlyOnWifi = false; protected isDestroyed = false; protected sitesObserver: CoreEventObserver; constructor() { - this.currentSiteId = CoreSites.getCurrentSiteId(); - this.sitesObserver = CoreEvents.on(CoreEvents.SITE_UPDATED, async (data) => { - const site = await CoreSites.getSite(data.siteId); + const siteId = data.siteId; - const siteEntry = this.sites.find((siteEntry) => siteEntry.id == site.id); - if (siteEntry) { - const siteInfo = site.getInfo(); + let siteEntry = siteId === this.accountsList.currentSite?.id + ? this.accountsList.currentSite + : undefined; - siteEntry.siteName = site.getSiteName(); + if (!siteEntry) { + siteEntry = this.accountsList.sameSite.find((siteEntry) => siteEntry.id === siteId); + } - if (siteInfo) { - siteEntry.siteUrl = siteInfo.siteurl; - siteEntry.fullName = siteInfo.fullname; - } + if (!siteEntry) { + this.accountsList.otherSites.some((sites) => { + siteEntry = sites.find((siteEntry) => siteEntry.id === siteId); + + return siteEntry; + }); + } + + if (!siteEntry) { + return; + } + + const site = await CoreSites.getSite(siteId); + + const siteInfo = site.getInfo(); + + siteEntry.siteName = site.getSiteName(); + + if (siteInfo) { + siteEntry.siteUrl = siteInfo.siteurl; + siteEntry.fullName = siteInfo.fullname; } }); } /** - * View loaded. + * @inheritdoc */ async ngOnInit(): Promise { + const currentSiteId = CoreSites.getCurrentSiteId(); + try { - this.sites = await CoreSites.getSortedSites(); + this.accountsList = await CoreLoginHelper.getAccountsList(currentSiteId); } catch { // Ignore errors. } diff --git a/src/core/services/sites.ts b/src/core/services/sites.ts index 3307ce10d..f28d5c44a 100644 --- a/src/core/services/sites.ts +++ b/src/core/services/sites.ts @@ -1185,6 +1185,7 @@ export class CoreSitesProvider { siteName: CoreConstants.CONFIG.sitename == '' ? siteInfo?.sitename: CoreConstants.CONFIG.sitename, avatar: siteInfo?.userpictureurl, siteHomeId: siteInfo?.siteid || 1, + loggedOut: !!site.loggedOut, }; formattedSites.push(basicInfo); } @@ -1923,6 +1924,7 @@ export type CoreSiteBasicInfo = { avatar?: string; // User's avatar. badge?: number; // Badge to display in the site. siteHomeId?: number; // Site home ID. + loggedOut: boolean; // If Site is logged out. }; /**
- -
{{ site.fullName }}
{{ site.siteUrlWithoutProtocol }}
{{ + accountsList.currentSite.siteUrlWithoutProtocol }} +
{{accountsList.currentSite.fullName}}
{{ sites[0].siteUrlWithoutProtocol }}
{{site.fullName}}