Skip to content

Commit

Permalink
perf: remove 3 sec SSR delay by enabling PreviewContextID listening o…
Browse files Browse the repository at this point in the history
…nly in browser (#1455)

* PreviewContextID is not used in SSR so it should only be enabled for the browser/client mode
* `timer(3000)` resulted in a general 3 seconds rendering time for all SSR requests
  • Loading branch information
shauke authored Jul 5, 2023
1 parent 38d8662 commit 65c8c9a
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/app/core/services/preview/preview.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,21 @@ export class PreviewService {
private route: ActivatedRoute
) {
this.init();
race([
this.route.queryParams.pipe(
filter(params => params.PreviewContextID),
map(params => params.PreviewContextID),
take(1)
),
// end listening for PreviewContextID if there is no such parameter at initialization
timer(3000),
]).subscribe(value => {
if (!this.previewContextId && value) {
this.previewContextId = value;
}
});
if (!SSR) {
race([
this.route.queryParams.pipe(
filter(params => params.PreviewContextID),
map(params => params.PreviewContextID),
take(1)
),
// end listening for PreviewContextID if there is no such parameter at initialization
timer(3000),
]).subscribe(value => {
if (!this.previewContextId && value) {
this.previewContextId = value;
}
});
}
}

/**
Expand Down

0 comments on commit 65c8c9a

Please sign in to comment.