Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: remove 3 sec SSR delay by enabling PreviewContextID listening only in browser #1455

Merged
merged 1 commit into from
Jul 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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