[develop-hydration 0aacac2d] [develop-hydration | WIP | CHANGED] Added checks and logs for server or client state, to utilize non destructive hydration and avoid first page load flickering (affected files so far: app.component.ts, app.module.ts, home.component.ts
This commit is contained in:
parent
0879a339ff
commit
97d038b729
|
@ -30,6 +30,7 @@ import {ISVocabulariesService} from "./openaireLibrary/utils/staticAutoComplete/
|
||||||
[onlyTop]=false [user]="user"
|
[onlyTop]=false [user]="user"
|
||||||
[communityId]="properties.adminToolsCommunity" [userMenuItems]=userMenuItems [menuItems]=menuItems></navbar>
|
[communityId]="properties.adminToolsCommunity" [userMenuItems]=userMenuItems [menuItems]=menuItems></navbar>
|
||||||
<div *ngIf="loading">
|
<div *ngIf="loading">
|
||||||
|
loading... {{isClient ? "client" : "server"}}
|
||||||
<loading [full]="true"></loading>
|
<loading [full]="true"></loading>
|
||||||
</div>
|
</div>
|
||||||
<schema2jsonld *ngIf="properties" [URL]="properties.domain+properties.baseLink"
|
<schema2jsonld *ngIf="properties" [URL]="properties.domain+properties.baseLink"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import {APP_ID, NgModule} from '@angular/core';
|
import {APP_ID, NgModule} from '@angular/core';
|
||||||
import {SharedModule} from './openaireLibrary/shared/shared.module';
|
import {SharedModule} from './openaireLibrary/shared/shared.module';
|
||||||
import {BrowserModule} from '@angular/platform-browser';
|
import {BrowserModule, provideClientHydration} from '@angular/platform-browser';
|
||||||
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
|
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
|
||||||
import {CommonModule} from '@angular/common';
|
import {CommonModule} from '@angular/common';
|
||||||
import {HTTP_INTERCEPTORS, HttpClientModule} from '@angular/common/http';
|
import {HTTP_INTERCEPTORS, HttpClientModule} from '@angular/common/http';
|
||||||
|
@ -38,6 +38,7 @@ import {LoadingModule} from "./openaireLibrary/utils/loading/loading.module";
|
||||||
declarations: [AppComponent],
|
declarations: [AppComponent],
|
||||||
exports: [AppComponent],
|
exports: [AppComponent],
|
||||||
providers: [
|
providers: [
|
||||||
|
provideClientHydration(),
|
||||||
{provide: APP_ID, useValue: 'explore'},
|
{provide: APP_ID, useValue: 'explore'},
|
||||||
// {
|
// {
|
||||||
// provide: HTTP_INTERCEPTORS,
|
// provide: HTTP_INTERCEPTORS,
|
||||||
|
|
|
@ -2,10 +2,10 @@ import {
|
||||||
AfterViewInit,
|
AfterViewInit,
|
||||||
ChangeDetectorRef,
|
ChangeDetectorRef,
|
||||||
Component,
|
Component,
|
||||||
ElementRef,
|
ElementRef, Inject, makeStateKey,
|
||||||
OnDestroy,
|
OnDestroy,
|
||||||
OnInit,
|
OnInit, PLATFORM_ID,
|
||||||
QueryList,
|
QueryList, TransferState,
|
||||||
ViewChild,
|
ViewChild,
|
||||||
ViewChildren
|
ViewChildren
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
|
@ -25,6 +25,7 @@ import {properties} from "../../environments/environment";
|
||||||
import {Numbers, NumbersComponent} from "../openaireLibrary/sharedComponents/numbers/numbers.component";
|
import {Numbers, NumbersComponent} from "../openaireLibrary/sharedComponents/numbers/numbers.component";
|
||||||
import {StringUtils} from "../openaireLibrary/utils/string-utils.class";
|
import {StringUtils} from "../openaireLibrary/utils/string-utils.class";
|
||||||
import {QuickContactService} from '../openaireLibrary/sharedComponents/quick-contact/quick-contact.service';
|
import {QuickContactService} from '../openaireLibrary/sharedComponents/quick-contact/quick-contact.service';
|
||||||
|
import {isPlatformServer} from "@angular/common";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'home',
|
selector: 'home',
|
||||||
|
@ -110,14 +111,19 @@ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||||
stringUtils = new StringUtils();
|
stringUtils = new StringUtils();
|
||||||
// disableSelect: boolean = true;
|
// disableSelect: boolean = true;
|
||||||
|
|
||||||
|
public isClient: boolean = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private _router: Router,
|
private _router: Router,
|
||||||
private _piwikService: PiwikService,
|
private _piwikService: PiwikService,
|
||||||
private config: ConfigurationService, private _meta: Meta, private _title: Title, private seoService: SEOService,
|
private config: ConfigurationService, private _meta: Meta, private _title: Title, private seoService: SEOService,
|
||||||
private helper: HelperService,
|
private helper: HelperService,
|
||||||
private cdr: ChangeDetectorRef,
|
private cdr: ChangeDetectorRef,
|
||||||
private quickContactService: QuickContactService
|
private quickContactService: QuickContactService,
|
||||||
|
@Inject(PLATFORM_ID) private platform: any,
|
||||||
|
private transferState: TransferState
|
||||||
) {
|
) {
|
||||||
|
this.isClient = !isPlatformServer(this.platform);
|
||||||
let description = "OpenAIRE Explore: Over 100M of research deduplicated, 170K research software, 11M research data. One of the largest open scholarly records collection worldwide.";
|
let description = "OpenAIRE Explore: Over 100M of research deduplicated, 170K research software, 11M research data. One of the largest open scholarly records collection worldwide.";
|
||||||
let title = "OpenAIRE | Find and Share research";
|
let title = "OpenAIRE | Find and Share research";
|
||||||
this._title.setTitle(title);
|
this._title.setTitle(title);
|
||||||
|
@ -221,7 +227,12 @@ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||||
this.resultTypes.values.push({name: this.openaireEntities.OTHER, id: "other", selected: false, number: 0});
|
this.resultTypes.values.push({name: this.openaireEntities.OTHER, id: "other", selected: false, number: 0});
|
||||||
}
|
}
|
||||||
if(this.numbersComponent) {
|
if(this.numbersComponent) {
|
||||||
|
let stateKey = makeStateKey<Numbers>("numbers");
|
||||||
|
// if(this.isClient && this.transferState.hasKey(stateKey)) {
|
||||||
|
// this.numbers = this.transferState.get(stateKey, null);
|
||||||
|
// } else {
|
||||||
this.numbersComponent.init(this.numbersComponent.showDatasets, this.numbersComponent.showSoftware, this.numbersComponent.showPublications, this.numbersComponent.showDatasets, this.numbersComponent.showSoftware, this.numbersComponent.showOrp, this.numbersComponent.showProjects, this.numbersComponent.showDataProviders, this.numbersComponent.showOrganizations);
|
this.numbersComponent.init(this.numbersComponent.showDatasets, this.numbersComponent.showSoftware, this.numbersComponent.showPublications, this.numbersComponent.showDatasets, this.numbersComponent.showSoftware, this.numbersComponent.showOrp, this.numbersComponent.showProjects, this.numbersComponent.showDataProviders, this.numbersComponent.showOrganizations);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue