Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent unneccessary presenter call #3671

Merged
merged 1 commit into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ export class MotionManageMotionMeetingUsersComponent<V extends BaseHasMeetingUse
public secondSelectorLabel: string;

@Input()
public loadSecondSelectorValues: () => Promise<Selectable[]>;

public secondSelectorValues: Selectable[];

public secondSelectorFormControl: UntypedFormControl;
Expand Down Expand Up @@ -98,6 +100,11 @@ export class MotionManageMotionMeetingUsersComponent<V extends BaseHasMeetingUse
this._editMode = value;
this._addUsersSet.clear();
this._removeUsersMap = {};
if (value && this.loadSecondSelectorValues) {
this.loadSecondSelectorValues().then(items => {
this.secondSelectorValues = items;
});
}
}

public get isEditMode(): boolean {
Expand Down Expand Up @@ -235,7 +242,7 @@ export class MotionManageMotionMeetingUsersComponent<V extends BaseHasMeetingUse
}
}

public getDisabledFn(): (Selectable) => boolean {
public getDisabledFn(): (v: Selectable) => boolean {
return (value: Selectable) => this.secondSelectorDisabledIds.includes(value.id);
}

Expand All @@ -246,7 +253,7 @@ export class MotionManageMotionMeetingUsersComponent<V extends BaseHasMeetingUse
}

public get isSecondSelectorValuesFilled(): boolean {
return this.secondSelectorValues.length > 0;
return this.secondSelectorValues && this.secondSelectorValues.length > 0;
}

private updateData(models: V[]): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
additionalInputLabel="{{ 'Extension' | translate }}"
[additionalInputValue]="motion?.additional_submitter"
secondSelectorLabel="{{ 'Committees' | translate }}"
[secondSelectorValues]="forwardingCommittees"
[loadSecondSelectorValues]="loadForwardingCommittees"
></os-motion-manage-motion-meeting-users>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,14 @@ export class MotionMetaDataComponent extends BaseMotionDetailChildComponent impl
return this._referencedMotions;
}

public get forwardingCommittees(): Selectable[] {
return this._forwardingCommittees;
}
public loadForwardingCommittees: () => Promise<Selectable[]>;

private _referencingMotions: ViewMotion[];

private _referencedMotions: ViewMotion[];

private _forwardingAvailable = false;

private _forwardingCommittees: (Selectable & { name: string; toString: any })[] = [];

public get supportersObservable(): Observable<ViewUser[]> {
return this._supportersSubject;
}
Expand Down Expand Up @@ -152,6 +148,9 @@ export class MotionMetaDataComponent extends BaseMotionDetailChildComponent impl
if (operator.hasPerms(Permission.motionCanManage)) {
this.motionForwardingService.forwardingMeetingsAvailable().then(forwardingAvailable => {
this._forwardingAvailable = forwardingAvailable;
this.loadForwardingCommittees = async (): Promise<Selectable[]> => {
return (await this.checkPresenter()) as Selectable[];
};
});
} else {
this._forwardingAvailable = false;
Expand All @@ -164,7 +163,6 @@ export class MotionMetaDataComponent extends BaseMotionDetailChildComponent impl
this.subscriptions.push(
this.participantSort.getSortedViewModelListObservable().subscribe(() => this.updateSupportersSubject())
);
this.checkPresenter();
}

public override ngOnDestroy(): void {
Expand Down Expand Up @@ -388,21 +386,23 @@ export class MotionMetaDataComponent extends BaseMotionDetailChildComponent impl
}
}

private async checkPresenter(): Promise<void> {
private async checkPresenter(): Promise<(Selectable & { name: string; toString: any })[]> {
const meetingId = this.activeMeetingService.meetingId;
const committees =
this.operator.hasPerms(Permission.motionCanManage) && !!meetingId
? await this.presenter.call({ meeting_id: meetingId })
: [];
this._forwardingCommittees = [];
const forwardingCommittees: (Selectable & { name: string; toString: any })[] = [];
for (let n = 0; n < committees.length; n++) {
this._forwardingCommittees.push({
forwardingCommittees.push({
id: n + 1,
name: committees[n],
getTitle: () => committees[n],
getListTitle: () => ``,
toString: () => committees[n]
});
}

return forwardingCommittees;
}
}
Loading