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

remove observable from the device service and update the view and ts file to be compatible with the changes

bsatarnejad5d69719d09fc
diff --git a/frontend/src/app/core/browser/device.service.ts b/frontend/src/app/core/browser/device.service.ts
index 8d64aff4227..f89c9167aa4 100644
--- a/frontend/src/app/core/browser/device.service.ts
+++ b/frontend/src/app/core/browser/device.service.ts
@@ -1,17 +1,10 @@
import { Injectable } from '@angular/core';
-import { BehaviorSubject } from 'rxjs';
@Injectable({ providedIn: 'root' })
export class DeviceService {
- public get isMobile():boolean {
- return window.matchMedia('(max-width: 679px)').matches;
- }
+ public mobileWidthTreshold = 680;
- constructor() {
- window.addEventListener('resize', () => {
- this.isMobile$.next(this.isMobile);
- });
+ public get isMobile():boolean {
+ return (window.innerWidth < this.mobileWidthTreshold);
}
-
- public isMobile$ = new BehaviorSubject<boolean>(this.isMobile);
}
diff --git a/frontend/src/app/features/team-planner/team-planner/planner/team-planner.component.html b/frontend/src/app/features/team-planner/team-planner/planner/team-planner.component.html
index dbd8fa2029a..e5d64e427fb 100644
--- a/frontend/src/app/features/team-planner/team-planner/planner/team-planner.component.html
+++ b/frontend/src/app/features/team-planner/team-planner/planner/team-planner.component.html
@@ -3,7 +3,7 @@
[ngClass]="{'op-team-planner_with_left_side_pane' : (showAddExistingPane | async)}"
>
<ng-container
- *ngIf="(calendarOptions$ | async) && !(isMobile$ | async)"
+ *ngIf="(calendarOptions$ | async) && !isMobile"
>
<button
#addExistingToggle
@@ -71,7 +71,7 @@
<op-principal
[principal]="resource.extendedProps.principal"
class="tp-assignee--principal op-principal_wrapped"
- [hideName]="isMobile$ | async"
+ [hideName]="isMobile"
></op-principal>
<button
type="button"
diff --git a/frontend/src/app/features/team-planner/team-planner/planner/team-planner.component.ts b/frontend/src/app/features/team-planner/team-planner/planner/team-planner.component.ts
index 933a9f9c8a8..f070de853bb 100644
--- a/frontend/src/app/features/team-planner/team-planner/planner/team-planner.component.ts
+++ b/frontend/src/app/features/team-planner/team-planner/planner/team-planner.component.ts
@@ -302,7 +302,7 @@ export class TeamPlannerComponent extends UntilDestroyedMixin implements OnInit,
shareReplay(1),
);
- isMobile$ = this.deviceService.isMobile$;
+ isMobile = this.deviceService.isMobile;
constructor(
private $state:StateService,
@@ -486,7 +486,7 @@ export class TeamPlannerComponent extends UntilDestroyedMixin implements OnInit,
},
],
resources: skeletonResources,
- resourceAreaWidth: this.isMobile$.getValue() ? '60px' : '180px',
+ resourceAreaWidth: this.isMobile ? '60px' : '180px',
select: this.handleDateClicked.bind(this) as unknown,
resourceLabelContent: (data:ResourceLabelContentArg) => this.renderTemplate(this.resourceContent, data.resource.id, data),
resourceLabelWillUnmount: (data:ResourceLabelContentArg) => this.unrenderTemplate(data.resource.id),