diff --git a/client/src/app/site/base/base-model-request-handler.component/base-model-request-handler.component.ts b/client/src/app/site/base/base-model-request-handler.component/base-model-request-handler.component.ts index 2510c2f4ed..4fe0ed0830 100644 --- a/client/src/app/site/base/base-model-request-handler.component/base-model-request-handler.component.ts +++ b/client/src/app/site/base/base-model-request-handler.component/base-model-request-handler.component.ts @@ -1,6 +1,6 @@ import { Directive, EventEmitter, inject, OnDestroy, OnInit } from '@angular/core'; import { Router } from '@angular/router'; -import { combineLatest, map, Observable, startWith } from 'rxjs'; +import { combineLatest, firstValueFrom, map, Observable, skip, startWith } from 'rxjs'; import { Id } from 'src/app/domain/definitions/key-types'; import { ModelRequestService } from 'src/app/site/services/model-request.service'; import { BaseUiComponent } from 'src/app/ui/base/base-ui-component'; @@ -53,9 +53,13 @@ export class BaseModelRequestHandlerComponent extends BaseUiComponent implements this.openslidesRouter = inject(OpenSlidesRouterService); } - public ngOnInit(): void { + public async ngOnInit(): Promise { + const currentParams = await firstValueFrom(this.openslidesRouter.currentParamMap); + this._currentParams = currentParams; + this._currentMeetingId = Number(currentParams[`meetingId`]) || null; + this.subscriptions.push( - this.openslidesRouter.currentParamMap.subscribe(event => { + this.openslidesRouter.currentParamMap.pipe(skip(1)).subscribe(event => { const nextMeetingId = Number(event[`meetingId`]) || null; if (nextMeetingId !== this._currentMeetingId) { this._currentMeetingId = nextMeetingId; @@ -79,7 +83,7 @@ export class BaseModelRequestHandlerComponent extends BaseUiComponent implements } protected onBeforeModelRequests(): void | Promise {} - protected onShouldCreateModelRequests(): void {} + protected onShouldCreateModelRequests(_params?: any, _meetingId?: Id | null): void {} protected onNextMeetingId(_id: Id | null): void {} protected onParamsChanged(_params: any, _oldParams?: any): void {} @@ -125,7 +129,7 @@ export class BaseModelRequestHandlerComponent extends BaseUiComponent implements private async initModelSubscriptions(): Promise { await this.onBeforeModelRequests(); - this.onShouldCreateModelRequests(); + this.onShouldCreateModelRequests(this._currentParams, this._currentMeetingId); } private createHideWhenObservable( diff --git a/client/src/app/site/pages/meetings/base/base-meeting-model-request-handler.component.ts b/client/src/app/site/pages/meetings/base/base-meeting-model-request-handler.component.ts new file mode 100644 index 0000000000..e91bb3c28e --- /dev/null +++ b/client/src/app/site/pages/meetings/base/base-meeting-model-request-handler.component.ts @@ -0,0 +1,21 @@ +import { Directive } from '@angular/core'; +import { Id } from 'src/app/domain/definitions/key-types'; +import { SubscriptionConfig } from 'src/app/domain/interfaces/subscription-config'; +import { BaseModelRequestHandlerComponent } from 'src/app/site/base/base-model-request-handler.component'; + +@Directive() +export abstract class BaseMeetingModelRequestHandler extends BaseModelRequestHandlerComponent { + protected abstract getSubscriptions(meetingId: Id): SubscriptionConfig[]; + + protected override onShouldCreateModelRequests(_params: any, id: number | null): void { + if (id) { + this.subscribeTo(this.getSubscriptions(id), { hideWhenMeetingChanged: true }); + } + } + + protected override onNextMeetingId(id: number | null): void { + if (id) { + this.updateSubscribeTo(this.getSubscriptions(id), { hideWhenMeetingChanged: true }); + } + } +} diff --git a/client/src/app/site/pages/meetings/modules/meetings-component-collector/agenda-content-object-form/components/agenda-content-object-form/agenda-content-object-form.component.ts b/client/src/app/site/pages/meetings/modules/meetings-component-collector/agenda-content-object-form/components/agenda-content-object-form/agenda-content-object-form.component.ts index 3a729bca04..a094f0ca53 100644 --- a/client/src/app/site/pages/meetings/modules/meetings-component-collector/agenda-content-object-form/components/agenda-content-object-form/agenda-content-object-form.component.ts +++ b/client/src/app/site/pages/meetings/modules/meetings-component-collector/agenda-content-object-form/components/agenda-content-object-form/agenda-content-object-form.component.ts @@ -2,8 +2,9 @@ import { AfterViewInit, Component, Input, OnDestroy } from '@angular/core'; import { AbstractControl, UntypedFormGroup } from '@angular/forms'; import { BehaviorSubject, map, Observable, Subscription } from 'rxjs'; import { Permission } from 'src/app/domain/definitions/permission'; +import { SubscriptionConfig } from 'src/app/domain/interfaces/subscription-config'; import { ItemTypeChoices } from 'src/app/domain/models/agenda/agenda-item'; -import { BaseModelRequestHandlerComponent } from 'src/app/site/base/base-model-request-handler.component'; +import { BaseMeetingModelRequestHandler } from 'src/app/site/pages/meetings/base/base-meeting-model-request-handler.component'; import { ViewAgendaItem } from 'src/app/site/pages/meetings/pages/agenda'; import { getAgendaListMinimalSubscriptionConfig } from 'src/app/site/pages/meetings/pages/agenda/agenda.subscription'; import { MeetingSettingsService } from 'src/app/site/pages/meetings/services/meeting-settings.service'; @@ -16,7 +17,7 @@ import { AgendaContentObjectFormService } from '../../services/agenda-content-ob styleUrls: [`./agenda-content-object-form.component.scss`] }) export class AgendaContentObjectFormComponent - extends BaseModelRequestHandlerComponent + extends BaseMeetingModelRequestHandler implements AfterViewInit, OnDestroy { @Input() @@ -92,10 +93,8 @@ export class AgendaContentObjectFormComponent super.ngOnDestroy(); } - protected override onNextMeetingId(id: number | null): void { - if (id) { - this.subscribeTo(getAgendaListMinimalSubscriptionConfig(id), { hideWhenDestroyed: true }); - } + protected getSubscriptions(meetingId: number): SubscriptionConfig[] { + return [getAgendaListMinimalSubscriptionConfig(meetingId)]; } private setupSubscription(): void { diff --git a/client/src/app/site/pages/meetings/pages/agenda/components/agenda-main/agenda-main.component.ts b/client/src/app/site/pages/meetings/pages/agenda/components/agenda-main/agenda-main.component.ts index 41def37345..7f6c3f7471 100644 --- a/client/src/app/site/pages/meetings/pages/agenda/components/agenda-main/agenda-main.component.ts +++ b/client/src/app/site/pages/meetings/pages/agenda/components/agenda-main/agenda-main.component.ts @@ -1,5 +1,7 @@ import { Component } from '@angular/core'; -import { BaseModelRequestHandlerComponent } from 'src/app/site/base/base-model-request-handler.component'; +import { Id } from 'src/app/domain/definitions/key-types'; +import { SubscriptionConfig } from 'src/app/domain/interfaces/subscription-config'; +import { BaseMeetingModelRequestHandler } from 'src/app/site/pages/meetings/base/base-meeting-model-request-handler.component'; import { getAgendaListSubscriptionConfig } from '../../agenda.subscription'; @@ -8,10 +10,8 @@ import { getAgendaListSubscriptionConfig } from '../../agenda.subscription'; templateUrl: `./agenda-main.component.html`, styleUrls: [`./agenda-main.component.scss`] }) -export class AgendaMainComponent extends BaseModelRequestHandlerComponent { - protected override onNextMeetingId(id: number | null): void { - if (id) { - this.subscribeTo(getAgendaListSubscriptionConfig(id), { hideWhenMeetingChanged: true }); - } +export class AgendaMainComponent extends BaseMeetingModelRequestHandler { + protected getSubscriptions(id: Id): SubscriptionConfig[] { + return [getAgendaListSubscriptionConfig(id)]; } } diff --git a/client/src/app/site/pages/meetings/pages/agenda/modules/list-of-speakers/components/list-of-speakers-main/list-of-speakers-main.component.ts b/client/src/app/site/pages/meetings/pages/agenda/modules/list-of-speakers/components/list-of-speakers-main/list-of-speakers-main.component.ts index b40a596c0f..293c4d9b48 100644 --- a/client/src/app/site/pages/meetings/pages/agenda/modules/list-of-speakers/components/list-of-speakers-main/list-of-speakers-main.component.ts +++ b/client/src/app/site/pages/meetings/pages/agenda/modules/list-of-speakers/components/list-of-speakers-main/list-of-speakers-main.component.ts @@ -20,24 +20,30 @@ export class ListOfSpeakersMainComponent extends BaseModelRequestHandlerComponen protected override onParamsChanged(params: any, oldParams: any): void { if (params[`id`] !== oldParams[`id`] || params[`meetingId`] !== oldParams[`meetingId`]) { - this.sequentialNumberMapping - .getIdBySequentialNumber({ - collection: ListOfSpeakers.COLLECTION, - meetingId: params[`meetingId`], - sequentialNumber: +params[`id`] - }) - .then(id => { - if (id && this._currentLOSId !== id) { - this._currentLOSId = id; - this.loadLOSDetail(); - } - }); + this.loadLOSDetail(+params[`id`], +params[`meetingId`]); } } - private loadLOSDetail(): void { - this.updateSubscribeTo(getListOfSpeakersDetailSubscriptionConfig(this._currentLOSId), { - hideWhenDestroyed: true - }); + protected override onShouldCreateModelRequests(params: any, meetingId: Id): void { + if (params[`id`] && meetingId) { + this.loadLOSDetail(+params[`id`], meetingId); + } + } + + private loadLOSDetail(id: Id, meetingId: Id): void { + this.sequentialNumberMapping + .getIdBySequentialNumber({ + collection: ListOfSpeakers.COLLECTION, + meetingId: meetingId, + sequentialNumber: id + }) + .then(id => { + if (id && this._currentLOSId !== id) { + this._currentLOSId = id; + this.updateSubscribeTo(getListOfSpeakersDetailSubscriptionConfig(this._currentLOSId), { + hideWhenDestroyed: true + }); + } + }); } } diff --git a/client/src/app/site/pages/meetings/pages/agenda/modules/topics/pages/topic-detail/components/topic-detail-main/topic-detail-main.component.ts b/client/src/app/site/pages/meetings/pages/agenda/modules/topics/pages/topic-detail/components/topic-detail-main/topic-detail-main.component.ts index 66263c2d51..15bd5b343e 100644 --- a/client/src/app/site/pages/meetings/pages/agenda/modules/topics/pages/topic-detail/components/topic-detail-main/topic-detail-main.component.ts +++ b/client/src/app/site/pages/meetings/pages/agenda/modules/topics/pages/topic-detail/components/topic-detail-main/topic-detail-main.component.ts @@ -22,27 +22,44 @@ export class TopicDetailMainComponent extends BaseModelRequestHandlerComponent { super(); } + protected override onShouldCreateModelRequests(params: any, meetingId: any): void { + if (meetingId) { + if (+params[`id`]) { + this.loadTopicDetail(+params[`id`], +params[`meetingId`]); + } else { + this.loadTopicList(+params[`meetingId`]); + } + } + } + protected override onParamsChanged(params: any, oldParams: any): void { - if (params[`id`] !== oldParams[`id`] || params[`meetingId`] !== oldParams[`meetingId`]) { - this.sequentialNumberMapping - .getIdBySequentialNumber({ - collection: Topic.COLLECTION, - meetingId: params[`meetingId`], - sequentialNumber: +params[`id`] - }) - .then(id => { - if (id && this._currentTopicId !== id) { - this._currentTopicId = id; - this.loadTopicDetail(); - } else if (!id && params[`meetingId`]) { - this.loadTopicList(+params[`meetingId`]); - } - }); + if ( + params[`id`] !== oldParams[`id`] || + (+params[`meetingId`] && params[`meetingId`] !== oldParams[`meetingId`]) + ) { + if (+params[`id`]) { + this.loadTopicDetail(+params[`id`], +params[`meetingId`]); + } else { + this.loadTopicList(+params[`meetingId`]); + } } } - private loadTopicDetail(): void { - this.updateSubscribeTo(getTopicDetailSubscriptionConfig(this._currentTopicId), { hideWhenDestroyed: true }); + private loadTopicDetail(sNr: Id, meetingId: Id): void { + this.sequentialNumberMapping + .getIdBySequentialNumber({ + collection: Topic.COLLECTION, + meetingId, + sequentialNumber: sNr + }) + .then(id => { + if (id && this._currentTopicId !== id) { + this._currentTopicId = id; + this.updateSubscribeTo(getTopicDetailSubscriptionConfig(this._currentTopicId), { + hideWhenDestroyed: true + }); + } + }); } private async loadTopicList(meetingId: number): Promise { diff --git a/client/src/app/site/pages/meetings/pages/agenda/modules/topics/pages/topic-import/components/topic-import-main/topic-import-main.component.ts b/client/src/app/site/pages/meetings/pages/agenda/modules/topics/pages/topic-import/components/topic-import-main/topic-import-main.component.ts index f0b0c2f541..71c0725647 100644 --- a/client/src/app/site/pages/meetings/pages/agenda/modules/topics/pages/topic-import/components/topic-import-main/topic-import-main.component.ts +++ b/client/src/app/site/pages/meetings/pages/agenda/modules/topics/pages/topic-import/components/topic-import-main/topic-import-main.component.ts @@ -1,5 +1,7 @@ import { Component } from '@angular/core'; -import { BaseModelRequestHandlerComponent } from 'src/app/site/base/base-model-request-handler.component'; +import { Id } from 'src/app/domain/definitions/key-types'; +import { SubscriptionConfig } from 'src/app/domain/interfaces/subscription-config'; +import { BaseMeetingModelRequestHandler } from 'src/app/site/pages/meetings/base/base-meeting-model-request-handler.component'; import { getAgendaListSubscriptionConfig } from '../../../../../../agenda.subscription'; @@ -8,10 +10,8 @@ import { getAgendaListSubscriptionConfig } from '../../../../../../agenda.subscr templateUrl: `./topic-import-main.component.html`, styleUrls: [`./topic-import-main.component.scss`] }) -export class TopicImportMainComponent extends BaseModelRequestHandlerComponent { - protected override onNextMeetingId(id: number | null): void { - if (id) { - this.subscribeTo(getAgendaListSubscriptionConfig(id), { hideWhenMeetingChanged: true }); - } +export class TopicImportMainComponent extends BaseMeetingModelRequestHandler { + protected getSubscriptions(id: Id): SubscriptionConfig[] { + return [getAgendaListSubscriptionConfig(id)]; } } diff --git a/client/src/app/site/pages/meetings/pages/assignments/components/assignment-main/assignment-main.component.ts b/client/src/app/site/pages/meetings/pages/assignments/components/assignment-main/assignment-main.component.ts index 9ab2a0c000..cf7056e392 100644 --- a/client/src/app/site/pages/meetings/pages/assignments/components/assignment-main/assignment-main.component.ts +++ b/client/src/app/site/pages/meetings/pages/assignments/components/assignment-main/assignment-main.component.ts @@ -1,6 +1,8 @@ import { Component } from '@angular/core'; -import { BaseModelRequestHandlerComponent } from 'src/app/site/base/base-model-request-handler.component'; +import { Id } from 'src/app/domain/definitions/key-types'; +import { SubscriptionConfig } from 'src/app/domain/interfaces/subscription-config'; +import { BaseMeetingModelRequestHandler } from '../../../../base/base-meeting-model-request-handler.component'; import { getAssignmentSubscriptionConfig } from '../../assignments.subscription'; @Component({ @@ -8,10 +10,8 @@ import { getAssignmentSubscriptionConfig } from '../../assignments.subscription' templateUrl: `./assignment-main.component.html`, styleUrls: [`./assignment-main.component.scss`] }) -export class AssignmentMainComponent extends BaseModelRequestHandlerComponent { - protected override onNextMeetingId(id: number | null): void { - if (id) { - this.subscribeTo(getAssignmentSubscriptionConfig(id), { hideWhenMeetingChanged: true }); - } +export class AssignmentMainComponent extends BaseMeetingModelRequestHandler { + protected getSubscriptions(id: Id): SubscriptionConfig[] { + return [getAssignmentSubscriptionConfig(id)]; } } diff --git a/client/src/app/site/pages/meetings/pages/assignments/pages/assignment-polls/components/assignment-poll-main/assignment-poll-main.component.ts b/client/src/app/site/pages/meetings/pages/assignments/pages/assignment-polls/components/assignment-poll-main/assignment-poll-main.component.ts index d2bf9c4afa..d7a4f6d54a 100644 --- a/client/src/app/site/pages/meetings/pages/assignments/pages/assignment-polls/components/assignment-poll-main/assignment-poll-main.component.ts +++ b/client/src/app/site/pages/meetings/pages/assignments/pages/assignment-polls/components/assignment-poll-main/assignment-poll-main.component.ts @@ -1,4 +1,5 @@ import { Component } from '@angular/core'; +import { Id } from 'src/app/domain/definitions/key-types'; import { BaseModelRequestHandlerComponent } from 'src/app/site/base/base-model-request-handler.component'; import { SequentialNumberMappingService } from 'src/app/site/pages/meetings/services/sequential-number-mapping.service'; @@ -16,12 +17,12 @@ export class AssignmentPollMainComponent extends BaseModelRequestHandlerComponen super(); } - protected override onParamsChanged(params: any, oldParams: any): void { - if (params[`id`] && params[`id`] !== oldParams[`id`]) { + protected override onShouldCreateModelRequests(params: any, meetingId: Id): void { + if (params[`id`]) { this.sequentialNumberMappingService .getIdBySequentialNumber({ collection: ViewPoll.COLLECTION, - meetingId: params[`meetingId`], + meetingId, sequentialNumber: +params[`id`] }) .then(id => { @@ -34,4 +35,23 @@ export class AssignmentPollMainComponent extends BaseModelRequestHandlerComponen }); } } + + protected override onParamsChanged(params: any, oldParams: any): void { + if ((params[`id`] && params[`id`] !== oldParams[`id`]) || params[`meetingId`] !== oldParams[`meetingId`]) { + this.sequentialNumberMappingService + .getIdBySequentialNumber({ + collection: ViewPoll.COLLECTION, + meetingId: params[`meetingId`], + sequentialNumber: +params[`id`] + }) + .then(id => { + if (id) { + this.updateSubscribeTo(getPollDetailSubscriptionConfig(id), { hideWhenDestroyed: true }); + this.updateSubscribeTo(getParticipantMinimalSubscriptionConfig(+params[`meetingId`]), { + hideWhenDestroyed: true + }); + } + }); + } + } } diff --git a/client/src/app/site/pages/meetings/pages/autopilot/components/autopilot-main/autopilot-main.component.ts b/client/src/app/site/pages/meetings/pages/autopilot/components/autopilot-main/autopilot-main.component.ts index ffa52c4854..362bc7dc6d 100644 --- a/client/src/app/site/pages/meetings/pages/autopilot/components/autopilot-main/autopilot-main.component.ts +++ b/client/src/app/site/pages/meetings/pages/autopilot/components/autopilot-main/autopilot-main.component.ts @@ -1,9 +1,10 @@ import { Component } from '@angular/core'; import { distinctUntilChanged, map } from 'rxjs'; import { Id } from 'src/app/domain/definitions/key-types'; +import { SubscriptionConfig } from 'src/app/domain/interfaces/subscription-config'; import { ProjectorRepositoryService } from 'src/app/gateways/repositories/projectors/projector-repository.service'; import { collectionFromFqid } from 'src/app/infrastructure/utils/transform-functions'; -import { BaseModelRequestHandlerComponent } from 'src/app/site/base/base-model-request-handler.component'; +import { BaseMeetingModelRequestHandler } from 'src/app/site/pages/meetings/base/base-meeting-model-request-handler.component'; import { CollectionMapperService } from 'src/app/site/services/collection-mapper.service'; import { @@ -17,7 +18,7 @@ import { templateUrl: `./autopilot-main.component.html`, styleUrls: [`./autopilot-main.component.scss`] }) -export class AutopilotMainComponent extends BaseModelRequestHandlerComponent { +export class AutopilotMainComponent extends BaseMeetingModelRequestHandler { private currentSubscriptions: Id[] = []; public constructor( @@ -83,11 +84,7 @@ export class AutopilotMainComponent extends BaseModelRequestHandlerComponent { ); } - protected override onNextMeetingId(id: number | null): void { - if (id) { - this.subscribeTo(getAutopilotSubscriptionConfig(id), { - hideWhenMeetingChanged: true - }); - } + protected getSubscriptions(id: Id): SubscriptionConfig[] { + return [getAutopilotSubscriptionConfig(id)]; } } diff --git a/client/src/app/site/pages/meetings/pages/history/components/history-main/history-main.component.ts b/client/src/app/site/pages/meetings/pages/history/components/history-main/history-main.component.ts index 91e10f6e1d..a3e596de64 100644 --- a/client/src/app/site/pages/meetings/pages/history/components/history-main/history-main.component.ts +++ b/client/src/app/site/pages/meetings/pages/history/components/history-main/history-main.component.ts @@ -12,7 +12,7 @@ import { getParticipantMinimalSubscriptionConfig } from '../../../participants/p styleUrls: [`./history-main.component.scss`] }) export class HistoryMainComponent extends BaseModelRequestHandlerComponent { - protected override onNextMeetingId(id: Id | null): void { + protected override onShouldCreateModelRequests(_params: any, id: Id | null): void { if (id) { this.subscribeTo(getMotionListMinimalSubscriptionConfig(id), { hideWhenDestroyed: true }); this.subscribeTo(getParticipantMinimalSubscriptionConfig(id), { hideWhenDestroyed: true }); diff --git a/client/src/app/site/pages/meetings/pages/mediafiles/components/mediafile-main/mediafile-main.component.ts b/client/src/app/site/pages/meetings/pages/mediafiles/components/mediafile-main/mediafile-main.component.ts index cdefa683a8..64f09284c8 100644 --- a/client/src/app/site/pages/meetings/pages/mediafiles/components/mediafile-main/mediafile-main.component.ts +++ b/client/src/app/site/pages/meetings/pages/mediafiles/components/mediafile-main/mediafile-main.component.ts @@ -1,6 +1,8 @@ import { Component } from '@angular/core'; -import { BaseModelRequestHandlerComponent } from 'src/app/site/base/base-model-request-handler.component'; +import { Id } from 'src/app/domain/definitions/key-types'; +import { SubscriptionConfig } from 'src/app/domain/interfaces/subscription-config'; +import { BaseMeetingModelRequestHandler } from '../../../../base/base-meeting-model-request-handler.component'; import { getMediafilesSubscriptionConfig } from '../../mediafiles.subscription'; @Component({ @@ -8,10 +10,8 @@ import { getMediafilesSubscriptionConfig } from '../../mediafiles.subscription'; templateUrl: `./mediafile-main.component.html`, styleUrls: [`./mediafile-main.component.scss`] }) -export class MediafileMainComponent extends BaseModelRequestHandlerComponent { - protected override onNextMeetingId(id: number | null): void { - if (id) { - this.subscribeTo(getMediafilesSubscriptionConfig(id), { hideWhenMeetingChanged: true }); - } +export class MediafileMainComponent extends BaseMeetingModelRequestHandler { + protected getSubscriptions(id: Id): SubscriptionConfig[] { + return [getMediafilesSubscriptionConfig(id)]; } } diff --git a/client/src/app/site/pages/meetings/pages/meeting-settings/pages/meeting-settings-group-detail/components/meeting-settings-group-detail-main/meeting-settings-group-detail-main.component.ts b/client/src/app/site/pages/meetings/pages/meeting-settings/pages/meeting-settings-group-detail/components/meeting-settings-group-detail-main/meeting-settings-group-detail-main.component.ts index 90c29b020a..ac5ad20dc5 100644 --- a/client/src/app/site/pages/meetings/pages/meeting-settings/pages/meeting-settings-group-detail/components/meeting-settings-group-detail-main/meeting-settings-group-detail-main.component.ts +++ b/client/src/app/site/pages/meetings/pages/meeting-settings/pages/meeting-settings-group-detail/components/meeting-settings-group-detail-main/meeting-settings-group-detail-main.component.ts @@ -17,7 +17,15 @@ export class MeetingSettingsGroupDetailMainComponent extends BaseModelRequestHan params[`group`] === MOTIONS_SETTINGS_GROUP && params[`meetingId`] !== oldParams[`meetingId`] ) { - this.subscribeTo(getMotionWorkflowSubscriptionConfig(+params[`meetingId`]), { + this.updateSubscribeTo(getMotionWorkflowSubscriptionConfig(+params[`meetingId`]), { + hideWhenMeetingChanged: true + }); + } + } + + protected override onShouldCreateModelRequests(params?: any, meetingId?: number): void { + if (params[`group`] && params[`group`] === MOTIONS_SETTINGS_GROUP && meetingId) { + this.subscribeTo(getMotionWorkflowSubscriptionConfig(meetingId), { hideWhenMeetingChanged: true }); } diff --git a/client/src/app/site/pages/meetings/pages/motions/components/motion-main/motion-main.component.ts b/client/src/app/site/pages/meetings/pages/motions/components/motion-main/motion-main.component.ts index b9fb932736..4717b3644a 100644 --- a/client/src/app/site/pages/meetings/pages/motions/components/motion-main/motion-main.component.ts +++ b/client/src/app/site/pages/meetings/pages/motions/components/motion-main/motion-main.component.ts @@ -1,6 +1,8 @@ import { Component } from '@angular/core'; -import { BaseModelRequestHandlerComponent } from 'src/app/site/base/base-model-request-handler.component'; +import { Id } from 'src/app/domain/definitions/key-types'; +import { SubscriptionConfig } from 'src/app/domain/interfaces/subscription-config'; +import { BaseMeetingModelRequestHandler } from '../../../../base/base-meeting-model-request-handler.component'; import { getMotionBlockSubscriptionConfig, getMotionListSubscriptionConfig, @@ -13,18 +15,13 @@ import { templateUrl: `./motion-main.component.html`, styleUrls: [`./motion-main.component.scss`] }) -export class MotionMainComponent extends BaseModelRequestHandlerComponent { - protected override onNextMeetingId(id: number | null): void { - if (id) { - this.updateSubscribeTo( - [ - getMotionListSubscriptionConfig(id), - getMotionBlockSubscriptionConfig(id), - getMotionWorkflowSubscriptionConfig(id), - getMotionsSubmodelSubscriptionConfig(id) - ], - { hideWhenMeetingChanged: true } - ); - } +export class MotionMainComponent extends BaseMeetingModelRequestHandler { + protected getSubscriptions(id: Id): SubscriptionConfig[] { + return [ + getMotionListSubscriptionConfig(id), + getMotionBlockSubscriptionConfig(id), + getMotionWorkflowSubscriptionConfig(id), + getMotionsSubmodelSubscriptionConfig(id) + ]; } } diff --git a/client/src/app/site/pages/meetings/pages/motions/pages/amendments/components/amendment-list-main/amendment-list-main.component.ts b/client/src/app/site/pages/meetings/pages/motions/pages/amendments/components/amendment-list-main/amendment-list-main.component.ts index 38c5727d71..f67ff1c147 100644 --- a/client/src/app/site/pages/meetings/pages/motions/pages/amendments/components/amendment-list-main/amendment-list-main.component.ts +++ b/client/src/app/site/pages/meetings/pages/motions/pages/amendments/components/amendment-list-main/amendment-list-main.component.ts @@ -1,5 +1,7 @@ import { Component } from '@angular/core'; -import { BaseModelRequestHandlerComponent } from 'src/app/site/base/base-model-request-handler.component'; +import { Id } from 'src/app/domain/definitions/key-types'; +import { SubscriptionConfig } from 'src/app/domain/interfaces/subscription-config'; +import { BaseMeetingModelRequestHandler } from 'src/app/site/pages/meetings/base/base-meeting-model-request-handler.component'; import { getAmendmentListSubscriptionConfig } from '../../../../motions.subscription'; @@ -8,10 +10,8 @@ import { getAmendmentListSubscriptionConfig } from '../../../../motions.subscrip templateUrl: `./amendment-list-main.component.html`, styleUrls: [`./amendment-list-main.component.scss`] }) -export class AmendmentListMainComponent extends BaseModelRequestHandlerComponent { - protected override onNextMeetingId(id: number | null): void { - if (id) { - this.subscribeTo(getAmendmentListSubscriptionConfig(id), { hideWhenMeetingChanged: true }); - } +export class AmendmentListMainComponent extends BaseMeetingModelRequestHandler { + protected getSubscriptions(id: Id): SubscriptionConfig[] { + return [getAmendmentListSubscriptionConfig(id)]; } } diff --git a/client/src/app/site/pages/meetings/pages/motions/pages/motion-detail/components/motion-detail/motion-detail.component.ts b/client/src/app/site/pages/meetings/pages/motions/pages/motion-detail/components/motion-detail/motion-detail.component.ts index a9add29d30..b12c22b455 100644 --- a/client/src/app/site/pages/meetings/pages/motions/pages/motion-detail/components/motion-detail/motion-detail.component.ts +++ b/client/src/app/site/pages/meetings/pages/motions/pages/motion-detail/components/motion-detail/motion-detail.component.ts @@ -28,34 +28,40 @@ export class MotionDetailComponent extends BaseModelRequestHandlerComponent { super(); } + protected override onShouldCreateModelRequests(params: any, meetingId: Id): void { + if (params[`id`] && meetingId) { + this.loadMotionDetail(meetingId, +params[`id`]); + } + } + protected override onParamsChanged(params: any, oldParams: any): void { if (params[`id`] !== oldParams[`id`] || params[`meetingId`] !== oldParams[`meetingId`]) { - this.sequentialNumberMapping - .getIdBySequentialNumber({ - collection: Motion.COLLECTION, - meetingId: params[`meetingId`], - sequentialNumber: +params[`id`] - }) - .then(id => { - if (id && this._currentMotionId !== id) { - this._currentMotionId = id; - this._watchingMap = {}; - this.loadMotionDetail(); - } - }); + this.loadMotionDetail(+params[`meetingId`], +params[`id`]); } } - private loadMotionDetail(): void { - this.updateSubscribeTo(getMotionDetailSubscriptionConfig(this._currentMotionId)); - this.updateSubscription( - MOTION_DETAIL_SUBSCRIPTION, - this.repo.getViewModelObservable(this._currentMotionId!).subscribe(motion => { - if (motion) { - this.watchForChanges(motion, `all_origin_ids`, `derived_motion_ids`); - } + private loadMotionDetail(meetingId: Id, motionId: Id): void { + this.sequentialNumberMapping + .getIdBySequentialNumber({ + collection: Motion.COLLECTION, + meetingId, + sequentialNumber: motionId }) - ); + .then(id => { + if (id && this._currentMotionId !== id) { + this._currentMotionId = id; + this._watchingMap = {}; + this.updateSubscribeTo(getMotionDetailSubscriptionConfig(this._currentMotionId)); + this.updateSubscription( + MOTION_DETAIL_SUBSCRIPTION, + this.repo.getViewModelObservable(this._currentMotionId!).subscribe(motion => { + if (motion) { + this.watchForChanges(motion, `all_origin_ids`, `derived_motion_ids`); + } + }) + ); + } + }); } private watchForChanges(motion: ViewMotion, ...fields: (keyof Motion)[]): void { diff --git a/client/src/app/site/pages/meetings/pages/motions/pages/motion-polls/components/motion-poll-main/motion-poll-main.component.ts b/client/src/app/site/pages/meetings/pages/motions/pages/motion-polls/components/motion-poll-main/motion-poll-main.component.ts index 59e1013c7f..0c4b9b339c 100644 --- a/client/src/app/site/pages/meetings/pages/motions/pages/motion-polls/components/motion-poll-main/motion-poll-main.component.ts +++ b/client/src/app/site/pages/meetings/pages/motions/pages/motion-polls/components/motion-poll-main/motion-poll-main.component.ts @@ -16,6 +16,25 @@ export class MotionPollMainComponent extends BaseModelRequestHandlerComponent { super(); } + protected override onShouldCreateModelRequests(params?: any, meetingId?: number): void { + if (params[`id`]) { + this.sequentialNumberMappingService + .getIdBySequentialNumber({ + collection: ViewPoll.COLLECTION, + meetingId, + sequentialNumber: +params[`id`] + }) + .then(id => { + if (id) { + this.subscribeTo(getPollDetailSubscriptionConfig(id), { hideWhenDestroyed: true }); + this.subscribeTo(getParticipantMinimalSubscriptionConfig(+params[`meetingId`]), { + hideWhenDestroyed: true + }); + } + }); + } + } + protected override onParamsChanged(params: any, oldParams: any): void { if (params[`id`] !== oldParams[`id`]) { this.sequentialNumberMappingService @@ -26,8 +45,8 @@ export class MotionPollMainComponent extends BaseModelRequestHandlerComponent { }) .then(id => { if (id) { - this.subscribeTo(getPollDetailSubscriptionConfig(id), { hideWhenDestroyed: true }); - this.subscribeTo(getParticipantMinimalSubscriptionConfig(+params[`meetingId`]), { + this.updateSubscribeTo(getPollDetailSubscriptionConfig(id), { hideWhenDestroyed: true }); + this.updateSubscribeTo(getParticipantMinimalSubscriptionConfig(+params[`meetingId`]), { hideWhenDestroyed: true }); } diff --git a/client/src/app/site/pages/meetings/pages/participants/components/participant-main/participant-main.component.ts b/client/src/app/site/pages/meetings/pages/participants/components/participant-main/participant-main.component.ts index 7cee7fa0a9..358f0ec987 100644 --- a/client/src/app/site/pages/meetings/pages/participants/components/participant-main/participant-main.component.ts +++ b/client/src/app/site/pages/meetings/pages/participants/components/participant-main/participant-main.component.ts @@ -1,5 +1,7 @@ import { Component } from '@angular/core'; -import { BaseModelRequestHandlerComponent } from 'src/app/site/base/base-model-request-handler.component'; +import { Id } from 'src/app/domain/definitions/key-types'; +import { SubscriptionConfig } from 'src/app/domain/interfaces/subscription-config'; +import { BaseMeetingModelRequestHandler } from 'src/app/site/pages/meetings/base/base-meeting-model-request-handler.component'; import { getParticipantListSubscriptionConfig, @@ -12,20 +14,12 @@ import { getStructureLevelListSubscriptionConfig } from '../../participants.subs templateUrl: `./participant-main.component.html`, styleUrls: [`./participant-main.component.scss`] }) -export class ParticipantMainComponent extends BaseModelRequestHandlerComponent { - protected override onNextMeetingId(id: number | null): void { - if (id) { - // TODO: Do requests for speaker list and structure level list somewhere else - this.subscribeTo( - [ - getParticipantListSubscriptionConfig(id), - getStructureLevelListSubscriptionConfig(id), - getSpeakersListSubscriptionConfig(id) - ], - { - hideWhenMeetingChanged: true - } - ); - } +export class ParticipantMainComponent extends BaseMeetingModelRequestHandler { + protected getSubscriptions(id: Id): SubscriptionConfig[] { + return [ + getParticipantListSubscriptionConfig(id), + getStructureLevelListSubscriptionConfig(id), + getSpeakersListSubscriptionConfig(id) + ]; } } diff --git a/client/src/app/site/pages/meetings/pages/participants/pages/participant-detail/components/participant-detail/participant-detail.component.ts b/client/src/app/site/pages/meetings/pages/participants/pages/participant-detail/components/participant-detail/participant-detail.component.ts index 20bfb72de0..4fb19bee8b 100644 --- a/client/src/app/site/pages/meetings/pages/participants/pages/participant-detail/components/participant-detail/participant-detail.component.ts +++ b/client/src/app/site/pages/meetings/pages/participants/pages/participant-detail/components/participant-detail/participant-detail.component.ts @@ -9,9 +9,15 @@ import { getParticipantDetailSubscription } from '../../../../participants.subsc styleUrls: [`./participant-detail.component.scss`] }) export class ParticipantDetailComponent extends BaseModelRequestHandlerComponent { + protected override onShouldCreateModelRequests(params?: any): void { + if (params[`id`]) { + this.subscribeTo(getParticipantDetailSubscription(+params[`id`]), { hideWhenDestroyed: true }); + } + } + protected override onParamsChanged(params: any, oldParams: any): void { if (params[`id`] && params[`id`] !== oldParams[`id`]) { - this.subscribeTo(getParticipantDetailSubscription(+params[`id`]), { hideWhenDestroyed: true }); + this.updateSubscribeTo(getParticipantDetailSubscription(+params[`id`]), { hideWhenDestroyed: true }); } } } diff --git a/client/src/app/site/pages/meetings/pages/polls/components/poll-main/poll-main.component.ts b/client/src/app/site/pages/meetings/pages/polls/components/poll-main/poll-main.component.ts index 0cd7cd41a0..93277e43a6 100644 --- a/client/src/app/site/pages/meetings/pages/polls/components/poll-main/poll-main.component.ts +++ b/client/src/app/site/pages/meetings/pages/polls/components/poll-main/poll-main.component.ts @@ -1,6 +1,8 @@ import { Component } from '@angular/core'; -import { BaseModelRequestHandlerComponent } from 'src/app/site/base/base-model-request-handler.component'; +import { Id } from 'src/app/domain/definitions/key-types'; +import { SubscriptionConfig } from 'src/app/domain/interfaces/subscription-config'; +import { BaseMeetingModelRequestHandler } from '../../../../base/base-meeting-model-request-handler.component'; import { getPollListSubscriptionConfig } from '../../polls.subscription'; @Component({ @@ -8,10 +10,8 @@ import { getPollListSubscriptionConfig } from '../../polls.subscription'; templateUrl: `./poll-main.component.html`, styleUrls: [`./poll-main.component.scss`] }) -export class PollMainComponent extends BaseModelRequestHandlerComponent { - protected override onNextMeetingId(id: number | null): void { - if (id) { - this.subscribeTo(getPollListSubscriptionConfig(id), { hideWhenMeetingChanged: true }); - } +export class PollMainComponent extends BaseMeetingModelRequestHandler { + protected override getSubscriptions(id: Id): SubscriptionConfig[] { + return [getPollListSubscriptionConfig(id)]; } } diff --git a/client/src/app/site/pages/meetings/pages/projectors/components/projector-main/projector-main.component.ts b/client/src/app/site/pages/meetings/pages/projectors/components/projector-main/projector-main.component.ts index e38ef4e2b3..ce3a91f104 100644 --- a/client/src/app/site/pages/meetings/pages/projectors/components/projector-main/projector-main.component.ts +++ b/client/src/app/site/pages/meetings/pages/projectors/components/projector-main/projector-main.component.ts @@ -1,6 +1,8 @@ import { Component } from '@angular/core'; -import { BaseModelRequestHandlerComponent } from 'src/app/site/base/base-model-request-handler.component'; +import { Id } from 'src/app/domain/definitions/key-types'; +import { SubscriptionConfig } from 'src/app/domain/interfaces/subscription-config'; +import { BaseMeetingModelRequestHandler } from '../../../../base/base-meeting-model-request-handler.component'; import { getProjectorListSubscriptionConfig } from '../../projectors.subscription'; @Component({ @@ -8,10 +10,8 @@ import { getProjectorListSubscriptionConfig } from '../../projectors.subscriptio templateUrl: `./projector-main.component.html`, styleUrls: [`./projector-main.component.scss`] }) -export class ProjectorMainComponent extends BaseModelRequestHandlerComponent { - protected override onNextMeetingId(id: number | null): void { - if (id) { - this.subscribeTo(getProjectorListSubscriptionConfig(id), { hideWhenMeetingChanged: true }); - } +export class ProjectorMainComponent extends BaseMeetingModelRequestHandler { + protected getSubscriptions(id: Id): SubscriptionConfig[] { + return [getProjectorListSubscriptionConfig(id)]; } } diff --git a/client/src/app/site/pages/meetings/pages/projectors/modules/fullscreen-projector/components/fullscreen-projector-main/fullscreen-projector-main.component.ts b/client/src/app/site/pages/meetings/pages/projectors/modules/fullscreen-projector/components/fullscreen-projector-main/fullscreen-projector-main.component.ts index f6339f6117..83aacfd3b3 100644 --- a/client/src/app/site/pages/meetings/pages/projectors/modules/fullscreen-projector/components/fullscreen-projector-main/fullscreen-projector-main.component.ts +++ b/client/src/app/site/pages/meetings/pages/projectors/modules/fullscreen-projector/components/fullscreen-projector-main/fullscreen-projector-main.component.ts @@ -1,4 +1,5 @@ import { Component } from '@angular/core'; +import { Id } from 'src/app/domain/definitions/key-types'; import { BaseModelRequestHandlerComponent } from 'src/app/site/base/base-model-request-handler.component'; import { SequentialNumberMappingService } from 'src/app/site/pages/meetings/services/sequential-number-mapping.service'; @@ -15,17 +16,17 @@ export class FullscreenProjectorMainComponent extends BaseModelRequestHandlerCom super(); } - protected override onParamsChanged(params: any, _oldParams?: any): void { + protected override onShouldCreateModelRequests(params: any, meetingId: Id): void { if (params[`id`]) { this.sequentialNumberMappingService .getIdBySequentialNumber({ collection: ViewProjector.COLLECTION, - meetingId: params[`meetingId`], + meetingId, sequentialNumber: +params[`id`] }) .then(id => { if (id) { - this.subscribeTo(getProjectorSubscriptionConfig(id), { hideWhenMeetingChanged: true }); + this.subscribeTo(getProjectorSubscriptionConfig(id), { hideWhenDestroyed: true }); } }); } diff --git a/client/src/app/site/pages/organization/pages/accounts/pages/account-detail/components/account-detail-main/account-detail-main.component.ts b/client/src/app/site/pages/organization/pages/accounts/pages/account-detail/components/account-detail-main/account-detail-main.component.ts index 9dca1fcb1b..cc9a4b8a5b 100644 --- a/client/src/app/site/pages/organization/pages/accounts/pages/account-detail/components/account-detail-main/account-detail-main.component.ts +++ b/client/src/app/site/pages/organization/pages/accounts/pages/account-detail/components/account-detail-main/account-detail-main.component.ts @@ -11,6 +11,13 @@ import { getAccountDetailSubscriptionConfig } from '../../../../accounts.subscri export class AccountDetailMainComponent extends BaseModelRequestHandlerComponent { protected override onParamsChanged(params: any, oldParams: any): void { if (params[`id`] !== oldParams[`id`]) { + const id = +params[`id`]; + this.updateSubscribeTo(getAccountDetailSubscriptionConfig(id), { hideWhenDestroyed: true }); + } + } + + protected override onShouldCreateModelRequests(params: any): void { + if (params[`id`]) { const id = +params[`id`]; this.subscribeTo(getAccountDetailSubscriptionConfig(id), { hideWhenDestroyed: true }); } diff --git a/client/src/app/site/pages/organization/pages/committees/pages/committee-detail/components/committee-detail/committee-detail.component.ts b/client/src/app/site/pages/organization/pages/committees/pages/committee-detail/components/committee-detail/committee-detail.component.ts index f34ce30f79..3b671657b5 100644 --- a/client/src/app/site/pages/organization/pages/committees/pages/committee-detail/components/committee-detail/committee-detail.component.ts +++ b/client/src/app/site/pages/organization/pages/committees/pages/committee-detail/components/committee-detail/committee-detail.component.ts @@ -1,5 +1,4 @@ import { Component } from '@angular/core'; -import { Id } from 'src/app/domain/definitions/key-types'; import { BaseModelRequestHandlerComponent } from 'src/app/site/base/base-model-request-handler.component/base-model-request-handler.component'; import { getCommitteeDetailSubscriptionConfig } from '../../../../committees.subscription'; @@ -10,12 +9,17 @@ import { getCommitteeDetailSubscriptionConfig } from '../../../../committees.sub styleUrls: [`./committee-detail.component.scss`] }) export class CommitteeDetailComponent extends BaseModelRequestHandlerComponent { - private committeeId: Id | null = null; - protected override onParamsChanged(params: any, oldParams: any): void { - if (params[`committeeId`] !== oldParams[`committeeId`]) { - this.committeeId = +params[`committeeId`] || null; - this.subscribeTo(getCommitteeDetailSubscriptionConfig(this.committeeId), { hideWhenDestroyed: true }); + if (params[`committeeId`] !== oldParams[`committeeId`] && +params[`committeeId`]) { + this.updateSubscribeTo(getCommitteeDetailSubscriptionConfig(+params[`committeeId`]), { + hideWhenDestroyed: true + }); + } + } + + protected override onShouldCreateModelRequests(params: any): void { + if (+params[`committeeId`]) { + this.subscribeTo(getCommitteeDetailSubscriptionConfig(+params[`committeeId`]), { hideWhenDestroyed: true }); } } } diff --git a/client/src/app/site/pages/organization/pages/committees/pages/committee-detail/modules/committee-detail-meeting/components/committee-detail-meeting-main/committee-detail-meeting-main.component.ts b/client/src/app/site/pages/organization/pages/committees/pages/committee-detail/modules/committee-detail-meeting/components/committee-detail-meeting-main/committee-detail-meeting-main.component.ts index c457071ee0..153c9b71bf 100644 --- a/client/src/app/site/pages/organization/pages/committees/pages/committee-detail/modules/committee-detail-meeting/components/committee-detail-meeting-main/committee-detail-meeting-main.component.ts +++ b/client/src/app/site/pages/organization/pages/committees/pages/committee-detail/modules/committee-detail-meeting/components/committee-detail-meeting-main/committee-detail-meeting-main.component.ts @@ -13,11 +13,12 @@ import { getCommitteeMeetingDetailSubscriptionConfig } from '../../../../../../c export class CommitteeDetailMeetingMainComponent extends BaseModelRequestHandlerComponent { protected override onNextMeetingId(id: Id | null): void { if (id) { - this.subscribeTo(getCommitteeMeetingDetailSubscriptionConfig(id), { hideWhenDestroyed: true }); + this.updateSubscribeTo(getCommitteeMeetingDetailSubscriptionConfig(id), { hideWhenDestroyed: true }); } } - protected override onShouldCreateModelRequests(): void { + protected override onShouldCreateModelRequests(_params: any, meetingId: Id): void { this.subscribeTo(getMeetingCreateSubscriptionConfig()); + this.subscribeTo(getCommitteeMeetingDetailSubscriptionConfig(meetingId), { hideWhenDestroyed: true }); } }