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

Fix timer button not being shown on turbo navigation

Oliver Günther91a04d2a00fe
diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts
index 3b0eb48fee6..db741909ce8 100644
--- a/frontend/src/app/app.module.ts
+++ b/frontend/src/app/app.module.ts
@@ -205,6 +205,7 @@ import {
OpWpDatePickerInstanceComponent,
} from 'core-app/shared/components/datepicker/wp-date-picker-modal/wp-date-picker-instance.component';
import { OpInviteUserModalAugmentService } from 'core-app/features/invite-user-modal/invite-user-modal-augment.service';
+import { TimeEntryTimerService } from 'core-app/shared/components/time_entries/services/time-entry-timer.service';
export function initializeServices(injector:Injector) {
return () => {
@@ -213,6 +214,7 @@ export function initializeServices(injector:Injector) {
const contextMenu = injector.get(OPContextMenuService);
const currentProject = injector.get(CurrentProjectService);
const inviteUserAugmentService = injector.get(OpInviteUserModalAugmentService);
+ const timeEntryTimerService = injector.get(TimeEntryTimerService);
// Conditionally add the Revit Add-In settings button
injector.get(RevitAddInSettingsButtonService);
@@ -221,6 +223,7 @@ export function initializeServices(injector:Injector) {
topMenuService.register();
contextMenu.register();
inviteUserAugmentService.setupListener();
+ timeEntryTimerService.initialize();
};
runOnRenderAndLoad();
diff --git a/frontend/src/app/shared/components/time_entries/services/time-entry-timer.service.ts b/frontend/src/app/shared/components/time_entries/services/time-entry-timer.service.ts
index e48aa54e974..a9b3db91820 100644
--- a/frontend/src/app/shared/components/time_entries/services/time-entry-timer.service.ts
+++ b/frontend/src/app/shared/components/time_entries/services/time-entry-timer.service.ts
@@ -1,34 +1,24 @@
-import {
- Injectable,
- Injector,
-} from '@angular/core';
-import {
- filter,
- map,
- tap,
-} from 'rxjs/operators';
+import { inject, Injectable } from '@angular/core';
+import { filter, map, tap } from 'rxjs/operators';
import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';
import { TimeEntryResource } from 'core-app/features/hal/resources/time-entry-resource';
import { ApiV3FilterBuilder } from 'core-app/shared/helpers/api-v3/api-v3-filter-builder';
-import {
- BehaviorSubject,
- Observable,
-} from 'rxjs';
+import { BehaviorSubject, Observable } from 'rxjs';
@Injectable()
export class TimeEntryTimerService {
public timer$ = new BehaviorSubject<TimeEntryResource|null|undefined>(undefined);
- public activeTimer$ = this.timer$
+ public activeTimer$ = this
+ .timer$
.asObservable()
.pipe(
filter((item) => item !== undefined),
- ) as Observable<TimeEntryResource|null>;
+ );
- constructor(
- readonly injector:Injector,
- readonly apiV3Service:ApiV3Service,
- ) {
+ private apiV3Service = inject(ApiV3Service);
+
+ public initialize() {
// Refresh the timer after some interval to not block other resources
setTimeout(() => this.refresh().subscribe(), 100);