1212// See the License for the specific language governing permissions and
1313// limitations under the License.
1414
15- import { Component , OnInit , OnDestroy , input , computed , signal , effect } from '@angular/core' ;
15+ import { Component , OnInit , OnDestroy , input , computed , signal , effect , untracked } from '@angular/core' ;
1616import { CoreSites } from '@services/sites' ;
1717import { CoreEventObserver , CoreEvents } from '@static/events' ;
18- import { CoreSite } from '@classes/sites/site' ;
18+ import { CoreSite , CoreSiteConfig } from '@classes/sites/site' ;
1919import { toBoolean } from '@/core/transforms/boolean' ;
2020import { CorePromiseUtils } from '@static/promise-utils' ;
2121import { CoreUnauthenticatedSite } from '@classes/sites/unauthenticated-site' ;
@@ -51,14 +51,17 @@ export class CoreSiteLogoComponent implements OnInit, OnDestroy {
5151 const showLogo = this . showLogo ( ) ;
5252 const logoError = this . logoError ( ) ;
5353 const hideOnError = this . hideOnError ( ) ;
54+ const siteConfig = this . siteConfig ( ) ;
5455
55- if ( ! showLogo || ( logoType === CoreSiteLogoType . TOP && site . getShowTopLogo ( ) === 'hidden' ) ) {
56+ if ( ! showLogo || ( logoType === CoreSiteLogoType . TOP && site . getShowTopLogo ( siteConfig ) === 'hidden' ) ) {
5657 return false ;
5758 }
5859
5960 return ! logoError || ! hideOnError ;
6061 } ) ;
6162
63+ protected readonly siteConfig = signal < CoreSiteConfig | undefined > ( undefined ) ;
64+
6265 protected readonly siteEffective = computed < CoreSite | CoreUnauthenticatedSite > ( ( ) =>
6366 this . site ( ) ?? CoreSites . getRequiredCurrentSite ( ) ) ;
6467
@@ -88,7 +91,11 @@ export class CoreSiteLogoComponent implements OnInit, OnDestroy {
8891
8992 constructor ( ) {
9093 effect ( async ( ) => {
91- await this . loadInfo ( this . siteEffective ( ) ) ;
94+ const site = this . siteEffective ( ) ;
95+ untracked ( ( ) => {
96+ void this . updateSiteConfig ( site ) ;
97+ void this . loadInfo ( site ) ;
98+ } ) ;
9299 } ) ;
93100
94101 }
@@ -98,7 +105,12 @@ export class CoreSiteLogoComponent implements OnInit, OnDestroy {
98105 */
99106 async ngOnInit ( ) : Promise < void > {
100107 this . updateSiteObserver = CoreEvents . on ( CoreEvents . SITE_UPDATED , async ( ) => {
101- await this . loadInfo ( this . siteEffective ( ) ) ;
108+ const site = this . siteEffective ( ) ;
109+
110+ untracked ( ( ) => {
111+ void this . updateSiteConfig ( site ) ;
112+ void this . loadInfo ( site ) ;
113+ } ) ;
102114 } , this . siteId ( ) ) ;
103115 }
104116
@@ -111,6 +123,17 @@ export class CoreSiteLogoComponent implements OnInit, OnDestroy {
111123 this . logoError . set ( ! success ) ;
112124 }
113125
126+ /**
127+ * Update the site config.
128+ *
129+ * @param site The site to update the config from.
130+ */
131+ protected async updateSiteConfig ( site : CoreSite | CoreUnauthenticatedSite ) : Promise < void > {
132+ if ( site instanceof CoreSite && this . logoType ( ) === CoreSiteLogoType . TOP ) {
133+ this . siteConfig . set ( await CorePromiseUtils . ignoreErrors ( site . getConfig ( ) ) ) ;
134+ }
135+ }
136+
114137 /**
115138 * Load the site name, config and logo.
116139 *
@@ -120,7 +143,7 @@ export class CoreSiteLogoComponent implements OnInit, OnDestroy {
120143 const siteName = await site . getSiteName ( ) ;
121144 this . siteName . set ( siteName || '' ) ;
122145
123- if ( ! this . showLogo ( ) || ( this . logoType ( ) === CoreSiteLogoType . TOP && site . getShowTopLogo ( ) === 'hidden' ) ) {
146+ if ( ! this . showLogo ( ) || ( this . logoType ( ) === CoreSiteLogoType . TOP && site . getShowTopLogo ( this . siteConfig ( ) ) === 'hidden' ) ) {
124147 return ;
125148 }
126149
0 commit comments