Skip to content

Commit

Permalink
Fixes counting of active users (#913) (#976)
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielInTheWorld committed Mar 30, 2022
1 parent e95b15c commit 292af21
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 13 deletions.
7 changes: 2 additions & 5 deletions client/src/app/core/core-services/notify.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,10 @@ export class NotifyService {
users?: number[],
channels?: string[]
): Promise<void> {
if (!this.channelId) {
throw new Error(`No channel id!`);
}

const notify: NotifyRequest<T> = {
name,
message,
channel_id: this.channelId,
channel_id: this.channelId ?? this.activeMeetingIdService.meetingId?.toString(),
to_meeting: this.activeMeetingIdService.meetingId
};

Expand All @@ -253,6 +249,7 @@ export class NotifyService {
notify.to_channels = channels;
}

console.debug(`Send following data over ICC:`, PUBLISH_PATH, notify);
await this.httpService.post<unknown>(PUBLISH_PATH, notify);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export class UserRepositoryService
`pronoun`,
`username` /* Required! To getShortName */
];
const shortGroupFields: TypedFieldset<User> = shortNameFields.concat([{ templateField: `group_$_ids` }]);
const singleVotesFields = shortNameFields.concat([
{ templateField: `vote_weight_$` },
{ templateField: `structure_level_$` },
Expand Down Expand Up @@ -157,6 +158,7 @@ export class UserRepositoryService
return {
[DEFAULT_FIELDSET]: detailFields,
shortName: shortNameFields,
shortGroup: shortGroupFields,
list: listFields,
orgaList: orgaListFields,
orgaEdit: orgaEditFields,
Expand Down
7 changes: 1 addition & 6 deletions client/src/app/core/ui-services/count-users.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ const RESPONSE_NAME = `count-user-response`;
export class CountUsersService {
private activeCounts: { [token: string]: Subject<CountUserData> } = {};

private currentUserId: number;

/**
* Sets up all listeners
*
Expand All @@ -47,7 +45,7 @@ export class CountUsersService {
{
token: request.message.token,
data: {
userId: this.currentUserId
userId: operator.operatorId
}
},
request.sender_channel_id
Expand All @@ -61,9 +59,6 @@ export class CountUsersService {
this.activeCounts[response.message.token].next(response.message.data);
}
});

// Look for the current user.
operator.operatorIdObservable.subscribe(id => (this.currentUserId = id));
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { Component, OnDestroy } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { SimplifiedModelRequest } from 'app/core/core-services/model-request-builder.service';
import { ComponentServiceCollector } from 'app/core/ui-services/component-service-collector';
import { ViewMeeting } from 'app/management/models/view-meeting';
import { BaseModelContextComponent } from 'app/site/base/components/base-model-context.component';
import { Observable } from 'rxjs';
import { auditTime } from 'rxjs/operators';

Expand All @@ -11,11 +16,17 @@ import { CountUsersStatisticsService, CountUserStatistics } from '../../services
selector: `os-count-users`,
templateUrl: `./count-users.component.html`
})
export class CountUsersComponent implements OnDestroy {
export class CountUsersComponent extends BaseModelContextComponent implements OnDestroy {
public token: string = null;
public stats: CountUserStatistics = null;

public constructor(private countUsersStatisticService: CountUsersStatisticsService) {}
public constructor(
componentServiceCollector: ComponentServiceCollector,
translate: TranslateService,
private countUsersStatisticService: CountUsersStatisticsService
) {
super(componentServiceCollector, translate);
}

public countUsers(): void {
if (this.token) {
Expand Down Expand Up @@ -49,6 +60,16 @@ export class CountUsersComponent implements OnDestroy {
}

public ngOnDestroy(): void {
super.ngOnDestroy();
this.stopCounting();
}

protected getModelRequest(): SimplifiedModelRequest {
return {
viewModelCtor: ViewMeeting,
ids: [this.activeMeetingId],
follow: [`group_ids`, { idField: `user_ids`, fieldset: `shortGroup` }],
fieldset: []
};
}
}

0 comments on commit 292af21

Please sign in to comment.