Skip to content

Commit 51cf4ce

Browse files
fix for prerender
1 parent 23c4428 commit 51cf4ce

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

angular.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@
4646
"discoverRoutes": false,
4747
"routesFile": "routes.txt"
4848
},
49-
"ssr": true
49+
"ssr": {
50+
"entry": "server.ts"
51+
}
5052
},
5153
"configurations": {
5254
"production": {
@@ -68,8 +70,6 @@
6870
"optimization": false,
6971
"extractLicenses": false,
7072
"sourceMap": true,
71-
"ssr": false,
72-
"prerender": false,
7373
"fileReplacements": [
7474
{
7575
"replace": "src/environments/environment.ts",

src/app/app.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<div>
2-
<!-- <router-outlet/>-->
2+
<router-outlet/>
33
</div>

src/app/reader/_components/main-page/posts-list/posts-list.component.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
ElementRef,
1010
signal,
1111
WritableSignal,
12+
OnInit,
1213
} from '@angular/core';
1314
import { RouterModule } from '@angular/router';
1415
import { AboutMeComponent } from '../../../../shared/about-me/about-me.component';
@@ -32,7 +33,7 @@ import { TagsStore } from '../../../../shared/stores/tags.store';
3233
changeDetection: ChangeDetectionStrategy.OnPush,
3334
schemas: [CUSTOM_ELEMENTS_SCHEMA],
3435
})
35-
export class PostsListComponent {
36+
export class PostsListComponent implements OnInit {
3637
scroll = viewChild<ElementRef<HTMLElement>>('scrollContainer');
3738
scrollProgress: WritableSignal<number> = signal(0);
3839
postStore = inject(PostsStore);
@@ -46,13 +47,16 @@ export class PostsListComponent {
4647
constructor() {
4748
this.scrollProgress.set(this.initialScroll);
4849
afterNextRender(() => {
49-
console.log('Scroll:', this.scroll());
5050
this.scroll()?.nativeElement.addEventListener(
5151
'scroll',
5252
this.onScroll.bind(this),
5353
);
5454
});
55-
console.log('init');
55+
}
56+
57+
//TODO: FIX HACK FOR PRERENDERING
58+
ngOnInit() {
59+
setTimeout(() => {}, 0);
5660
}
5761

5862
onScroll(event: Event) {

src/app/services/supabase.service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Injectable } from '@angular/core';
1+
import { inject, Injectable, NgZone } from '@angular/core';
22
import {
33
AuthChangeEvent,
44
AuthSession,
@@ -15,11 +15,11 @@ import { environment } from '../../environments/environment';
1515
export class SupabaseService {
1616
private readonly supabase: SupabaseClient;
1717
public session: AuthSession | null = null;
18+
private readonly ngZone = inject(NgZone);
1819

1920
constructor() {
20-
this.supabase = createClient(
21-
environment.supabaseUrl,
22-
environment.supabaseKey,
21+
this.supabase = this.ngZone.runOutsideAngular(() =>
22+
createClient(environment.supabaseUrl, environment.supabaseKey),
2323
);
2424
}
2525

0 commit comments

Comments
 (0)