Fix notification settings

pull/5817/head
Chocobozzz 2023-05-24 17:22:40 +02:00
parent 431ebbd5e4
commit f9735a9e88
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
5 changed files with 8 additions and 3 deletions

View File

@ -12,6 +12,7 @@
<div>
<my-input-switch
[inputName]="'web-notification-' + notificationType"
[(ngModel)]="webNotifications[notificationType]"
(ngModelChange)="updateWebSetting(notificationType, webNotifications[notificationType])"
></my-input-switch>
@ -19,6 +20,7 @@
<div *ngIf="emailEnabled">
<my-input-switch
[inputName]="'email-notification-' + notificationType"
[(ngModel)]="emailNotifications[notificationType]"
(ngModelChange)="updateEmailSetting(notificationType, emailNotifications[notificationType])"
></my-input-switch>

View File

@ -3,6 +3,7 @@ import { Subject } from 'rxjs'
import { Component, Input, OnInit } from '@angular/core'
import { Notifier, ServerService, User } from '@app/core'
import { UserNotificationService } from '@app/shared/shared-main'
import { objectKeysTyped } from '@shared/core-utils'
import { UserNotificationSetting, UserNotificationSettingValue, UserRight } from '@shared/models'
@Component({
@ -141,7 +142,7 @@ export class MyAccountNotificationPreferencesComponent implements OnInit {
}
private loadNotificationSettings () {
for (const key of Object.keys(this.user.notificationSettings) as (keyof UserNotificationSetting)[]) {
for (const key of objectKeysTyped(this.user.notificationSettings)) {
const value = this.user.notificationSettings[key]
this.emailNotifications[key] = !!(value & UserNotificationSettingValue.EMAIL)

View File

@ -7,7 +7,7 @@
[ngbTooltip]="autoPlayNextVideoTooltip" placement="bottom-right auto"
>
<span i18n>AUTOPLAY</span>
<my-input-switch class="small" [(ngModel)]="autoPlayNextVideo" (ngModelChange)="switchAutoPlayNextVideo()"></my-input-switch>
<my-input-switch class="small" inputName="autoplay-next-video" [(ngModel)]="autoPlayNextVideo" (ngModelChange)="switchAutoPlayNextVideo()"></my-input-switch>
</div>
</div>

View File

@ -61,7 +61,7 @@
<my-global-icon iconName="p2p" aria-hidden="true"></my-global-icon>
<ng-container i18n>Help share videos</ng-container>
<my-input-switch class="ms-auto" [checked]="user.p2pEnabled"></my-input-switch>
<my-input-switch inputName="p2p-enabled" class="ms-auto" [checked]="user.p2pEnabled"></my-input-switch>
</button>
<div class="dropdown-divider"></div>

View File

@ -20,6 +20,7 @@ export class InputSwitchComponent implements ControlValueAccessor {
propagateChange = (_: any) => { /* empty */ }
writeValue (checked: boolean) {
console.log(checked)
this.checked = checked
}
@ -32,6 +33,7 @@ export class InputSwitchComponent implements ControlValueAccessor {
}
update () {
console.log(this.checked)
this.checked = !this.checked
this.propagateChange(this.checked)
}