bug fixed
This commit is contained in:
parent
d6ca5bc7ce
commit
0ad42ef10d
|
@ -32,14 +32,11 @@
|
|||
[value]="setting.method"
|
||||
(selectionChange)="onSelectionChangeMethod($event)"
|
||||
>
|
||||
<mat-option [value]="NotificationMethod.Sound">
|
||||
{{ 'settings.notification.methodTypeSound' | translate }}
|
||||
</mat-option>
|
||||
<mat-option [value]="NotificationMethod.Alert">
|
||||
{{ 'settings.notification.methodTypeAlert' | translate }}
|
||||
</mat-option>
|
||||
<mat-option [value]="NotificationMethod.SoundAndAlert">
|
||||
{{ 'settings.notification.methodTypeSoundAndAlert' | translate }}
|
||||
<mat-option
|
||||
*ngFor="let notificationMethod of notificationMethodList"
|
||||
[value]="notificationMethod.type"
|
||||
>
|
||||
{{ notificationMethod.name }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
|
|
@ -4,7 +4,8 @@ import {
|
|||
ChangeDetectorRef,
|
||||
Input,
|
||||
Output,
|
||||
EventEmitter
|
||||
EventEmitter,
|
||||
OnDestroy
|
||||
} from '@angular/core';
|
||||
import { NotificationSetting } from '../models/settings';
|
||||
import {
|
||||
|
@ -14,28 +15,48 @@ import {
|
|||
} from '@angular/material';
|
||||
import { NGXLogger } from 'ngx-logger';
|
||||
import { NotificationMethod } from '@ucap-webmessenger/core';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { Subscription, merge } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'ucap-settings-notification',
|
||||
templateUrl: './notification.component.html',
|
||||
styleUrls: ['./notification.component.scss']
|
||||
})
|
||||
export class NotificationComponent implements OnInit {
|
||||
export class NotificationComponent implements OnInit, OnDestroy {
|
||||
@Input()
|
||||
setting: NotificationSetting;
|
||||
|
||||
@Output()
|
||||
changed = new EventEmitter<NotificationSetting>();
|
||||
|
||||
notificationMethodList: { type: NotificationMethod; name: string }[];
|
||||
langChangeSubscription: Subscription;
|
||||
|
||||
NotificationMethod = NotificationMethod;
|
||||
|
||||
constructor(
|
||||
private translateService: TranslateService,
|
||||
private changeDetectorRef: ChangeDetectorRef,
|
||||
private logger: NGXLogger
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.logger.debug('setting', this.setting);
|
||||
|
||||
this.langChangeSubscription = merge(
|
||||
this.translateService.onLangChange,
|
||||
this.translateService.onDefaultLangChange,
|
||||
this.translateService.onTranslationChange
|
||||
).subscribe(() => {
|
||||
this.setNotificationMethodList();
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
if (!!this.langChangeSubscription) {
|
||||
this.langChangeSubscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
onChangeUse(event: MatRadioChange) {
|
||||
|
@ -62,4 +83,27 @@ export class NotificationComponent implements OnInit {
|
|||
this.setting = setting;
|
||||
this.changed.emit(this.setting);
|
||||
}
|
||||
|
||||
private setNotificationMethodList() {
|
||||
const langs = this.translateService.instant([
|
||||
'settings.notification.methodTypeSound',
|
||||
'settings.notification.methodTypeAlert',
|
||||
'settings.notification.methodTypeSoundAndAlert'
|
||||
]);
|
||||
|
||||
this.notificationMethodList = [
|
||||
{
|
||||
type: NotificationMethod.Sound,
|
||||
name: langs['settings.notification.methodTypeSound']
|
||||
},
|
||||
{
|
||||
type: NotificationMethod.Alert,
|
||||
name: langs['settings.notification.methodTypeAlert']
|
||||
},
|
||||
{
|
||||
type: NotificationMethod.SoundAndAlert,
|
||||
name: langs['settings.notification.methodTypeSoundAndAlert']
|
||||
}
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user