Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Use fetch in a service, not Turbo.visit

Oliver Güntherc8f04189f200
diff --git a/frontend/src/app/core/turbo/turbo-requests.service.ts b/frontend/src/app/core/turbo/turbo-requests.service.ts
new file mode 100644
index 00000000000..41532ce7c83
--- /dev/null
+++ b/frontend/src/app/core/turbo/turbo-requests.service.ts
@@ -0,0 +1,25 @@
+import { Injectable } from '@angular/core';
+import { renderStreamMessage } from '@hotwired/turbo';
+import { ToastService } from 'core-app/shared/components/toaster/toast.service';
+
+@Injectable({ providedIn: 'root' })
+export class TurboRequestsService {
+ constructor(
+ private toast:ToastService,
+ ) {
+
+ }
+
+ public request(url:string):Promise<unknown> {
+ return fetch(url)
+ .then((response) => {
+ if (!response.ok) {
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
+ }
+
+ return response.text();
+ })
+ .then((html) => renderStreamMessage(html))
+ .catch((error) => this.toast.addError(error as string));
+ }
+}
diff --git a/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts b/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts
index 479677996cd..6116f4a7b4b 100644
--- a/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts
+++ b/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts
@@ -61,6 +61,7 @@ import { ApiV3ListFilter, ApiV3ListParameters } from 'core-app/core/apiv3/paths/
import { FrameElement } from '@hotwired/turbo';
import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';
import { UrlParamsService } from 'core-app/core/url-params/url-params.service';
+import { TurboRequestsService } from "core-app/core/turbo/turbo-requests.service";
export interface INotificationPageQueryParameters {
filter?:string|null;
@@ -192,6 +193,7 @@ export class IanCenterService extends UntilDestroyedMixin {
readonly state:StateService,
readonly deviceService:DeviceService,
readonly pathHelper:PathHelperService,
+ readonly turboRequests:TurboRequestsService,
) {
super();
this.reload.subscribe();
@@ -233,7 +235,7 @@ export class IanCenterService extends UntilDestroyedMixin {
openSplitScreen(workPackageId:string, tabIdentifier:string = 'activity'):void {
const link = this.pathHelper.notificationsDetailsPath(workPackageId, tabIdentifier) + window.location.search;
- Turbo.visit(link, { action: 'replace', acceptsStreamResponse: true } as never);
+ void this.turboRequests.request(link);
}
openFullView(workPackageId:string|null):void {