Skip to content

Commit 30ad2c1

Browse files
committed
Fix the issue with initialization NotFoundPage component many times #5
1 parent aac5f26 commit 30ad2c1

File tree

1 file changed

+5
-34
lines changed

1 file changed

+5
-34
lines changed

project/application/src/app/modules/core/services/http-response-status/http-response-status.service.ts

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,21 @@ import { Inject, Injectable, Optional } from '@angular/core';
22
import { RESPONSE } from '@nguniversal/express-engine/tokens';
33

44
import { CoreModule } from '../../core.module';
5-
import { TransferStateService } from '../transfer-state/transfer-state.service';
6-
7-
interface PayloadDefinition {
8-
payload: {
9-
setStatusExecuted: boolean;
10-
};
11-
}
125

136
@Injectable({
147
providedIn: CoreModule,
158
})
169
export class HttpResponseStatusService {
17-
private payloadServerName = 'HttpResponseStatusServicePayload';
18-
1910
constructor(
2011
@Optional()
2112
@Inject(RESPONSE)
22-
private res: any,
23-
private transferStateService: TransferStateService
13+
private res: any
2414
) {}
2515

2616
public setStatus(code: number, message: string): void {
27-
this.transferStateService
28-
.savePayload(
29-
() =>
30-
new Promise(resolve => {
31-
if (this.res) {
32-
this.res.statusCode = code;
33-
this.res.statusMessage = message;
34-
}
35-
36-
const payload = { setStatusExecuted: true };
37-
38-
resolve({ payload });
39-
}),
40-
this.payloadServerName
41-
)
42-
.then(
43-
(payload: PayloadDefinition) => {
44-
// payload received
45-
},
46-
error => {
47-
// error while receiving payload
48-
}
49-
);
17+
if (this.res) {
18+
this.res.statusCode = code;
19+
this.res.statusMessage = message;
20+
}
5021
}
5122
}

0 commit comments

Comments
 (0)